Exemplo n.º 1
0
  public void test(ClassLoader cls_loader) throws Exception {
    Configuration.setRunAllTests(true);
    LoadTestSerialization loader = new LoadTestSerialization();
    List<TestSerialization> creators =
        loader.load(cls_loader, "edu.syr.pcpratts.rootbeer.testcases.rootbeertest.Main");
    List<TestException> ex_creators =
        loader.loadException(cls_loader, "edu.syr.pcpratts.rootbeer.testcases.rootbeertest.ExMain");
    int num_tests = creators.size() + ex_creators.size();
    int test_num = 1;

    for (TestSerialization creator : creators) {
      System.out.println("[TEST " + test_num + "/" + num_tests + "] " + creator.toString());
      test(creator);
      if (m_passed) {
        System.out.println("  PASSED");
        System.out.println("  Cpu time: " + m_cpuTime + " ms");
        System.out.println("  Gpu time: " + m_gpuTime + " ms");
      } else {
        System.out.println("  FAILED");
        System.out.println("  " + m_message);
        m_failedTests.add(creator.toString());
      }
      ++test_num;
    }

    for (TestException ex_creator : ex_creators) {
      System.out.println("[TEST " + test_num + "/" + num_tests + "] " + ex_creator.toString());
      ex_test(ex_creator);
      if (m_passed) {
        System.out.println("  PASSED");
      } else {
        System.out.println("  FAILED");
        System.out.println("  " + m_message);
        m_failedTests.add(ex_creator.toString());
      }
      ++test_num;
    }

    int test_passed = num_tests - m_failedTests.size();
    System.out.println(test_passed + "/" + num_tests + " tests PASS");
    if (test_passed == num_tests) {
      System.out.println("ALL TESTS PASS!");
    } else {
      System.out.println("Failing tests:");
      for (String failure : m_failedTests) {
        System.out.println("  " + failure);
      }
    }
  }
Exemplo n.º 2
0
 public void testOne(ClassLoader cls_loader, String test_case) throws Exception {
   Configuration.setRunAllTests(false);
   Class test_case_cls = cls_loader.loadClass(test_case);
   Object test_case_obj = test_case_cls.newInstance();
   if (test_case_obj instanceof TestSerialization) {
     TestSerialization test_ser = (TestSerialization) test_case_obj;
     System.out.println("[TEST 1/1] " + test_ser.toString());
     test(test_ser);
     if (m_passed) {
       System.out.println("  PASSED");
       System.out.println("  Cpu time: " + m_cpuTime + " ms");
       System.out.println("  Gpu time: " + m_gpuTime + " ms");
     } else {
       System.out.println("  FAILED");
       System.out.println("  " + m_message);
     }
   } else if (test_case_obj instanceof TestException) {
     TestException test_ex = (TestException) test_case_obj;
     System.out.println("[TEST 1/1] " + test_ex.toString());
     ex_test(test_ex);
     if (m_passed) {
       System.out.println("  PASSED");
     } else {
       System.out.println("  FAILED");
       System.out.println("  " + m_message);
     }
   } else {
     throw new RuntimeException("unknown test case type");
   }
 }