mirror of https://github.com/swig/swig
Expand li_std_string_runme.*
Add testing of the empty and null cases for all languages which already have a runme.
This commit is contained in:
parent
1a31e9dc0c
commit
a44a7de348
|
@ -94,7 +94,20 @@ public class runme
|
|||
Structure.StaticMemberString2 = s;
|
||||
if (Structure.StaticMemberString2 != s)
|
||||
throw new Exception("StaticMemberString2 test 2");
|
||||
if (Structure.ConstStaticMemberString != "const static member string")
|
||||
throw new Exception("ConstStaticMemberString test");
|
||||
if (Structure.ConstStaticMemberString != "const static member string")
|
||||
throw new Exception("ConstStaticMemberString test");
|
||||
|
||||
if (li_std_string.stdstring_empty() != "")
|
||||
throw new Exception("stdstring_empty test");
|
||||
if (li_std_string.c_empty() != "")
|
||||
throw new Exception("c_empty test");
|
||||
if (li_std_string.c_null() != null)
|
||||
throw new Exception("c_null test");
|
||||
if (li_std_string.get_null(li_std_string.c_null()) != null)
|
||||
throw new Exception("get_null c_null test");
|
||||
if (li_std_string.get_null(li_std_string.c_empty()) != "non-null")
|
||||
throw new Exception("get_null c_empty test");
|
||||
if (li_std_string.get_null(li_std_string.stdstring_empty()) != "non-null")
|
||||
throw new Exception("get_null stdstring_empty test");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,6 +72,13 @@ void main() {
|
|||
Structure.StaticMemberString2 = s;
|
||||
enforce(Structure.StaticMemberString2 == s, "StaticMemberString2 test 2");
|
||||
enforce(Structure.ConstStaticMemberString == "const static member string", "ConstStaticMemberString test");
|
||||
|
||||
enforce(stdstring_empty() == "", "stdstring_empty test");
|
||||
enforce(c_empty() == "", "c_empty test");
|
||||
enforce(c_null() == null, "c_null test");
|
||||
enforce(get_null(c_null()) == null, "get_null c_null test");
|
||||
enforce(get_null(c_empty()) == null, "get_null c_empty test");
|
||||
enforce(get_null(stdstring_empty()) == null, "get_null stdstring_empty test");
|
||||
}
|
||||
|
||||
private void enforceThrows(void delegate() dg, string errorMessage) {
|
||||
|
|
|
@ -104,5 +104,18 @@ public class li_std_string_runme {
|
|||
throw new Exception("StaticMemberString2 test 2");
|
||||
if (!Structure.getConstStaticMemberString().equals("const static member string"))
|
||||
throw new Exception("ConstStaticMemberString test");
|
||||
|
||||
if (!li_std_string.stdstring_empty().equals(""))
|
||||
throw new Exception("stdstring_empty test");
|
||||
if (!li_std_string.c_empty().equals(""))
|
||||
throw new Exception("c_empty test");
|
||||
if (li_std_string.c_null() != null)
|
||||
throw new Exception("c_null test");
|
||||
if (li_std_string.get_null(li_std_string.c_null()) != null)
|
||||
throw new Exception("get_null c_null test");
|
||||
if (!li_std_string.get_null(li_std_string.c_empty()).equals("non-null"))
|
||||
throw new Exception("get_null c_empty test");
|
||||
if (!li_std_string.get_null(li_std_string.stdstring_empty()).equals("non-null"))
|
||||
throw new Exception("get_null stdstring_empty test");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,3 +119,11 @@ assert(pcall(function () li_std_string.Structure_ConstStaticMemberString='f' end
|
|||
assert(type(li_std_string.Structure_StaticMemberString)=="string")
|
||||
assert(type(li_std_string.Structure_StaticMemberString2)=="string")
|
||||
assert(type(li_std_string.Structure_ConstStaticMemberString)=="string")
|
||||
|
||||
|
||||
assert(stdstring_empty()=="")
|
||||
assert(c_empty()=="")
|
||||
assert(c_null()==nil)
|
||||
assert(get_null(c_null())==nil)
|
||||
assert(get_null(c_empty())=="non-null")
|
||||
assert(get_null(stdstring_empty())=="non-null")
|
||||
|
|
|
@ -41,4 +41,13 @@ let _ =
|
|||
ignore (_Structure_StaticMemberString2 '(s));
|
||||
assert (_Structure_StaticMemberString2 '() = s);
|
||||
assert (_Structure_ConstStaticMemberString '() as string = "const static member string")
|
||||
|
||||
assert (_stdstring_empty '() as string = "")
|
||||
assert (_c_empty '() as string = "")
|
||||
(* FIXME: Can't work out what C++ NULL maps to here...
|
||||
assert (_c_null '() = None)
|
||||
assert (_get_null (_c_null '()) = None)
|
||||
*)
|
||||
assert (_get_null (_c_empty '()) as string = "non-null")
|
||||
assert (_get_null (_stdstring_empty '()) as string = "non-null")
|
||||
;;
|
||||
|
|
|
@ -101,14 +101,14 @@ is($gen1->testl("9234567890121111113"), "9234567890121111114", "ulonglong big nu
|
|||
|
||||
is(li_std_string::stdstring_empty(), "", "stdstring_empty");
|
||||
|
||||
is(li_std_string::c_empty(), "", "c_empty");
|
||||
is(li_std_string::c_empty(), "", "c_empty");
|
||||
|
||||
|
||||
is(li_std_string::c_null(), undef, "c_empty");
|
||||
is(li_std_string::c_null(), undef, "c_null");
|
||||
|
||||
|
||||
is(li_std_string::get_null(li_std_string::c_null()), undef, "c_empty");
|
||||
is(li_std_string::get_null(li_std_string::c_null()), undef, "get_null c_null");
|
||||
|
||||
is(li_std_string::get_null(li_std_string::c_empty()), "non-null", "c_empty");
|
||||
is(li_std_string::get_null(li_std_string::c_empty()), "non-null", "get_null c_empty");
|
||||
|
||||
is(li_std_string::get_null(li_std_string::stdstring_empty()), "non-null", "stdstring_empty");
|
||||
is(li_std_string::get_null(li_std_string::stdstring_empty()), "non-null", "get_null stdstring_empty");
|
||||
|
|
|
@ -93,6 +93,13 @@ try {
|
|||
check::equal($s->getMessage(), "foo");
|
||||
}
|
||||
|
||||
check::equal(li_std_string::stdstring_empty(), "", "stdstring_empty test");
|
||||
check::equal(li_std_string::c_empty(), "", "c_empty test");
|
||||
check::isnull(li_std_string::c_null(), "c_null test");
|
||||
check::isnull(li_std_string::get_null(li_std_string::c_null()), "get_null c_null test");
|
||||
check::equal(li_std_string::get_null(li_std_string::c_empty()), "non-null", "get_null c_empty test");
|
||||
check::equal(li_std_string::get_null(li_std_string::stdstring_empty()), "non-null", "get_null stdstring_empty test");
|
||||
|
||||
// This used to give "Undefined variable: r"
|
||||
li_std_string::test_const_reference_returning_void("foo");
|
||||
|
||||
|
|
|
@ -131,17 +131,25 @@ if (stdstring_empty() != "")
|
|||
raise RuntimeError
|
||||
end
|
||||
|
||||
if (c_empty() != "")
|
||||
if (c_empty() != "")
|
||||
raise RuntimeError
|
||||
end
|
||||
|
||||
|
||||
if (c_null() != nil)
|
||||
if (c_null() != nil)
|
||||
raise RuntimeError
|
||||
end
|
||||
|
||||
|
||||
if (get_null(c_null()) != nil)
|
||||
if (get_null(c_null()) != nil)
|
||||
raise RuntimeError
|
||||
end
|
||||
|
||||
|
||||
if (get_null(c_empty()) != "non-null")
|
||||
raise RuntimeError
|
||||
end
|
||||
|
||||
if (get_null(stdstring_empty()) != "non-null")
|
||||
raise RuntimeError
|
||||
end
|
||||
|
|
|
@ -45,4 +45,20 @@
|
|||
(if (not (string=? (Structure-ConstStaticMemberString) "const static member string"))
|
||||
(error "Error 10"))
|
||||
|
||||
(if (not (string=? (stdstring-empty) ""))
|
||||
(error "stdstring-empty test"))
|
||||
(if (not (string=? (c-empty) ""))
|
||||
(error "c-empty test"))
|
||||
; C++ NULL is mapped to #f (false) here rather than null. I don't know guile
|
||||
; enough to know if that makes sense or not.
|
||||
(if (c-null)
|
||||
(error "c-null test"))
|
||||
; FIXME: However, #f doesn't round-trip, so something seems wrong.
|
||||
; (if (get-null (c-null))
|
||||
; (error "get-null c-empty test"))
|
||||
(if (not (string=? (get-null (c-empty)) "non-null"))
|
||||
(error "get-null c-empty test"))
|
||||
(if (not (string=? (get-null (stdstring-empty)) "non-null"))
|
||||
(error "get-null stdstring-empty test"))
|
||||
|
||||
(exit 0)
|
||||
|
|
|
@ -19,3 +19,14 @@ if {"$GlobalString2" != "hello"} { error "bad string map"}
|
|||
|
||||
set Structure_StaticMemberString2 "hello"
|
||||
if {"$Structure_StaticMemberString2" != "hello"} { error "bad string map"}
|
||||
|
||||
if {[stdstring_empty] != ""} { error "bad stdstring_empty test" }
|
||||
if {[c_empty] != ""} { error "bad c_empty test" }
|
||||
# FIXME: [c_null] seems to give an empty string currently, but Tcl doesn't have
|
||||
# a real NULL value and the string "NULL" we used for elsewhere for NULL
|
||||
# pointers doesn't work well here as it's indistinguishable from the string
|
||||
# "NULL" being returned.
|
||||
#if {[c_null] != "NULL"} { error "bad c_null test" }
|
||||
#if {[get_null [c_null]] != "NULL"} { error "bad get_null c_null test" }
|
||||
if {[get_null [c_empty]] != "non-null"} { error "bad get_null c_empty test" }
|
||||
if {[get_null [stdstring_empty]] != "non-null"} { error "bad get_null stdstring_empty test" }
|
||||
|
|
Loading…
Reference in New Issue