Advertisement
T99

SandboxTest.java

T99
Jun 28th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.58 KB | None | 0 0
  1. package com.t99sdevelopment.sandbox;
  2.  
  3. import org.junit.jupiter.api.Test;
  4.  
  5. import static com.t99sdevelopment.sandbox.Sandbox.tokenize;
  6. import static org.junit.jupiter.api.Assertions.*;
  7.  
  8. public class SandboxTest {
  9.    
  10.     @Test
  11.     void AbasicZeroLengthInput() {
  12.        
  13.         test("", new String[0]);
  14.        
  15.     }
  16.    
  17.     @Test
  18.     void BbasicSingleLengthInput() {
  19.        
  20.         test("a", new String[] {"a"});
  21.        
  22.     }
  23.    
  24.     @Test
  25.     void CcommandWithoutArgs() {
  26.    
  27.         test("command", new String[] {"command"});
  28.    
  29.     }
  30.    
  31.     @Test
  32.     void DcommandWithBasicArgs() {
  33.        
  34.         test("command arg1 arg2", new String[] {"command", "arg1", "arg2"});
  35.        
  36.     }
  37.    
  38.     @Test
  39.     void EcommandWithSingleQuoteGroupedArgs() {
  40.        
  41.         test("command 'arg 1' 'arg 2'", new String[] {"command", "arg 1", "arg 2"});
  42.        
  43.     }
  44.    
  45.     @Test
  46.     void FcommandWithDoubleQuoteGroupedArgs() {
  47.        
  48.         test("command \"arg 1\" \"arg 2\"", new String[] {"command", "arg 1", "arg 2"});
  49.        
  50.     }
  51.    
  52.     @Test
  53.     void GcommandWithGraveQuoteGroupedArgs() {
  54.        
  55.         test("command `arg 1` `arg 2`", new String[] {"command", "arg 1", "arg 2"});
  56.        
  57.     }
  58.    
  59.     void test(String input, String[] expectedOutput) {
  60.        
  61.         String[] actualOutput;
  62.        
  63.         try {
  64.            
  65.             actualOutput = tokenize(input);
  66.            
  67.             System.out.println("Input string:\t\t'" + input + "'");
  68.             System.out.println("Expected output:\t"+ Sandbox.arrayPrinter(expectedOutput));
  69.             System.out.println("Actual output:\t\t" + Sandbox.arrayPrinter(actualOutput));
  70.            
  71.             assertArrayEquals(expectedOutput, actualOutput);
  72.            
  73.         } catch (UnclosedDelimiterException e) {
  74.            
  75.             System.out.println(e.getMessage());
  76.            
  77.         }
  78.        
  79.     }
  80.    
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement