Skip to content

Commit 40f9023

Browse files
authored
Add files via upload
1 parent 6f4399a commit 40f9023

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.jme3.math;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
6+
public class ColorRGBATest {
7+
8+
@Test
9+
public void testIntColor() {
10+
float r = 1,
11+
g = 0.2f,
12+
b = 0.6f,
13+
a = 0.8f;
14+
15+
ColorRGBA color = new ColorRGBA(r, g, b, a);
16+
17+
int rgba = color.asIntRGBA();
18+
int abgr = color.asIntABGR();
19+
int argb = color.asIntARGB();
20+
21+
Assert.assertEquals(-13395508, rgba);
22+
Assert.assertEquals(-862374913, abgr);
23+
Assert.assertEquals(-855690343, argb);
24+
25+
validateColor(new ColorRGBA().fromIntRGBA(rgba), 1.0f, 0.2f, 0.6f, 0.8f);
26+
validateColor(new ColorRGBA().fromIntABGR(abgr), 1.0f, 0.2f, 0.6f, 0.8f);
27+
validateColor(new ColorRGBA().fromIntARGB(argb), 1.0f, 0.2f, 0.6f, 0.8f);
28+
}
29+
30+
private void validateColor(ColorRGBA color, float r, float g, float b, float a) {
31+
Assert.assertEquals(r, color.r, 0.001f);
32+
Assert.assertEquals(g, color.g, 0.001f);
33+
Assert.assertEquals(b, color.b, 0.001f);
34+
Assert.assertEquals(a, color.a, 0.001f);
35+
}
36+
}

0 commit comments

Comments
 (0)