Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 21.3k
Expand file tree
/
Copy pathHexaDecimalToDecimalTest.java
More file actions
Latest commit
37 lines (32 loc) · 1.19 KB
/
Copy pathHexaDecimalToDecimalTest.java
File metadata and controls
37 lines (32 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
packagecom.thealgorithms.conversions;
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
importstaticorg.junit.jupiter.api.Assertions.assertThrows;
importorg.junit.jupiter.params.ParameterizedTest;
importorg.junit.jupiter.params.provider.CsvSource;
publicclassHexaDecimalToDecimalTest {
@ParameterizedTest
@CsvSource({
"A1, 161", // Simple case with two characters
"1AC, 428", // Mixed-case input
"0, 0", // Single zero
"F, 15", // Single digit
"10, 16", // Power of 16
"FFFF, 65535", // Max 4-character hex
"7FFFFFFF, 2147483647"// Max positive int value
})
publicvoid
testValidHexaToDecimal(StringhexInput, intexpectedDecimal) {
assertEquals(expectedDecimal, HexaDecimalToDecimal.getHexaToDec(hexInput));
}
@ParameterizedTest
@CsvSource({
"G", // Invalid character
"1Z", // Mixed invalid input
"123G", // Valid prefix with invalid character
"#$%"// Non-hexadecimal symbols
})
publicvoid
testInvalidHexaToDecimal(StringinvalidHex) {
assertThrows(IllegalArgumentException.class, () -> HexaDecimalToDecimal.getHexaToDec(invalidHex));
}
}