Sfoglia il codice sorgente

Added testing for baseOptions

Trinh Tong 6 anni fa
parent
commit
79238f4d16
3 ha cambiato i file con 75 aggiunte e 2 eliminazioni
  1. 0
    1
      Console.java
  2. 1
    1
      SwitchDisplay.java
  3. 74
    0
      SwitchDisplayTest.java

+ 0
- 1
Console.java Vedi File

@@ -145,7 +145,6 @@ public class Console {
145 145
                     advAnswer = advCalc.sqrt(advInput1);
146 146
                 }else if (mode.equals("7")){
147 147
                     advAnswer = advCalc.factorial(advInput1);
148
-             
149 148
 
150 149
                 }else if (mode.equals("8")) {
151 150
                     break;

+ 1
- 1
SwitchDisplay.java Vedi File

@@ -59,7 +59,7 @@ public class SwitchDisplay
59 59
     
60 60
     public String toDecimal(int userInput) {
61 61
         
62
-        return Integer.toBinaryString((int)userInput);
62
+        return Integer.toString(userInput);
63 63
         
64 64
     }
65 65
     

+ 74
- 0
SwitchDisplayTest.java Vedi File

@@ -0,0 +1,74 @@
1
+
2
+
3
+import static org.junit.Assert.*;
4
+import org.junit.After;
5
+import org.junit.Before;
6
+import org.junit.Test;
7
+
8
+/**
9
+ * The test class SwitchDisplayTest.
10
+ *
11
+ * @author  (your name)
12
+ * @version (a version number or a date)
13
+ */
14
+public class SwitchDisplayTest
15
+{
16
+    /**
17
+     * Default constructor for test class SwitchDisplayTest
18
+     */
19
+    public SwitchDisplayTest()
20
+    {
21
+    }
22
+
23
+    /**
24
+     * Sets up the test fixture.
25
+     *
26
+     * Called before every test case method.
27
+     */
28
+    @Before
29
+    public void setUp()
30
+    {
31
+    }
32
+
33
+    /**
34
+     * Tears down the test fixture.
35
+     *
36
+     * Called after every test case method.
37
+     */
38
+    @After
39
+    public void tearDown()
40
+    {
41
+    }
42
+
43
+    @Test
44
+    public void toBinary()
45
+    {
46
+        SwitchDisplay switchDi1 = new SwitchDisplay();
47
+        assertEquals("101101", switchDi1.toBinary(45));
48
+    }
49
+
50
+    @Test
51
+    public void toOctal()
52
+    {
53
+        SwitchDisplay switchDi1 = new SwitchDisplay();
54
+        assertEquals("55", switchDi1.toOctal(45));
55
+    }
56
+
57
+    @Test
58
+    public void toHexa()
59
+    {
60
+        SwitchDisplay switchDi1 = new SwitchDisplay();
61
+        assertEquals("2d", switchDi1.toHexa(45));
62
+    }
63
+
64
+    @Test
65
+    public void toDecimal()
66
+    {
67
+        SwitchDisplay switchDi1 = new SwitchDisplay();
68
+        assertEquals("45", switchDi1.toDecimal(45));
69
+    }
70
+}
71
+
72
+
73
+
74
+