Reputation: 5789
if I get color of text , I got : java.awt.Color[r=234,g=152,b=28] which should correspond to orange but when I perform the assertion : this is not working
assertEquals(Color.ORANGE.ToString(),myText.getColor());
expected :java.awt.Color[r=255,g=0,b=0] but was : java.awt.Color[r=234,g=152,b=28]
any idea ?
Upvotes: 0
Views: 6651
Reputation: 2124
You are comparing String and Color objects. Correct assertion is
assertEquals(Color.ORANGE, myText.getColor());
Also the java.awt.Color.orange is new Color(255, 200, 0);
.
Upvotes: 5
Reputation: 85476
And anyway in java/awt/Color.java source ORANGE is defined as:
/**
* The color orange. In the default sRGB space.
*/
public final static Color orange = new Color(255, 200, 0);
/**
* The color orange. In the default sRGB space.
* @since 1.4
*/
public final static Color ORANGE = orange;
Upvotes: 1