Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7c2a370

Browse files
[LEET-999] move test out of class
1 parent c89cc86 commit 7c2a370

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed
Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.stevesun.solutions;
22

33
import com.stevesun.common.classes.ListNode;
4-
import com.stevesun.common.utils.CommonUtils;
54

65
/**Given a sorted linked list, delete all duplicates such that each element appear only once.
76
@@ -21,15 +20,4 @@ public static ListNode deleteDuplicates(ListNode head) {
2120
}
2221
return ret.next;
2322
}
24-
25-
public static void main(String...strings){
26-
ListNode head = new ListNode(1);
27-
head.next = new ListNode(1);
28-
head.next.next = new ListNode(2);
29-
head.next.next.next = new ListNode(3);
30-
head.next.next.next.next = new ListNode(3);
31-
CommonUtils.printList(head);
32-
ListNode result = deleteDuplicates(head);
33-
CommonUtils.printList(result);
34-
}
3523
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.stevesun;
2+
3+
import com.stevesun.common.classes.ListNode;
4+
import com.stevesun.solutions.RemoveDuplicatesfromSortedList;
5+
import org.junit.Assert;
6+
import org.junit.Test;
7+
8+
/**
9+
* Created by stevesun on 4/18/17.
10+
*/
11+
public class RemoveDuplicatesfromSortedListTest {
12+
13+
@Test
14+
public void test1() {
15+
ListNode head = new ListNode(1);
16+
head.next = new ListNode(1);
17+
head.next.next = new ListNode(2);
18+
head.next.next.next = new ListNode(3);
19+
head.next.next.next.next = new ListNode(3);
20+
21+
RemoveDuplicatesfromSortedList test = new RemoveDuplicatesfromSortedList();
22+
23+
ListNode expected = new ListNode(1);
24+
expected.next = new ListNode(2);
25+
expected.next.next = new ListNode(3);
26+
27+
Assert.assertEquals(expected, test.deleteDuplicates(head));
28+
}
29+
}

0 commit comments

Comments
 (0)