Skip to content

Commit f7fa08f

Browse files
committed
Add more unit tests for max/min.
1 parent 8711009 commit f7fa08f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/test/java/com/github/underscore/_Test.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,22 @@ public Integer apply(Integer item) {
694694
}
695695
});
696696
assertEquals("2", resultComp.toString());
697+
class Person {
698+
public final String name;
699+
public final Integer age;
700+
public Person(final String name, final Integer age) {
701+
this.name = name;
702+
this.age = age;
703+
}
704+
};
705+
final Person resultPerson = _.max(asList(new Person("moe", 40), new Person("larry", 50), new Person("curly", 60)),
706+
new Function1<Person, Integer>() {
707+
public Integer apply(Person item) {
708+
return item.age;
709+
}
710+
});
711+
assertEquals("curly", resultPerson.name);
712+
assertEquals(60, resultPerson.age);
697713
}
698714

699715
/*
@@ -712,6 +728,22 @@ public Integer apply(Integer item) {
712728
}
713729
});
714730
assertEquals("1000", resultComp.toString());
731+
class Person {
732+
public final String name;
733+
public final Integer age;
734+
public Person(final String name, final Integer age) {
735+
this.name = name;
736+
this.age = age;
737+
}
738+
};
739+
final Person resultPerson = _.min(asList(new Person("moe", 40), new Person("larry", 50), new Person("curly", 60)),
740+
new Function1<Person, Integer>() {
741+
public Integer apply(Person item) {
742+
return item.age;
743+
}
744+
});
745+
assertEquals("moe", resultPerson.name);
746+
assertEquals(40, resultPerson.age);
715747
}
716748

717749
/*

0 commit comments

Comments
 (0)