Skip to content

Commit

Permalink
Some tests on trim
Browse files Browse the repository at this point in the history
  • Loading branch information
VincenzoArceri committed Jul 11, 2023
1 parent ec852b2 commit e8b5c34
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,31 @@ public void repeatSingleString() throws MathNumberConversionException {
RegexAutomaton epsilon = RegexAutomaton.string("");
RegexAutomaton abc_with_ws = RegexAutomaton.string(" a b c ");
RegexAutomaton empty_star = RegexAutomaton.string(" ").star();

Tarsis a = new Tarsis(abc);
Tarsis b = new Tarsis(ws);
Tarsis c = new Tarsis(abc_with_ws);
Tarsis d = new Tarsis(empty_star);
RegexAutomaton comp1 = RegexAutomaton.string(" ").concat(RegexAutomaton.string(" abc"));
RegexAutomaton comp2 = RegexAutomaton.string(" a").concat(RegexAutomaton.string(" b "));

// "abc".trim() = "abc"
Tarsis a = new Tarsis(abc);
assertTrue(a.trim().getAutomaton().isEqualTo(abc));

// " ".trim() = ""
Tarsis b = new Tarsis(ws);
assertTrue(b.trim().getAutomaton().isEqualTo(epsilon));

// " a b c ".trim() = "a b c"
Tarsis c = new Tarsis(abc_with_ws);
assertTrue(c.trim().getAutomaton().isEqualTo(RegexAutomaton.string("a b c")));

// (" ")*.trim() = ""
Tarsis d = new Tarsis(empty_star);
assertTrue(d.trim().getAutomaton().isEqualTo(RegexAutomaton.emptyStr()));

// " " + " abc".trim() = "abc"
Tarsis e = new Tarsis(comp1);
assertTrue(e.trim().getAutomaton().isEqualTo(abc));

// " a" + " b ".trim() = "a b "
Tarsis f = new Tarsis(comp2);
assertTrue(f.trim().getAutomaton().isEqualTo(RegexAutomaton.string("a b ")));
}
}

0 comments on commit e8b5c34

Please sign in to comment.