PageRenderTime 35ms CodeModel.GetById 13ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. using System;
  2. using catchesNamespace;
  3. public class runme {
  4. static void Main() {
  5. // test_catches()
  6. try {
  7. catches.test_catches(1);
  8. throw new Exception("missed exception");
  9. } catch (ApplicationException e) {
  10. if (e.Message != "C++ int exception thrown, value: 1")
  11. throw new ApplicationException("bad exception order: " + e.Message);
  12. }
  13. try {
  14. catches.test_catches(2);
  15. throw new Exception("missed exception");
  16. } catch (ApplicationException e) {
  17. if (e.Message != "two")
  18. throw new ApplicationException("bad exception order: " + e.Message);
  19. }
  20. try {
  21. catches.test_catches(3);
  22. throw new Exception("missed exception");
  23. } catch (ApplicationException e) {
  24. if (e.Message != "C++ ThreeException const & exception thrown")
  25. throw new ApplicationException("bad exception order: " + e.Message);
  26. }
  27. // test_exception_specification()
  28. try {
  29. catches.test_exception_specification(1);
  30. throw new Exception("missed exception");
  31. } catch (ApplicationException e) {
  32. if (e.Message != "C++ int exception thrown, value: 1")
  33. throw new ApplicationException("bad exception order: " + e.Message);
  34. }
  35. try {
  36. catches.test_exception_specification(2);
  37. throw new Exception("missed exception");
  38. } catch (ApplicationException e) {
  39. if (e.Message != "unknown exception")
  40. throw new ApplicationException("bad exception order: " + e.Message);
  41. }
  42. try {
  43. catches.test_exception_specification(3);
  44. throw new Exception("missed exception");
  45. } catch (ApplicationException e) {
  46. if (e.Message != "unknown exception")
  47. throw new ApplicationException("bad exception order: " + e.Message);
  48. }
  49. // test_catches_all()
  50. try {
  51. catches.test_catches_all(1);
  52. throw new Exception("missed exception");
  53. } catch (ApplicationException e) {
  54. if (e.Message != "unknown exception")
  55. throw new ApplicationException("bad exception order: " + e.Message);
  56. }
  57. }
  58. }