Main
Main copied to clipboard
Simpler assertion syntax
Instead of
@Test public void wikiPageRanksExample() {
final Graph<String> g = makeWikiExample();
assertEquals(11, g.size());
assertEquals(5, g.sourcesCount());
assertEquals(1, g.sinksCount());
assertEquals(1, g.inDegree(g.vertex("A")));
assertEquals(0, g.outDegree(g.vertex("A")));
assertEquals(6, g.inDegree(g.vertex("E")));
assertEquals(3, g.outDegree(g.vertex("E")));
assertEquals(11, Iterables.count(g.preOrder()));
verifyPreorder(g);
verifyGraph(g);
}
let me write
@Test public void wikiPageRanksExample() {
final Graph<String> g = makeWikiExample();
assert g.size() == 11 && 5 == g.sourcesCount() && 1, g.sinksCount() == 1 ....;
verifyPreorder(g);
verifyGraph(g);
}
and convert the later to the former at run time.
Moreover, convert
graph.isCyclic();
to
assert graph.isCyclic()
@yossigil
Do you prefer the complexed AND over the fluent AssertJ way ?
i.e :
for
assertEquals(x1,y1);
assertEquals(x2,y2);
...
assertEquals(xn,yn);
to :
x1.equals(y1) && x2.equals(y2) && ... && xn.equals(yn)
over :
assertThat(x1).is(y1);
assertThat(x2).is(y2);
...
assertThat(xn).is(yn);
?
The short syntax should be replaced by assertJ/assertEquals whatever you see fit.
Note also
assert a > 3 || a < 2;
Not between?
?