1
+ package recursion ;
2
+
3
+ import static org .junit .jupiter .api .Assertions .assertThrows ;
4
+
5
+ import javax .annotation .processing .Generated ;
6
+
7
+ import org .junit .AfterClass ;
8
+ import org .junit .Assert ;
9
+ import org .junit .BeforeClass ;
10
+ import org .junit .Test ;
11
+
12
+ @ Generated (value = "org.junit-tools-1.1.0" )
13
+ public class RecursiveDigitSumTest {
14
+
15
+ @ BeforeClass
16
+ public static void setUpBeforeClass () throws Exception {
17
+ System .out .println ("BeforeClass" );
18
+ }
19
+
20
+ @ AfterClass
21
+ public static void tearDownAfterClass () throws Exception {
22
+ System .out .println ("AfterClass" );
23
+ }
24
+
25
+ @ Test
26
+ public void testSuperDigitWithNull () throws Exception {
27
+ // TC1
28
+ int k = 0 ;
29
+ String n = null ;
30
+ String expected = "by input exception [" + n + "]" ;
31
+ Exception result = assertThrows (Exception .class ,
32
+ () -> RecursiveDigitSum .superDigit (n , k ));
33
+
34
+ Assert .assertEquals (expected , result .getMessage ());
35
+ }
36
+
37
+ @ Test
38
+ public void testSuperDigitWithEmpty () throws Exception {
39
+ // TC2
40
+ int k = 1 ;
41
+ String n = "" ;
42
+ int expected = 0 ;
43
+ int result = RecursiveDigitSum .superDigit (n , k );
44
+
45
+ Assert .assertEquals (expected , result );
46
+ }
47
+
48
+ @ Test
49
+ public void testSuperDigitWithNegative1 () throws Exception {
50
+ // TC3
51
+ int k = -1 ;
52
+ String n = "1" ;
53
+ String expected = "by input exception [" + k + "]" ;
54
+ Exception result = assertThrows (Exception .class ,
55
+ () -> RecursiveDigitSum .superDigit (n , k ));
56
+
57
+ Assert .assertEquals (expected , result .getMessage ());
58
+ }
59
+
60
+ @ Test
61
+ public void testSuperDigit1 () throws Exception {
62
+ // TC4
63
+ int k = 0 ;
64
+ String n = "1" ;
65
+ int expected = 1 ;
66
+ int result = RecursiveDigitSum .superDigit (n , k );
67
+
68
+ Assert .assertEquals (expected , result );
69
+ }
70
+
71
+ @ Test
72
+ public void testSuperDigitMax1 () throws Exception {
73
+ // TC5
74
+ int k = 999999999 ;
75
+ String n = "1" ;
76
+ int expected = 9 ;
77
+ int result = RecursiveDigitSum .superDigit (n , k );
78
+
79
+ Assert .assertEquals (expected , result );
80
+ }
81
+
82
+ @ Test
83
+ public void testSuperDigit3 () throws Exception {
84
+ // TC6
85
+ int k = 0 ;
86
+ String n = "12" ;
87
+ int expected = 3 ;
88
+ int result = RecursiveDigitSum .superDigit (n , k );
89
+
90
+ Assert .assertEquals (expected , result );
91
+ }
92
+
93
+ @ Test
94
+ public void testSuperDigit4 () throws Exception {
95
+ // TC7
96
+ int k = 1 ;
97
+ String n = "12" ;
98
+ int expected = 3 ;
99
+ int result = RecursiveDigitSum .superDigit (n , k );
100
+
101
+ Assert .assertEquals (expected , result );
102
+ }
103
+
104
+ @ Test
105
+ public void testSuperDigitMax2 () throws Exception {
106
+ // TC8
107
+ int k = 1 ;
108
+ String n = "999999999" ;
109
+ int expected = 9 ;
110
+ int result = RecursiveDigitSum .superDigit (n , k );
111
+
112
+ Assert .assertEquals (expected , result );
113
+ }
114
+
115
+ @ Test
116
+ public void testSuperDigitWithNegative2 () throws Exception {
117
+ // TC9
118
+ int k = 1 ;
119
+ String n = "-a" ;
120
+ String expected = "by input exception [" + n + "]" ;
121
+ Exception result = assertThrows (Exception .class ,
122
+ () -> RecursiveDigitSum .superDigit (n , k ));
123
+
124
+ Assert .assertEquals (expected , result .getMessage ());
125
+ }
126
+
127
+ }
0 commit comments