2 using li_std_stringNamespace;
8 // Checking expected use of %typemap(in) std::string {}
9 li_std_string.test_value("Fee");
11 // Checking expected result of %typemap(out) std::string {}
12 if (li_std_string.test_value("Fi") != "Fi")
13 throw new Exception("Test 1 failed");
15 // Verify type-checking for %typemap(in) std::string {}
17 li_std_string.test_value(null);
18 throw new Exception("Test 2 failed");
19 } catch (ArgumentNullException) {
22 // Checking expected use of %typemap(in) const std::string & {}
23 li_std_string.test_const_reference("Fo");
25 // Checking expected result of %typemap(out) const std::string& {}
26 if (li_std_string.test_const_reference("Fum") != "Fum")
27 throw new Exception("Test 3 failed");
29 // Verify type-checking for %typemap(in) const std::string & {}
31 li_std_string.test_const_reference(null);
32 throw new Exception("Test 4 failed");
33 } catch (ArgumentNullException) {
37 // Input and output typemaps for pointers and non-const references to
38 // std::string are *not* supported; the following tests confirm
39 // that none of these cases are slipping through.
42 SWIGTYPE_p_std__string stringPtr = null;
44 stringPtr = li_std_string.test_pointer_out();
46 li_std_string.test_pointer(stringPtr);
48 stringPtr = li_std_string.test_const_pointer_out();
50 li_std_string.test_const_pointer(stringPtr);
52 stringPtr = li_std_string.test_reference_out();
54 li_std_string.test_reference(stringPtr);
56 // Check throw exception specification
58 li_std_string.test_throw();
59 throw new Exception("Test 5 failed");
60 } catch (ApplicationException e) {
61 if (e.Message != "test_throw message")
62 throw new Exception("Test 5 string check: " + e.Message);
65 li_std_string.test_const_reference_throw();
66 throw new Exception("Test 6 failed");
67 } catch (ApplicationException e) {
68 if (e.Message != "test_const_reference_throw message")
69 throw new Exception("Test 6 string check: " + e.Message);
73 const string s = "initial string";
74 if (li_std_string.GlobalString2 != "global string 2")
75 throw new Exception("GlobalString2 test 1");
76 li_std_string.GlobalString2 = s;
77 if (li_std_string.GlobalString2 != s)
78 throw new Exception("GlobalString2 test 2");
79 if (li_std_string.ConstGlobalString != "const global string")
80 throw new Exception("ConstGlobalString test");
83 Structure myStructure = new Structure();
84 if (myStructure.MemberString2 != "member string 2")
85 throw new Exception("MemberString2 test 1");
86 myStructure.MemberString2 = s;
87 if (myStructure.MemberString2 != s)
88 throw new Exception("MemberString2 test 2");
89 if (myStructure.ConstMemberString != "const member string")
90 throw new Exception("ConstMemberString test");
92 if (Structure.StaticMemberString2 != "static member string 2")
93 throw new Exception("StaticMemberString2 test 1");
94 Structure.StaticMemberString2 = s;
95 if (Structure.StaticMemberString2 != s)
96 throw new Exception("StaticMemberString2 test 2");
97 if (Structure.ConstStaticMemberString != "const static member string")
98 throw new Exception("ConstStaticMemberString test");