Expand std::string_view test coverage

Fill in cases which weren't being tested for some target languages.
This commit is contained in:
Olly Betts 2023-05-26 16:19:05 +12:00
parent 376198531b
commit 427d41b547
5 changed files with 51 additions and 0 deletions

View File

@ -80,5 +80,18 @@ public class runme
if (Structure.ConstStaticMemberString != "const static member string")
throw new Exception("ConstStaticMemberString test");
if (cpp17_string_view.stdstringview_empty() != "")
throw new Exception("stdstringview_empty test");
if (cpp17_string_view.c_empty() != "")
throw new Exception("c_empty test");
if (cpp17_string_view.c_null() != null)
throw new Exception("c_null test");
if (cpp17_string_view.get_null(cpp17_string_view.c_null()) != null)
throw new Exception("get_null c_null test");
if (cpp17_string_view.get_null(cpp17_string_view.c_empty()) != "non-null")
throw new Exception("get_null c_empty test");
if (cpp17_string_view.get_null(cpp17_string_view.stdstringview_empty()) != "non-null")
throw new Exception("get_null stdstringview_empty test");
}
}

View File

@ -88,5 +88,18 @@ public class cpp17_string_view_runme {
if (!Structure.getConstStaticMemberString().equals("const static member string"))
throw new Exception("ConstStaticMemberString test");
if (!cpp17_string_view.stdstringview_empty().equals(""))
throw new Exception("stdstringview_empty test");
if (!cpp17_string_view.c_empty().equals(""))
throw new Exception("c_empty test");
if (cpp17_string_view.c_null() != null)
throw new Exception("c_null test");
if (cpp17_string_view.get_null(cpp17_string_view.c_null()) != null)
throw new Exception("get_null c_null test");
if (!cpp17_string_view.get_null(cpp17_string_view.c_empty()).equals("non-null"))
throw new Exception("get_null c_empty test");
if (!cpp17_string_view.get_null(cpp17_string_view.stdstringview_empty()).equals("non-null"))
throw new Exception("get_null stdstringview_empty test");
}
}

View File

@ -48,3 +48,10 @@ assert(myStructure.ConstMemberString=="const member string")
assert(Structure.ConstStaticMemberString=="const static member string")
test_const_reference_returning_void("foo")
assert(stdstringview_empty()=="")
assert(c_empty()=="")
assert(c_null()==nil)
assert(get_null(c_null())==nil)
assert(get_null(c_empty())=="non-null")
assert(get_null(stdstringview_empty())=="non-null")

View File

@ -41,4 +41,11 @@ check::equal(Structure::ConstStaticMemberString(), "const static member string",
cpp17_string_view::test_const_reference_returning_void("foo");
check::equal(cpp17_string_view::stdstringview_empty(), "", "stdstringview_empty test");
check::equal(cpp17_string_view::c_empty(), "", "c_empty test");
check::isnull(cpp17_string_view::c_null(), "c_null test");
check::isnull(cpp17_string_view::get_null(cpp17_string_view::c_null()), "get_null c_null test");
check::equal(cpp17_string_view::get_null(cpp17_string_view::c_empty()), "non-null", "get_null c_empty test");
check::equal(cpp17_string_view::get_null(cpp17_string_view::stdstringview_empty()), "non-null", "get_null stdstringview_empty test");
check::done();

View File

@ -33,3 +33,14 @@ if {[s cget -ConstMemberString] != "const member string"} { error "bad ConstMemb
if {$Structure_ConstStaticMemberString != "const static member string"} { error "bad ConstStaticMemberString"}
test_const_reference_returning_void "foo"
if {[stdstringview_empty] != ""} { error "bad stdstringview_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 [stdstringview_empty]] != "non-null"} { error "bad get_null stdstringview_empty test" }