PageRenderTime 24ms CodeModel.GetById 10ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/csharp/catches_runme.cs

#
C# | 66 lines | 55 code | 8 blank | 3 comment | 14 complexity | 7d7f2e5c9a3b27aefa1bacd688d46304 MD5 | raw file
 1using System;
 2using catchesNamespace;
 3
 4public class runme {
 5  static void Main() {
 6    // test_catches()
 7    try {
 8      catches.test_catches(1);
 9      throw new Exception("missed exception");
10    } catch (ApplicationException e) {
11      if (e.Message != "C++ int exception thrown, value: 1")
12        throw new ApplicationException("bad exception order: " + e.Message);
13    }
14
15    try {
16      catches.test_catches(2);
17      throw new Exception("missed exception");
18    } catch (ApplicationException e) {
19      if (e.Message != "two")
20        throw new ApplicationException("bad exception order: " + e.Message);
21    }
22
23    try {
24      catches.test_catches(3);
25      throw new Exception("missed exception");
26    } catch (ApplicationException e) {
27      if (e.Message != "C++ ThreeException const & exception thrown")
28        throw new ApplicationException("bad exception order: " + e.Message);
29    }
30
31    // test_exception_specification()
32    try {
33      catches.test_exception_specification(1);
34      throw new Exception("missed exception");
35    } catch (ApplicationException e) {
36      if (e.Message != "C++ int exception thrown, value: 1")
37        throw new ApplicationException("bad exception order: " + e.Message);
38    }
39
40    try {
41      catches.test_exception_specification(2);
42      throw new Exception("missed exception");
43    } catch (ApplicationException e) {
44      if (e.Message != "unknown exception")
45        throw new ApplicationException("bad exception order: " + e.Message);
46    }
47
48    try {
49      catches.test_exception_specification(3);
50      throw new Exception("missed exception");
51    } catch (ApplicationException e) {
52      if (e.Message != "unknown exception")
53        throw new ApplicationException("bad exception order: " + e.Message);
54    }
55
56    // test_catches_all()
57    try {
58      catches.test_catches_all(1);
59      throw new Exception("missed exception");
60    } catch (ApplicationException e) {
61      if (e.Message != "unknown exception")
62        throw new ApplicationException("bad exception order: " + e.Message);
63    }
64
65  }
66}