PageRenderTime 13ms CodeModel.GetById 2ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/java/li_std_except_runme.java

#
Java | 29 lines | 26 code | 3 blank | 0 comment | 9 complexity | 370e3892e7f12ab10860d92f23177f8e MD5 | raw file
 1import li_std_except.*;
 2
 3public class li_std_except_runme {
 4
 5  static {
 6    try {
 7        System.loadLibrary("li_std_except");
 8    } catch (UnsatisfiedLinkError e) {
 9      System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
10      System.exit(1);
11    }
12  }
13
14  public static void main(String argv[]) throws Throwable
15  {
16    Test test = new Test();
17    try { test.throw_bad_exception(); throw new RuntimeException("throw_bad_exception failed"); } catch (RuntimeException e) {}
18    try { test.throw_domain_error(); throw new RuntimeException("throw_domain_error failed"); } catch (RuntimeException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); }
19    try { test.throw_exception(); throw new RuntimeException("throw_exception failed"); } catch (RuntimeException e) {}
20    try { test.throw_invalid_argument(); throw new RuntimeException("throw_invalid_argument failed"); } catch (IllegalArgumentException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); }
21    try { test.throw_length_error(); throw new RuntimeException("throw_length_error failed"); } catch (IndexOutOfBoundsException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); }
22    try { test.throw_logic_error(); throw new RuntimeException("throw_logic_error failed"); } catch (RuntimeException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); }
23    try { test.throw_out_of_range(); throw new RuntimeException("throw_out_of_range failed"); } catch (IndexOutOfBoundsException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); }
24    try { test.throw_overflow_error(); throw new RuntimeException("throw_overflow_error failed"); } catch (ArithmeticException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); }
25    try { test.throw_range_error(); throw new RuntimeException("throw_range_error failed"); } catch (IndexOutOfBoundsException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); }
26    try { test.throw_runtime_error(); throw new RuntimeException("throw_runtime_error failed"); } catch (RuntimeException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); }
27    try { test.throw_underflow_error(); throw new RuntimeException("throw_underflow_error failed"); } catch (ArithmeticException e) { if (!e.getMessage().equals("oops")) throw new RuntimeException("wrong message returned"); }
28  }
29}