Skip to content

Commit 1dd320e

Browse files
committed
Fix
1 parent f33ad33 commit 1dd320e

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/test/java/com/thealgorithms/conversions/EndianConverterTest.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,31 @@
77

88
public class EndianConverterTest {
99

10-
/**
11-
* Tests conversion from big-endian to little-endian using parameterized inputs.
12-
*/
1310
@ParameterizedTest
1411
@CsvSource({
15-
"0x12345678, 0x78563412", "0x00000000, 0x00000000", "0x01000000, 0x00000001",
16-
"0xFFFFFFFF, 0xFFFFFFFF", // -1 in two’s complement
17-
"0x7F000000, 0x0000007F" // Positive boundary case
12+
"0x78563412, 0x12345678",
13+
"0x00000000, 0x00000000",
14+
"0x00000001, 0x01000000",
15+
"0xFFFFFFFF, 0xFFFFFFFF", // -1 in two's complement
16+
"0x0000007F, 0x7F000000" // Positive boundary case
1817
})
19-
public void
20-
testBigToLittleEndian(int input, int expected) {
21-
assertEquals(expected, EndianConverter.bigToLittleEndian(input));
18+
public void testLittleToBigEndian(String inputHex, String expectedHex) {
19+
int input = (int) Long.parseLong(inputHex.substring(2), 16); // Convert hex string to int
20+
int expected = (int) Long.parseLong(expectedHex.substring(2), 16); // Convert hex string to int
21+
assertEquals(expected, EndianConverter.littleToBigEndian(input));
2222
}
2323

24-
/**
25-
* Tests conversion from little-endian to big-endian using parameterized inputs.
26-
*/
2724
@ParameterizedTest
2825
@CsvSource({
29-
"0x78563412, 0x12345678", "0x00000000, 0x00000000", "0x00000001, 0x01000000",
30-
"0xFFFFFFFF, 0xFFFFFFFF", // -1 in two’s complement
31-
"0x0000007F, 0x7F000000" // Positive boundary case
26+
"0x12345678, 0x78563412",
27+
"0x00000000, 0x00000000",
28+
"0x01000000, 0x00000001",
29+
"0xFFFFFFFF, 0xFFFFFFFF", // -1 in two's complement
30+
"0x7F000000, 0x0000007F" // Positive boundary case
3231
})
33-
public void
34-
testLittleToBigEndian(int input, int expected) {
35-
assertEquals(expected, EndianConverter.littleToBigEndian(input));
32+
public void testBigToLittleEndian(String inputHex, String expectedHex) {
33+
int input = (int) Long.parseLong(inputHex.substring(2), 16); // Convert hex string to int
34+
int expected = (int) Long.parseLong(expectedHex.substring(2), 16); // Convert hex string to int
35+
assertEquals(expected, EndianConverter.bigToLittleEndian(input));
3636
}
3737
}

0 commit comments

Comments
 (0)