Exemplo n.º 1
0
 // test 7
 @Test
 public void testNoSuchFileExist() {
   try {
     WC counter = new WC(new String[] {"java", "WC", "i"});
   } catch (InputError ie) {
     // System.out.println(ie.getMessage());
     assertTrue(
         "incorrect error encountered",
         ie.getMessage()
                 .compareTo(
                     "[Input error] ERR07 - No such file exists. Please refer to the user manual for further information.")
             == 0);
   }
 }
Exemplo n.º 2
0
 // test 5
 @Test
 public void testInputDirectory() {
   try {
     WC counter = new WC(new String[] {"java", "WC", "src"});
   } catch (InputError ie) {
     // System.out.println(ie.getMessage());
     assertTrue(
         "incorrect error encountered",
         ie.getMessage()
                 .compareTo(
                     "[Input error] ERR05 - The file is a directory. Please refer to the user manual for further information.")
             == 0);
   }
 }
Exemplo n.º 3
0
 // test 6
 @Test
 public void testParseEmptyFile() {
   try {
     WC counter = new WC(new String[] {"java", "WC", "src" + File.separator + "test02.txt"});
   } catch (InputError ie) {
     // System.out.println(ie.getMessage());
     assertTrue(
         "incorrect error encountered",
         ie.getMessage()
                 .compareTo(
                     "[Input error] ERR06 - The file provided was empty. Please refer to the user manual for further information.")
             == 0);
   }
 }
Exemplo n.º 4
0
 // test 4
 @Test(expected = NullPointerException.class)
 public void testNoInputFile() {
   try {
     WC counter = new WC(new String[] {"java", "WC", null});
   } catch (InputError ie) {
     // System.out.println(ie.getMessage());
     assertTrue(
         "incorrect error encountered",
         ie.getMessage()
                 .compareTo(
                     "[Input error] ERR04 - No input file provided. Please refer to the user manual for further information.")
             == 0);
   }
 }