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

Commit88d6328

Browse files
committed
update lib
1 parentf1c3e93 commit88d6328

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

‎src/com/lintcode/Test.java

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
***************************************************************************
3+
* Some supplements to assertion in Junit Test
4+
*
5+
***************************************************************************
6+
*/
7+
packagecom.lintcode;
8+
9+
importjava.util.ArrayList;
10+
importjava.util.Arrays;
11+
importjava.util.Collections;
12+
importjava.util.List;
13+
14+
importstaticorg.junit.Assert.*;
15+
16+
publicclassTest {
17+
18+
/**
19+
* Asserts two lists are equals ignoring order of elements in list
20+
*
21+
* @param actual actual list value
22+
* @param expected expected list value
23+
*/
24+
publicstatic <T>voidassertEqualsIgnoreOrder(List<T>expected,
25+
List<T>actual) {
26+
List<String>act =toStringList(actual);
27+
List<String>exp =toStringList(expected);
28+
Collections.sort(act);
29+
Collections.sort(exp);
30+
assertEquals(exp,act);
31+
}
32+
33+
// convert to a list of string in order to compare
34+
privatestatic <T>List<String>toStringList(List<T>list) {
35+
List<String>result =newArrayList<>();
36+
for (Tl :list) {
37+
result.add(l.toString());
38+
}
39+
returnresult;
40+
}
41+
42+
/**
43+
* Asserts two lists of array are equals ignoring order of elements in list
44+
*
45+
* @param expected
46+
* @param actual
47+
*/
48+
publicstatic <T>voidassertArrayEqualsIgnoreOrder(List<T[]>expected,
49+
List<T[]>actual) {
50+
List<String>act =arrayToStringList(actual);
51+
List<String>exp =arrayToStringList(expected);
52+
Collections.sort(act);
53+
Collections.sort(exp);
54+
assertEquals(exp,act);
55+
}
56+
57+
privatestatic <T>List<String>arrayToStringList(List<T[]>list) {
58+
List<String>result =newArrayList<>();
59+
for (T[]l :list) {
60+
result.add(Arrays.toString(l));
61+
}
62+
returnresult;
63+
}
64+
65+
}

‎src/com/leetcode/TreeNode.javarenamed to‎src/com/lintcode/TreeNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
packagecom.leetcode;
1+
packagecom.lintcode;
22

33
importjava.util.LinkedList;
44
importjava.util.Queue;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp