The Value of 0xFF Number and Its Uses With & Operation in Java Article by Abdallah Sawan

This commit is contained in:
AbdallahSawan 2020-11-02 10:31:44 +02:00
parent 12b927e2ae
commit 44ff0f03f6
1 changed files with 6 additions and 6 deletions

View File

@ -9,41 +9,41 @@ public class Number0xffUnitTest {
public void test0xFFAssignedToInteger() {
int x = 0xff;
int expectedValue = 255;
assertEquals(x, expectedValue);
assertEquals(expectedValue, x);
}
@Test
public void test0xFFAssignedToByte() {
byte y = (byte) 0xff;
int expectedValue = -1;
assertEquals(y, expectedValue);
assertEquals(expectedValue, y);
}
@Test
public void givenColor_whenGetRedColor_thenExtractRedColor() {
int rgba = 272214023;
int expectedValue = 16;
assertEquals(Number0xff.getRedColor(rgba), expectedValue);
assertEquals(expectedValue, Number0xff.getRedColor(rgba));
}
@Test
public void givenColor_whenGetGreenColor_thenExtractGreenColor() {
int rgba = 272214023;
int expectedValue = 57;
assertEquals(Number0xff.getGreenColor(rgba), expectedValue);
assertEquals(expectedValue, Number0xff.getGreenColor(rgba));
}
@Test
public void givenColor_whenGetBlueColor_thenExtractBlueColor() {
int rgba = 272214023;
int expectedValue = 168;
assertEquals(Number0xff.getBlueColor(rgba), expectedValue);
assertEquals(expectedValue, Number0xff.getBlueColor(rgba));
}
@Test
public void givenColor_whenGetAlfa_thenExtractAlfa() {
int rgba = 272214023;
int expectedValue = 7;
assertEquals(Number0xff.getAlfa(rgba), expectedValue);
assertEquals(expectedValue, Number0xff.getAlfa(rgba));
}
}