Updated tests
This commit is contained in:
parent
95ceff1506
commit
770abc054a
@ -12,6 +12,13 @@ class ParserTest {
|
||||
public void testParser() {
|
||||
Parser parser = null; // <-- Your implementation goes here
|
||||
|
||||
// test invalid strings -> should return null
|
||||
assertNull(parser.parse(""));
|
||||
assertNull(parser.parse("-"));
|
||||
assertNull(parser.parse("ls -"));
|
||||
assertNull(parser.parse("ls --"));
|
||||
|
||||
// test valid string
|
||||
testInput(parser, "ls", "ls", List.of(), List.of());
|
||||
testInput(parser, " ls -la", "ls", List.of("l", "a"), List.of());
|
||||
testInput(parser, "ls ./hello/world ", "ls", List.of(), List.of("./hello/world"));
|
||||
@ -20,6 +27,10 @@ class ParserTest {
|
||||
testInput(parser, " cd . ", "cd", List.of(), List.of("."));
|
||||
testInput(parser, " mkdir . ", "mkdir", List.of(), List.of("."));
|
||||
testInput(parser, "super -abc -de -f super nice danke paul", "super", List.of("a", "b", "c", "d", "e", "f"), List.of("super", "nice", "danke", "paul"));
|
||||
|
||||
// new tests
|
||||
|
||||
testInput(parser, "print hello-world", "print", List.of(), List.of("hello-world"));
|
||||
}
|
||||
|
||||
private void testInput(Parser parser, String input, String expectedCommand, List<String> expectedFlags, List<String> expectedArgs) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user