-
Notifications
You must be signed in to change notification settings - Fork 19.8k
/
Copy pathAnyBaseToDecimalTest.java
39 lines (32 loc) · 1.89 KB
/
AnyBaseToDecimalTest.java
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
38
39
package com.algorithms.conversions;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
class AnyBaseToDecimalTest {
@Test
void testAnyBaseToDecimal() {
AnyBaseToDecimal anyBaseToDecimal = new AnyBaseToDecimal();
assertEquals("Invalid Number", anyBaseToDecimal.convertToDecimal("2", 2));
assertEquals("Invalid Number", anyBaseToDecimal.convertToDecimal("3", 2));
assertEquals("3", anyBaseToDecimal.convertToDecimal("11", 2));
assertEquals("4", anyBaseToDecimal.convertToDecimal("100", 2));
assertEquals("5", anyBaseToDecimal.convertToDecimal("101", 2));
assertEquals("10", anyBaseToDecimal.convertToDecimal("1010", 2));
assertEquals("1024", anyBaseToDecimal.convertToDecimal("10000000000", 2));
assertEquals("Invalid Number", anyBaseToDecimal.convertToDecimal("8", 8));
assertEquals("Invalid Number", anyBaseToDecimal.convertToDecimal("9", 8));
assertEquals("7", anyBaseToDecimal.convertToDecimal("7", 8));
assertEquals("8", anyBaseToDecimal.convertToDecimal("10", 8));
assertEquals("9", anyBaseToDecimal.convertToDecimal("11", 8));
assertEquals("10", anyBaseToDecimal.convertToDecimal("12", 8));
assertEquals("1024", anyBaseToDecimal.convertToDecimal("2000", 8));
assertEquals("Invalid Number", anyBaseToDecimal.convertToDecimal("A", 10));
assertEquals("10", anyBaseToDecimal.convertToDecimal("10", 10));
assertEquals("1024", anyBaseToDecimal.convertToDecimal("1024", 10));
assertEquals("Invalid Number", anyBaseToDecimal.convertToDecimal("G", 16));
assertEquals("16", anyBaseToDecimal.convertToDecimal("10", 16));
assertEquals("17", anyBaseToDecimal.convertToDecimal("11", 16));
assertEquals("100", anyBaseToDecimal.convertToDecimal("64", 16));
assertEquals("225", anyBaseToDecimal.convertToDecimal("E1", 16));
assertEquals("1024", anyBaseToDecimal.convertToDecimal("400", 16));
}
}