From 74ccef87d145f1e35050a00c6b1b8fc81f3590c8 Mon Sep 17 00:00:00 2001 From: Baptiste Wicht Date: Thu, 5 Apr 2018 14:10:04 +0200 Subject: [PATCH] New std::string test --- tstl/test_suite/strings.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tstl/test_suite/strings.cpp b/tstl/test_suite/strings.cpp index 28abeb45..618fe520 100644 --- a/tstl/test_suite/strings.cpp +++ b/tstl/test_suite/strings.cpp @@ -440,6 +440,25 @@ void test_compare(){ CHECK(e.compare(e) == 0, "Invalid std::string::compare"); } +void test_assign_sv(){ + std::string a = "bcd"; + std::string b = "abcde"; + std::string_view sb = b; + std::string c = "def"; + + a = sb; + + CHECK(!a.empty(), "String mustn't be empty"); + CHECK(a.size() == 5, "Invalid size"); + CHECK(strcmp(a.c_str(), "abcde") == 0, "Invalid content"); + + a = static_cast(c); + + CHECK(!a.empty(), "String mustn't be empty"); + CHECK(a.size() == 3, "Invalid size"); + CHECK(strcmp(a.c_str(), "def") == 0, "Invalid content"); +} + } //end of anonymous namespace void string_tests(){ @@ -457,4 +476,5 @@ void string_tests(){ test_operators_short_to_long(); test_operators_long_to_short(); test_compare(); + test_assign_sv(); }