From 53a420fba21cf1644972b34dcd811a43cdb8368d Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 2 Jan 2017 19:18:58 +0000 Subject: Vendor import of libc++ trunk r290819: https://llvm.org/svn/llvm-project/libcxx/trunk@290819 --- .../string_oplt=/string_string_view.pass.cpp | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string_view.pass.cpp (limited to 'test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string_view.pass.cpp') diff --git a/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string_view.pass.cpp b/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string_view.pass.cpp new file mode 100644 index 000000000000..97a9d7cc7175 --- /dev/null +++ b/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string_view.pass.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// we get this comparison "for free" because the string implicitly converts to the string_view + +#include +#include + +#include "min_allocator.h" + +template +void +test(const S& lhs, SV rhs, bool x) +{ + assert((lhs <= rhs) == x); +} + +int main() +{ + { + typedef std::string S; + typedef std::string_view SV; + test(S(""), SV(""), true); + test(S(""), SV("abcde"), true); + test(S(""), SV("abcdefghij"), true); + test(S(""), SV("abcdefghijklmnopqrst"), true); + test(S("abcde"), SV(""), false); + test(S("abcde"), SV("abcde"), true); + test(S("abcde"), SV("abcdefghij"), true); + test(S("abcde"), SV("abcdefghijklmnopqrst"), true); + test(S("abcdefghij"), SV(""), false); + test(S("abcdefghij"), SV("abcde"), false); + test(S("abcdefghij"), SV("abcdefghij"), true); + test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), true); + test(S("abcdefghijklmnopqrst"), SV(""), false); + test(S("abcdefghijklmnopqrst"), SV("abcde"), false); + test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), false); + test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), true); + } +#if TEST_STD_VER >= 11 + { + typedef std::basic_string, min_allocator> S; + typedef std::basic_string_view> SV; + test(S(""), SV(""), true); + test(S(""), SV("abcde"), true); + test(S(""), SV("abcdefghij"), true); + test(S(""), SV("abcdefghijklmnopqrst"), true); + test(S("abcde"), SV(""), false); + test(S("abcde"), SV("abcde"), true); + test(S("abcde"), SV("abcdefghij"), true); + test(S("abcde"), SV("abcdefghijklmnopqrst"), true); + test(S("abcdefghij"), SV(""), false); + test(S("abcdefghij"), SV("abcde"), false); + test(S("abcdefghij"), SV("abcdefghij"), true); + test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), true); + test(S("abcdefghijklmnopqrst"), SV(""), false); + test(S("abcdefghijklmnopqrst"), SV("abcde"), false); + test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), false); + test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), true); + } +#endif +} -- cgit v1.3