Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.t99sdevelopment.sandbox;
- import org.junit.jupiter.api.Test;
- import static com.t99sdevelopment.sandbox.Sandbox.tokenize;
- import static org.junit.jupiter.api.Assertions.*;
- public class SandboxTest {
- @Test
- void AbasicZeroLengthInput() {
- test("", new String[0]);
- }
- @Test
- void BbasicSingleLengthInput() {
- test("a", new String[] {"a"});
- }
- @Test
- void CcommandWithoutArgs() {
- test("command", new String[] {"command"});
- }
- @Test
- void DcommandWithBasicArgs() {
- test("command arg1 arg2", new String[] {"command", "arg1", "arg2"});
- }
- @Test
- void EcommandWithSingleQuoteGroupedArgs() {
- test("command 'arg 1' 'arg 2'", new String[] {"command", "arg 1", "arg 2"});
- }
- @Test
- void FcommandWithDoubleQuoteGroupedArgs() {
- test("command \"arg 1\" \"arg 2\"", new String[] {"command", "arg 1", "arg 2"});
- }
- @Test
- void GcommandWithGraveQuoteGroupedArgs() {
- test("command `arg 1` `arg 2`", new String[] {"command", "arg 1", "arg 2"});
- }
- void test(String input, String[] expectedOutput) {
- String[] actualOutput;
- try {
- actualOutput = tokenize(input);
- System.out.println("Input string:\t\t'" + input + "'");
- System.out.println("Expected output:\t"+ Sandbox.arrayPrinter(expectedOutput));
- System.out.println("Actual output:\t\t" + Sandbox.arrayPrinter(actualOutput));
- assertArrayEquals(expectedOutput, actualOutput);
- } catch (UnclosedDelimiterException e) {
- System.out.println(e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement