From f32e0b93c06fa28fe03976ecc8bdca66f3cbc454 Mon Sep 17 00:00:00 2001 From: Baptiste Wicht Date: Thu, 5 Apr 2018 12:12:37 +0200 Subject: [PATCH] Tests for mixed comparison --- tstl/test_suite/string_view.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tstl/test_suite/string_view.cpp b/tstl/test_suite/string_view.cpp index 28d5dbe4..b1155d89 100644 --- a/tstl/test_suite/string_view.cpp +++ b/tstl/test_suite/string_view.cpp @@ -117,6 +117,36 @@ void test_compare(){ CHECK(e.compare(e) == 0, "Invalid std::string_view::compare"); } +void test_mixed_compare(){ + std::string sa = "bcd"; + std::string sb = "bcde"; + std::string sc = "abcd"; + std::string sd = "abcde"; + std::string se = "bcd"; + + std::string_view a = sa; + std::string_view b = sb; + std::string_view c = sc; + std::string_view d = sd; + std::string_view e = se; + + CHECK(a == sa, "Invalid operator=="); + CHECK(a == se, "Invalid operator=="); + CHECK(e == sa, "Invalid operator=="); + + CHECK(sa == a, "Invalid operator=="); + CHECK(sa == e, "Invalid operator=="); + CHECK(se == a, "Invalid operator=="); + + CHECK(a != sb, "Invalid operator!="); + CHECK(a != sc, "Invalid operator!="); + CHECK(a != sd, "Invalid operator!="); + + CHECK(sa != b, "Invalid operator!="); + CHECK(sa != c, "Invalid operator!="); + CHECK(sa != d, "Invalid operator!="); +} + } //end of anonymous namespace void string_view_tests(){ @@ -124,4 +154,5 @@ void string_view_tests(){ test_suffix(); test_empty(); test_compare(); + test_mixed_compare(); }