Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/test/java/com/github/underscore/ArraysTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ public Person(final String name, final Integer age) {
}

public int compareTo(Person person) {
return person.age - this.age;
return Integer.compare(person.age, this.age);
}

public String toString() {
Expand Down
14 changes: 9 additions & 5 deletions src/test/java/com/github/underscore/CollectionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1282,22 +1282,26 @@ void sortWith() {
Underscore.sortWith(
asList(1, 2, 3, 4, 5, 6),
(item1, item2) ->
(int) (Math.sin(item1) * 1000) - (int) (Math.sin(item2) * 1000));
Integer.compare(
(int) (Math.sin(item1) * 1000),
(int) (Math.sin(item2) * 1000)));
assertEquals("[5, 4, 6, 3, 1, 2]", result.toString());
final List<Integer> resultObj =
new Underscore<>(asList(1, 2, 3, 4, 5, 6))
.sortWith(
(item1, item2) ->
(int) (Math.sin(item1) * 1000)
- (int) (Math.sin(item2) * 1000));
Integer.compare(
(int) (Math.sin(item1) * 1000),
(int) (Math.sin(item2) * 1000)));
assertEquals("[5, 4, 6, 3, 1, 2]", resultObj.toString());
final List<Integer> resultChain =
Underscore.chain(asList(1, 2, 3, 4, 5, 6))
.sortWith(
(Comparator<Integer>)
(item1, item2) ->
(int) (Math.sin(item1) * 1000)
- (int) (Math.sin(item2) * 1000))
Integer.compare(
(int) (Math.sin(item1) * 1000),
(int) (Math.sin(item2) * 1000)))
.value();
assertEquals("[5, 4, 6, 3, 1, 2]", resultChain.toString());
}
Expand Down
37 changes: 19 additions & 18 deletions src/test/java/com/github/underscore/LodashTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,7 @@ void fetchPut() {
null);
assertEquals(404, result2.getStatus());
U.Chain<String> resultChain =
U.chain(
"http://www.w3schools.com/xml/note.xml")
U.chain("http://www.w3schools.com/xml/note.xml")
.fetch(
"PUT",
"{"
Expand Down Expand Up @@ -1180,20 +1179,22 @@ void xmpToJson7() {
}

@ParameterizedTest(name = "{0}")
@CsvSource(delimiter = '|', value = {
// input | expected (k=v,k=v)
"key=\"value\" | key=value",
"key='value' | key=value",
"a=\"1\" b='2' | a=1,b=2",
"key=\"it's a value\" | key=it's a value",
"key='say \"hi\"' | key=say \"hi\"",
"key=\"a=b=c\" | key=a=b=c",
"key=\"\" | key=",
" key =\"value\" | key=value",
"data-id=\"5\" | data-id=5",
"x==\"y\" | x=y",
"k=\"first\" k=\"second\" | k=second",
})
@CsvSource(
delimiter = '|',
value = {
// input | expected (k=v,k=v)
"key=\"value\" | key=value",
"key='value' | key=value",
"a=\"1\" b='2' | a=1,b=2",
"key=\"it's a value\" | key=it's a value",
"key='say \"hi\"' | key=say \"hi\"",
"key=\"a=b=c\" | key=a=b=c",
"key=\"\" | key=",
" key =\"value\" | key=value",
"data-id=\"5\" | data-id=5",
"x==\"y\" | x=y",
"k=\"first\" k=\"second\" | k=second",
})
void parses(String input, String expected) {
assertEquals(parse(expected), Xml.parseAttributes(input));
}
Expand All @@ -1211,8 +1212,8 @@ void producesNothing(String input) {

@Test
void preservesInsertionOrder() {
assertEquals("[z, a, m]",
Xml.parseAttributes("z=\"1\" a=\"2\" m=\"3\"").keySet().toString());
assertEquals(
"[z, a, m]", Xml.parseAttributes("z=\"1\" a=\"2\" m=\"3\"").keySet().toString());
}

// builds expected map from "k=v,k=v"
Expand Down
Loading