Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit101deaa

Browse files
committed
002 (3) update tests
1 parentf807716 commit101deaa

File tree

2 files changed

+73
-27
lines changed

2 files changed

+73
-27
lines changed

‎test/_002_AddTwoNumbers/PracticeTest.java

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,43 +31,66 @@ public void tearDown() throws Exception {
3131
// 342 + 564 = 807
3232
@Test
3333
publicvoidTest1() {
34-
int[]nums1 = {2,4,3};
35-
int[]nums2 = {5,6,4};
34+
int[]nums1 = {2,4,3};
35+
int[]nums2 = {5,6,4};
3636
ListNodea =ListNode.constructLinkedList(nums1);
3737
ListNodeb =ListNode.constructLinkedList(nums2);
3838
ListNodeactual =solution.addTwoNumbers(a,b);
39-
int[]exps = {7,0,8};
39+
int[]exps = {7,0,8};
4040
ListNodeexpected =ListNode.constructLinkedList(exps);
4141
assertTrue(ListNode.isSameList(actual,expected));
42-
4342
}
4443

45-
// 2 + 499 = 501
44+
// 2 + 499 = 501
4645
@Test
4746
publicvoidTest2() {
48-
int[]nums1 = {2};
49-
int[]nums2 = {9,9,4};
47+
int[]nums1 = {2};
48+
int[]nums2 = {9,9,4};
5049
ListNodea =ListNode.constructLinkedList(nums1);
5150
ListNodeb =ListNode.constructLinkedList(nums2);
5251
ListNodeactual =solution.addTwoNumbers(a,b);
53-
int[]exps = {1,0,5};
52+
int[]exps = {1,0,5};
5453
ListNodeexpected =ListNode.constructLinkedList(exps);
5554
assertTrue(ListNode.isSameList(actual,expected));
56-
5755
}
5856

5957
// 8 + 2 = 10
6058
@Test
6159
publicvoidTest3() {
62-
int[]nums1 = {2};
63-
int[]nums2 = {8};
60+
int[]nums1 = {2};
61+
int[]nums2 = {8};
6462
ListNodea =ListNode.constructLinkedList(nums1);
6563
ListNodeb =ListNode.constructLinkedList(nums2);
6664
ListNodeactual =solution.addTwoNumbers(a,b);
67-
int[]exps = {0,1};
65+
int[]exps = {0,1 };
66+
ListNodeexpected =ListNode.constructLinkedList(exps);
67+
assertTrue(ListNode.isSameList(actual,expected));
68+
}
69+
70+
// 499 + 3 = 502
71+
@Test
72+
publicvoidTest4() {
73+
int[]nums1 = {9,9,4 };
74+
int[]nums2 = {3 };
75+
ListNodea =ListNode.constructLinkedList(nums1);
76+
ListNodeb =ListNode.constructLinkedList(nums2);
77+
ListNodeactual =solution.addTwoNumbers(a,b);
78+
int[]exps = {2,0,5 };
79+
ListNodeexpected =ListNode.constructLinkedList(exps);
80+
assertTrue(ListNode.isSameList(actual,expected));
81+
}
82+
83+
// 0 + 20 = 20
84+
@Test
85+
publicvoidTest5() {
86+
int[]nums1 = {0 };
87+
int[]nums2 = {0,2 };
88+
ListNodea =ListNode.constructLinkedList(nums1);
89+
ListNodeb =ListNode.constructLinkedList(nums2);
90+
ListNodeactual =solution.addTwoNumbers(a,b);
91+
int[]exps = {0,2 };
6892
ListNodeexpected =ListNode.constructLinkedList(exps);
6993
assertTrue(ListNode.isSameList(actual,expected));
70-
7194
}
7295

7396
}

‎test/_002_AddTwoNumbers/SolutionTest.java

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
importcom.leetcode.ListNode;
1212

1313
publicclassSolutionTest {
14-
14+
1515
/** Test method for {@link _002_AddTwoNumbers.Solution } */
1616
Solutionsolution;
1717

@@ -31,43 +31,66 @@ public void tearDown() throws Exception {
3131
// 342 + 564 = 807
3232
@Test
3333
publicvoidTest1() {
34-
int[]nums1 = {2,4,3};
35-
int[]nums2 = {5,6,4};
34+
int[]nums1 = {2,4,3};
35+
int[]nums2 = {5,6,4};
3636
ListNodea =ListNode.constructLinkedList(nums1);
3737
ListNodeb =ListNode.constructLinkedList(nums2);
3838
ListNodeactual =solution.addTwoNumbers(a,b);
39-
int[]exps = {7,0,8};
39+
int[]exps = {7,0,8};
4040
ListNodeexpected =ListNode.constructLinkedList(exps);
4141
assertTrue(ListNode.isSameList(actual,expected));
42-
4342
}
4443

45-
// 2 + 499 = 501
44+
// 2 + 499 = 501
4645
@Test
4746
publicvoidTest2() {
48-
int[]nums1 = {2};
49-
int[]nums2 = {9,9,4};
47+
int[]nums1 = {2};
48+
int[]nums2 = {9,9,4};
5049
ListNodea =ListNode.constructLinkedList(nums1);
5150
ListNodeb =ListNode.constructLinkedList(nums2);
5251
ListNodeactual =solution.addTwoNumbers(a,b);
53-
int[]exps = {1,0,5};
52+
int[]exps = {1,0,5};
5453
ListNodeexpected =ListNode.constructLinkedList(exps);
5554
assertTrue(ListNode.isSameList(actual,expected));
56-
5755
}
5856

5957
// 8 + 2 = 10
6058
@Test
6159
publicvoidTest3() {
62-
int[]nums1 = {2};
63-
int[]nums2 = {8};
60+
int[]nums1 = {2 };
61+
int[]nums2 = {8 };
62+
ListNodea =ListNode.constructLinkedList(nums1);
63+
ListNodeb =ListNode.constructLinkedList(nums2);
64+
ListNodeactual =solution.addTwoNumbers(a,b);
65+
int[]exps = {0,1 };
66+
ListNodeexpected =ListNode.constructLinkedList(exps);
67+
assertTrue(ListNode.isSameList(actual,expected));
68+
}
69+
70+
// 499 + 3 = 502
71+
@Test
72+
publicvoidTest4() {
73+
int[]nums1 = {9,9,4 };
74+
int[]nums2 = {3 };
75+
ListNodea =ListNode.constructLinkedList(nums1);
76+
ListNodeb =ListNode.constructLinkedList(nums2);
77+
ListNodeactual =solution.addTwoNumbers(a,b);
78+
int[]exps = {2,0,5 };
79+
ListNodeexpected =ListNode.constructLinkedList(exps);
80+
assertTrue(ListNode.isSameList(actual,expected));
81+
}
82+
83+
// 0 + 20 = 20
84+
@Test
85+
publicvoidTest5() {
86+
int[]nums1 = {0 };
87+
int[]nums2 = {0,2 };
6488
ListNodea =ListNode.constructLinkedList(nums1);
6589
ListNodeb =ListNode.constructLinkedList(nums2);
6690
ListNodeactual =solution.addTwoNumbers(a,b);
67-
int[]exps = {0,1};
91+
int[]exps = {0,2};
6892
ListNodeexpected =ListNode.constructLinkedList(exps);
6993
assertTrue(ListNode.isSameList(actual,expected));
70-
7194
}
7295

7396
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp