Skip to content

Commit 4da0907

Browse files
committed
Sync with underscore-java
1 parent 6b2d946 commit 4da0907

3 files changed

Lines changed: 29 additions & 24 deletions

File tree

‎src/test/java/com/github/underscore/ArraysTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ public Person(final String name, final Integer age) {
765765
}
766766

767767
public int compareTo(Person person) {
768-
return person.age - this.age;
768+
return Integer.compare(person.age, this.age);
769769
}
770770

771771
public String toString() {

‎src/test/java/com/github/underscore/CollectionsTest.java‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,22 +1282,26 @@ void sortWith() {
12821282
Underscore.sortWith(
12831283
asList(1, 2, 3, 4, 5, 6),
12841284
(item1, item2) ->
1285-
(int) (Math.sin(item1) * 1000) - (int) (Math.sin(item2) * 1000));
1285+
Integer.compare(
1286+
(int) (Math.sin(item1) * 1000),
1287+
(int) (Math.sin(item2) * 1000)));
12861288
assertEquals("[5, 4, 6, 3, 1, 2]", result.toString());
12871289
final List<Integer> resultObj =
12881290
new Underscore<>(asList(1, 2, 3, 4, 5, 6))
12891291
.sortWith(
12901292
(item1, item2) ->
1291-
(int) (Math.sin(item1) * 1000)
1292-
- (int) (Math.sin(item2) * 1000));
1293+
Integer.compare(
1294+
(int) (Math.sin(item1) * 1000),
1295+
(int) (Math.sin(item2) * 1000)));
12931296
assertEquals("[5, 4, 6, 3, 1, 2]", resultObj.toString());
12941297
final List<Integer> resultChain =
12951298
Underscore.chain(asList(1, 2, 3, 4, 5, 6))
12961299
.sortWith(
12971300
(Comparator<Integer>)
12981301
(item1, item2) ->
1299-
(int) (Math.sin(item1) * 1000)
1300-
- (int) (Math.sin(item2) * 1000))
1302+
Integer.compare(
1303+
(int) (Math.sin(item1) * 1000),
1304+
(int) (Math.sin(item2) * 1000)))
13011305
.value();
13021306
assertEquals("[5, 4, 6, 3, 1, 2]", resultChain.toString());
13031307
}

‎src/test/java/com/github/underscore/LodashTest.java‎

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -742,8 +742,7 @@ void fetchPut() {
742742
null);
743743
assertEquals(404, result2.getStatus());
744744
U.Chain<String> resultChain =
745-
U.chain(
746-
"http://www.w3schools.com/xml/note.xml")
745+
U.chain("http://www.w3schools.com/xml/note.xml")
747746
.fetch(
748747
"PUT",
749748
"{"
@@ -1180,20 +1179,22 @@ void xmpToJson7() {
11801179
}
11811180

11821181
@ParameterizedTest(name = "{0}")
1183-
@CsvSource(delimiter = '|', value = {
1184-
// input | expected (k=v,k=v)
1185-
"key=\"value\" | key=value",
1186-
"key='value' | key=value",
1187-
"a=\"1\" b='2' | a=1,b=2",
1188-
"key=\"it's a value\" | key=it's a value",
1189-
"key='say \"hi\"' | key=say \"hi\"",
1190-
"key=\"a=b=c\" | key=a=b=c",
1191-
"key=\"\" | key=",
1192-
" key =\"value\" | key=value",
1193-
"data-id=\"5\" | data-id=5",
1194-
"x==\"y\" | x=y",
1195-
"k=\"first\" k=\"second\" | k=second",
1196-
})
1182+
@CsvSource(
1183+
delimiter = '|',
1184+
value = {
1185+
// input | expected (k=v,k=v)
1186+
"key=\"value\" | key=value",
1187+
"key='value' | key=value",
1188+
"a=\"1\" b='2' | a=1,b=2",
1189+
"key=\"it's a value\" | key=it's a value",
1190+
"key='say \"hi\"' | key=say \"hi\"",
1191+
"key=\"a=b=c\" | key=a=b=c",
1192+
"key=\"\" | key=",
1193+
" key =\"value\" | key=value",
1194+
"data-id=\"5\" | data-id=5",
1195+
"x==\"y\" | x=y",
1196+
"k=\"first\" k=\"second\" | k=second",
1197+
})
11971198
void parses(String input, String expected) {
11981199
assertEquals(parse(expected), Xml.parseAttributes(input));
11991200
}
@@ -1211,8 +1212,8 @@ void producesNothing(String input) {
12111212

12121213
@Test
12131214
void preservesInsertionOrder() {
1214-
assertEquals("[z, a, m]",
1215-
Xml.parseAttributes("z=\"1\" a=\"2\" m=\"3\"").keySet().toString());
1215+
assertEquals(
1216+
"[z, a, m]", Xml.parseAttributes("z=\"1\" a=\"2\" m=\"3\"").keySet().toString());
12161217
}
12171218

12181219
// builds expected map from "k=v,k=v"

0 commit comments

Comments
 (0)