forked from OSchip/llvm-project
[libc++] [test] Refactor string_view comparison tests for comprehensiveness.
Differential Revision: https://reviews.llvm.org/D114658
This commit is contained in:
parent
b4a13e4c98
commit
0efd9a03fa
|
@ -0,0 +1,116 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits>
|
||||
// constexpr bool operator==(basic_string_view<charT, traits> lhs, basic_string_view<charT, traits> rhs);
|
||||
// (plus "sufficient additional overloads" to make implicit conversions work as intended)
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "constexpr_char_traits.h"
|
||||
#include "make_string.h"
|
||||
|
||||
template<class T>
|
||||
struct ConvertibleTo {
|
||||
T t_;
|
||||
TEST_CONSTEXPR explicit ConvertibleTo(T t) : t_(t) {}
|
||||
TEST_CONSTEXPR operator T() const {
|
||||
return t_;
|
||||
}
|
||||
};
|
||||
|
||||
template<class SV>
|
||||
TEST_CONSTEXPR_CXX14 bool test()
|
||||
{
|
||||
typedef typename SV::value_type CharT;
|
||||
typedef typename SV::traits_type Traits;
|
||||
|
||||
// Test the behavior of the operator, both with and without implicit conversions.
|
||||
SV v[] = {
|
||||
SV(MAKE_CSTRING(CharT, "")),
|
||||
SV(MAKE_CSTRING(CharT, "abc")),
|
||||
SV(MAKE_CSTRING(CharT, "abcdef")),
|
||||
SV(MAKE_CSTRING(CharT, "acb")),
|
||||
};
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
// See http://eel.is/c++draft/string.view#tab:string.view.comparison.overloads
|
||||
bool expected = (i == j);
|
||||
assert((v[i] == v[j]) == expected);
|
||||
assert((v[i].data() == v[j]) == expected);
|
||||
assert((v[i] == v[j].data()) == expected);
|
||||
assert((ConvertibleTo<SV>(v[i]) == v[j]) == expected);
|
||||
assert((v[i] == ConvertibleTo<SV>(v[j])) == expected);
|
||||
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
// TODO FIXME: once P0980 "Making std::string constexpr" is implemented
|
||||
assert((std::basic_string<CharT, Traits>(v[i]) == v[j]) == expected);
|
||||
assert((v[i] == std::basic_string<CharT, Traits>(v[j])) == expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test its behavior with embedded null bytes.
|
||||
SV abc = SV(MAKE_CSTRING(CharT, "abc"));
|
||||
SV abc0def = SV(MAKE_CSTRING(CharT, "abc\0def"), 7);
|
||||
SV abcdef = SV(MAKE_CSTRING(CharT, "abcdef"));
|
||||
assert((abc == abc0def) == false);
|
||||
assert((abc == abcdef) == false);
|
||||
assert((abc0def == abc) == false);
|
||||
assert((abc0def == abcdef) == false);
|
||||
assert((abcdef == abc) == false);
|
||||
assert((abcdef == abc0def) == false);
|
||||
|
||||
assert((abc.data() == abc0def) == false);
|
||||
assert((abc0def == abc.data()) == false);
|
||||
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
// TODO FIXME: once P0980 "Making std::string constexpr" is implemented
|
||||
assert((std::basic_string<CharT, Traits>(abc) == abc0def) == false);
|
||||
assert((abc0def == std::basic_string<CharT, Traits>(abc)) == false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test<std::string_view>();
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
test<std::wstring_view>();
|
||||
#endif
|
||||
#if TEST_STD_VER >= 11
|
||||
test<std::u16string_view>();
|
||||
test<std::u32string_view>();
|
||||
#endif
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(test<std::string_view>(), "");
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
static_assert(test<std::wstring_view>(), "");
|
||||
#endif
|
||||
static_assert(test<std::u16string_view>(), "");
|
||||
static_assert(test<std::u32string_view>(), "");
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
test<std::basic_string_view<char, constexpr_char_traits<char>>>();
|
||||
static_assert(test<std::basic_string_view<char, constexpr_char_traits<char>>>(), "");
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER > 17
|
||||
test<std::u8string_view>();
|
||||
static_assert(test<std::u8string_view>());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits>
|
||||
// constexpr bool operator>(basic_string_view<charT, traits> lhs, basic_string_view<charT, traits> rhs);
|
||||
// (plus "sufficient additional overloads" to make implicit conversions work as intended)
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "constexpr_char_traits.h"
|
||||
#include "make_string.h"
|
||||
|
||||
template<class T>
|
||||
struct ConvertibleTo {
|
||||
T t_;
|
||||
TEST_CONSTEXPR explicit ConvertibleTo(T t) : t_(t) {}
|
||||
TEST_CONSTEXPR operator T() const {
|
||||
return t_;
|
||||
}
|
||||
};
|
||||
|
||||
template<class SV>
|
||||
TEST_CONSTEXPR_CXX14 bool test()
|
||||
{
|
||||
typedef typename SV::value_type CharT;
|
||||
typedef typename SV::traits_type Traits;
|
||||
|
||||
// Test the behavior of the operator, both with and without implicit conversions.
|
||||
SV v[] = {
|
||||
SV(MAKE_CSTRING(CharT, "")),
|
||||
SV(MAKE_CSTRING(CharT, "abc")),
|
||||
SV(MAKE_CSTRING(CharT, "abcdef")),
|
||||
SV(MAKE_CSTRING(CharT, "acb")),
|
||||
};
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
// See http://eel.is/c++draft/string.view#tab:string.view.comparison.overloads
|
||||
bool expected = (i > j);
|
||||
assert((v[i] > v[j]) == expected);
|
||||
assert((v[i].data() > v[j]) == expected);
|
||||
assert((v[i] > v[j].data()) == expected);
|
||||
assert((ConvertibleTo<SV>(v[i]) > v[j]) == expected);
|
||||
assert((v[i] > ConvertibleTo<SV>(v[j])) == expected);
|
||||
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
// TODO FIXME: once P0980 "Making std::string constexpr" is implemented
|
||||
assert((std::basic_string<CharT, Traits>(v[i]) > v[j]) == expected);
|
||||
assert((v[i] > std::basic_string<CharT, Traits>(v[j])) == expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test its behavior with embedded null bytes.
|
||||
SV abc = SV(MAKE_CSTRING(CharT, "abc"));
|
||||
SV abc0def = SV(MAKE_CSTRING(CharT, "abc\0def"), 7);
|
||||
SV abcdef = SV(MAKE_CSTRING(CharT, "abcdef"));
|
||||
assert((abc > abc0def) == false);
|
||||
assert((abc > abcdef) == false);
|
||||
assert((abc0def > abc) == true);
|
||||
assert((abc0def > abcdef) == false);
|
||||
assert((abcdef > abc) == true);
|
||||
assert((abcdef > abc0def) == true);
|
||||
|
||||
assert((abc.data() > abc0def) == false);
|
||||
assert((abc0def > abc.data()) == true);
|
||||
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
// TODO FIXME: once P0980 "Making std::string constexpr" is implemented
|
||||
assert((std::basic_string<CharT, Traits>(abc) > abc0def) == false);
|
||||
assert((abc0def > std::basic_string<CharT, Traits>(abc)) == true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test<std::string_view>();
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
test<std::wstring_view>();
|
||||
#endif
|
||||
#if TEST_STD_VER >= 11
|
||||
test<std::u16string_view>();
|
||||
test<std::u32string_view>();
|
||||
#endif
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(test<std::string_view>(), "");
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
static_assert(test<std::wstring_view>(), "");
|
||||
#endif
|
||||
static_assert(test<std::u16string_view>(), "");
|
||||
static_assert(test<std::u32string_view>(), "");
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
test<std::basic_string_view<char, constexpr_char_traits<char>>>();
|
||||
static_assert(test<std::basic_string_view<char, constexpr_char_traits<char>>>(), "");
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER > 17
|
||||
test<std::u8string_view>();
|
||||
static_assert(test<std::u8string_view>());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits>
|
||||
// constexpr bool operator>=(basic_string_view<charT, traits> lhs, basic_string_view<charT, traits> rhs);
|
||||
// (plus "sufficient additional overloads" to make implicit conversions work as intended)
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "constexpr_char_traits.h"
|
||||
#include "make_string.h"
|
||||
|
||||
template<class T>
|
||||
struct ConvertibleTo {
|
||||
T t_;
|
||||
TEST_CONSTEXPR explicit ConvertibleTo(T t) : t_(t) {}
|
||||
TEST_CONSTEXPR operator T() const {
|
||||
return t_;
|
||||
}
|
||||
};
|
||||
|
||||
template<class SV>
|
||||
TEST_CONSTEXPR_CXX14 bool test()
|
||||
{
|
||||
typedef typename SV::value_type CharT;
|
||||
typedef typename SV::traits_type Traits;
|
||||
|
||||
// Test the behavior of the operator, both with and without implicit conversions.
|
||||
SV v[] = {
|
||||
SV(MAKE_CSTRING(CharT, "")),
|
||||
SV(MAKE_CSTRING(CharT, "abc")),
|
||||
SV(MAKE_CSTRING(CharT, "abcdef")),
|
||||
SV(MAKE_CSTRING(CharT, "acb")),
|
||||
};
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
// See http://eel.is/c++draft/string.view#tab:string.view.comparison.overloads
|
||||
bool expected = (i >= j);
|
||||
assert((v[i] >= v[j]) == expected);
|
||||
assert((v[i].data() >= v[j]) == expected);
|
||||
assert((v[i] >= v[j].data()) == expected);
|
||||
assert((ConvertibleTo<SV>(v[i]) >= v[j]) == expected);
|
||||
assert((v[i] >= ConvertibleTo<SV>(v[j])) == expected);
|
||||
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
// TODO FIXME: once P0980 "Making std::string constexpr" is implemented
|
||||
assert((std::basic_string<CharT, Traits>(v[i]) >= v[j]) == expected);
|
||||
assert((v[i] >= std::basic_string<CharT, Traits>(v[j])) == expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test its behavior with embedded null bytes.
|
||||
SV abc = SV(MAKE_CSTRING(CharT, "abc"));
|
||||
SV abc0def = SV(MAKE_CSTRING(CharT, "abc\0def"), 7);
|
||||
SV abcdef = SV(MAKE_CSTRING(CharT, "abcdef"));
|
||||
assert((abc >= abc0def) == false);
|
||||
assert((abc >= abcdef) == false);
|
||||
assert((abc0def >= abc) == true);
|
||||
assert((abc0def >= abcdef) == false);
|
||||
assert((abcdef >= abc) == true);
|
||||
assert((abcdef >= abc0def) == true);
|
||||
|
||||
assert((abc.data() >= abc0def) == false);
|
||||
assert((abc0def >= abc.data()) == true);
|
||||
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
// TODO FIXME: once P0980 "Making std::string constexpr" is implemented
|
||||
assert((std::basic_string<CharT, Traits>(abc) >= abc0def) == false);
|
||||
assert((abc0def >= std::basic_string<CharT, Traits>(abc)) == true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test<std::string_view>();
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
test<std::wstring_view>();
|
||||
#endif
|
||||
#if TEST_STD_VER >= 11
|
||||
test<std::u16string_view>();
|
||||
test<std::u32string_view>();
|
||||
#endif
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(test<std::string_view>(), "");
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
static_assert(test<std::wstring_view>(), "");
|
||||
#endif
|
||||
static_assert(test<std::u16string_view>(), "");
|
||||
static_assert(test<std::u32string_view>(), "");
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
test<std::basic_string_view<char, constexpr_char_traits<char>>>();
|
||||
static_assert(test<std::basic_string_view<char, constexpr_char_traits<char>>>(), "");
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER > 17
|
||||
test<std::u8string_view>();
|
||||
static_assert(test<std::u8string_view>());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits>
|
||||
// constexpr bool operator<(basic_string_view<charT, traits> lhs, basic_string_view<charT, traits> rhs);
|
||||
// (plus "sufficient additional overloads" to make implicit conversions work as intended)
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "constexpr_char_traits.h"
|
||||
#include "make_string.h"
|
||||
|
||||
template<class T>
|
||||
struct ConvertibleTo {
|
||||
T t_;
|
||||
TEST_CONSTEXPR explicit ConvertibleTo(T t) : t_(t) {}
|
||||
TEST_CONSTEXPR operator T() const {
|
||||
return t_;
|
||||
}
|
||||
};
|
||||
|
||||
template<class SV>
|
||||
TEST_CONSTEXPR_CXX14 bool test()
|
||||
{
|
||||
typedef typename SV::value_type CharT;
|
||||
typedef typename SV::traits_type Traits;
|
||||
|
||||
// Test the behavior of the operator, both with and without implicit conversions.
|
||||
SV v[] = {
|
||||
SV(MAKE_CSTRING(CharT, "")),
|
||||
SV(MAKE_CSTRING(CharT, "abc")),
|
||||
SV(MAKE_CSTRING(CharT, "abcdef")),
|
||||
SV(MAKE_CSTRING(CharT, "acb")),
|
||||
};
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
// See http://eel.is/c++draft/string.view#tab:string.view.comparison.overloads
|
||||
bool expected = (i < j);
|
||||
assert((v[i] < v[j]) == expected);
|
||||
assert((v[i].data() < v[j]) == expected);
|
||||
assert((v[i] < v[j].data()) == expected);
|
||||
assert((ConvertibleTo<SV>(v[i]) < v[j]) == expected);
|
||||
assert((v[i] < ConvertibleTo<SV>(v[j])) == expected);
|
||||
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
// TODO FIXME: once P0980 "Making std::string constexpr" is implemented
|
||||
assert((std::basic_string<CharT, Traits>(v[i]) < v[j]) == expected);
|
||||
assert((v[i] < std::basic_string<CharT, Traits>(v[j])) == expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test its behavior with embedded null bytes.
|
||||
SV abc = SV(MAKE_CSTRING(CharT, "abc"));
|
||||
SV abc0def = SV(MAKE_CSTRING(CharT, "abc\0def"), 7);
|
||||
SV abcdef = SV(MAKE_CSTRING(CharT, "abcdef"));
|
||||
assert((abc < abc0def) == true);
|
||||
assert((abc < abcdef) == true);
|
||||
assert((abc0def < abc) == false);
|
||||
assert((abc0def < abcdef) == true);
|
||||
assert((abcdef < abc) == false);
|
||||
assert((abcdef < abc0def) == false);
|
||||
|
||||
assert((abc.data() < abc0def) == true);
|
||||
assert((abc0def < abc.data()) == false);
|
||||
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
// TODO FIXME: once P0980 "Making std::string constexpr" is implemented
|
||||
assert((std::basic_string<CharT, Traits>(abc) < abc0def) == true);
|
||||
assert((abc0def < std::basic_string<CharT, Traits>(abc)) == false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test<std::string_view>();
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
test<std::wstring_view>();
|
||||
#endif
|
||||
#if TEST_STD_VER >= 11
|
||||
test<std::u16string_view>();
|
||||
test<std::u32string_view>();
|
||||
#endif
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(test<std::string_view>(), "");
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
static_assert(test<std::wstring_view>(), "");
|
||||
#endif
|
||||
static_assert(test<std::u16string_view>(), "");
|
||||
static_assert(test<std::u32string_view>(), "");
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
test<std::basic_string_view<char, constexpr_char_traits<char>>>();
|
||||
static_assert(test<std::basic_string_view<char, constexpr_char_traits<char>>>(), "");
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER > 17
|
||||
test<std::u8string_view>();
|
||||
static_assert(test<std::u8string_view>());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits>
|
||||
// constexpr bool operator<=(basic_string_view<charT, traits> lhs, basic_string_view<charT, traits> rhs);
|
||||
// (plus "sufficient additional overloads" to make implicit conversions work as intended)
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "constexpr_char_traits.h"
|
||||
#include "make_string.h"
|
||||
|
||||
template<class T>
|
||||
struct ConvertibleTo {
|
||||
T t_;
|
||||
TEST_CONSTEXPR explicit ConvertibleTo(T t) : t_(t) {}
|
||||
TEST_CONSTEXPR operator T() const {
|
||||
return t_;
|
||||
}
|
||||
};
|
||||
|
||||
template<class SV>
|
||||
TEST_CONSTEXPR_CXX14 bool test()
|
||||
{
|
||||
typedef typename SV::value_type CharT;
|
||||
typedef typename SV::traits_type Traits;
|
||||
|
||||
// Test the behavior of the operator, both with and without implicit conversions.
|
||||
SV v[] = {
|
||||
SV(MAKE_CSTRING(CharT, "")),
|
||||
SV(MAKE_CSTRING(CharT, "abc")),
|
||||
SV(MAKE_CSTRING(CharT, "abcdef")),
|
||||
SV(MAKE_CSTRING(CharT, "acb")),
|
||||
};
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
// See http://eel.is/c++draft/string.view#tab:string.view.comparison.overloads
|
||||
bool expected = (i <= j);
|
||||
assert((v[i] <= v[j]) == expected);
|
||||
assert((v[i].data() <= v[j]) == expected);
|
||||
assert((v[i] <= v[j].data()) == expected);
|
||||
assert((ConvertibleTo<SV>(v[i]) <= v[j]) == expected);
|
||||
assert((v[i] <= ConvertibleTo<SV>(v[j])) == expected);
|
||||
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
// TODO FIXME: once P0980 "Making std::string constexpr" is implemented
|
||||
assert((std::basic_string<CharT, Traits>(v[i]) <= v[j]) == expected);
|
||||
assert((v[i] <= std::basic_string<CharT, Traits>(v[j])) == expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test its behavior with embedded null bytes.
|
||||
SV abc = SV(MAKE_CSTRING(CharT, "abc"));
|
||||
SV abc0def = SV(MAKE_CSTRING(CharT, "abc\0def"), 7);
|
||||
SV abcdef = SV(MAKE_CSTRING(CharT, "abcdef"));
|
||||
assert((abc <= abc0def) == true);
|
||||
assert((abc <= abcdef) == true);
|
||||
assert((abc0def <= abc) == false);
|
||||
assert((abc0def <= abcdef) == true);
|
||||
assert((abcdef <= abc) == false);
|
||||
assert((abcdef <= abc0def) == false);
|
||||
|
||||
assert((abc.data() <= abc0def) == true);
|
||||
assert((abc0def <= abc.data()) == false);
|
||||
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
// TODO FIXME: once P0980 "Making std::string constexpr" is implemented
|
||||
assert((std::basic_string<CharT, Traits>(abc) <= abc0def) == true);
|
||||
assert((abc0def <= std::basic_string<CharT, Traits>(abc)) == false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test<std::string_view>();
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
test<std::wstring_view>();
|
||||
#endif
|
||||
#if TEST_STD_VER >= 11
|
||||
test<std::u16string_view>();
|
||||
test<std::u32string_view>();
|
||||
#endif
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(test<std::string_view>(), "");
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
static_assert(test<std::wstring_view>(), "");
|
||||
#endif
|
||||
static_assert(test<std::u16string_view>(), "");
|
||||
static_assert(test<std::u32string_view>(), "");
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
test<std::basic_string_view<char, constexpr_char_traits<char>>>();
|
||||
static_assert(test<std::basic_string_view<char, constexpr_char_traits<char>>>(), "");
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER > 17
|
||||
test<std::u8string_view>();
|
||||
static_assert(test<std::u8string_view>());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits>
|
||||
// constexpr bool operator!=(basic_string_view<charT, traits> lhs, basic_string_view<charT, traits> rhs);
|
||||
// (plus "sufficient additional overloads" to make implicit conversions work as intended)
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "constexpr_char_traits.h"
|
||||
#include "make_string.h"
|
||||
|
||||
template<class T>
|
||||
struct ConvertibleTo {
|
||||
T t_;
|
||||
TEST_CONSTEXPR explicit ConvertibleTo(T t) : t_(t) {}
|
||||
TEST_CONSTEXPR operator T() const {
|
||||
return t_;
|
||||
}
|
||||
};
|
||||
|
||||
template<class SV>
|
||||
TEST_CONSTEXPR_CXX14 bool test()
|
||||
{
|
||||
typedef typename SV::value_type CharT;
|
||||
typedef typename SV::traits_type Traits;
|
||||
|
||||
// Test the behavior of the operator, both with and without implicit conversions.
|
||||
SV v[] = {
|
||||
SV(MAKE_CSTRING(CharT, "")),
|
||||
SV(MAKE_CSTRING(CharT, "abc")),
|
||||
SV(MAKE_CSTRING(CharT, "abcdef")),
|
||||
SV(MAKE_CSTRING(CharT, "acb")),
|
||||
};
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
// See http://eel.is/c++draft/string.view#tab:string.view.comparison.overloads
|
||||
bool expected = (i != j);
|
||||
assert((v[i] != v[j]) == expected);
|
||||
assert((v[i].data() != v[j]) == expected);
|
||||
assert((v[i] != v[j].data()) == expected);
|
||||
assert((ConvertibleTo<SV>(v[i]) != v[j]) == expected);
|
||||
assert((v[i] != ConvertibleTo<SV>(v[j])) == expected);
|
||||
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
// TODO FIXME: once P0980 "Making std::string constexpr" is implemented
|
||||
assert((std::basic_string<CharT, Traits>(v[i]) != v[j]) == expected);
|
||||
assert((v[i] != std::basic_string<CharT, Traits>(v[j])) == expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test its behavior with embedded null bytes.
|
||||
SV abc = SV(MAKE_CSTRING(CharT, "abc"));
|
||||
SV abc0def = SV(MAKE_CSTRING(CharT, "abc\0def"), 7);
|
||||
SV abcdef = SV(MAKE_CSTRING(CharT, "abcdef"));
|
||||
assert((abc != abc0def) == true);
|
||||
assert((abc != abcdef) == true);
|
||||
assert((abc0def != abc) == true);
|
||||
assert((abc0def != abcdef) == true);
|
||||
assert((abcdef != abc) == true);
|
||||
assert((abcdef != abc0def) == true);
|
||||
|
||||
assert((abc.data() != abc0def) == true);
|
||||
assert((abc0def != abc.data()) == true);
|
||||
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
// TODO FIXME: once P0980 "Making std::string constexpr" is implemented
|
||||
assert((std::basic_string<CharT, Traits>(abc) != abc0def) == true);
|
||||
assert((abc0def != std::basic_string<CharT, Traits>(abc)) == true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test<std::string_view>();
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
test<std::wstring_view>();
|
||||
#endif
|
||||
#if TEST_STD_VER >= 11
|
||||
test<std::u16string_view>();
|
||||
test<std::u32string_view>();
|
||||
#endif
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(test<std::string_view>(), "");
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
static_assert(test<std::wstring_view>(), "");
|
||||
#endif
|
||||
static_assert(test<std::u16string_view>(), "");
|
||||
static_assert(test<std::u32string_view>(), "");
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
test<std::basic_string_view<char, constexpr_char_traits<char>>>();
|
||||
static_assert(test<std::basic_string_view<char, constexpr_char_traits<char>>>(), "");
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER > 17
|
||||
test<std::u8string_view>();
|
||||
static_assert(test<std::u8string_view>());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits>
|
||||
// constexpr bool operator==(basic_string_view<charT,traits> lhs, const charT* rhs);
|
||||
// template<class charT, class traits>
|
||||
// constexpr bool operator==(const charT* lhs, basic_string_view<charT,traits> rhs);
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "constexpr_char_traits.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(S lhs, const typename S::value_type* rhs, bool x)
|
||||
{
|
||||
assert((lhs == rhs) == x);
|
||||
assert((rhs == lhs) == x);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef std::string_view S;
|
||||
test(S(""), "", true);
|
||||
test(S(""), "abcde", false);
|
||||
test(S(""), "abcdefghij", false);
|
||||
test(S(""), "abcdefghijklmnopqrst", false);
|
||||
test(S("abcde"), "", false);
|
||||
test(S("abcde"), "abcde", true);
|
||||
test(S("abcde"), "abcdefghij", false);
|
||||
test(S("abcde"), "abcdefghijklmnopqrst", false);
|
||||
test(S("abcdefghij"), "", false);
|
||||
test(S("abcdefghij"), "abcde", false);
|
||||
test(S("abcdefghij"), "abcdefghij", true);
|
||||
test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
|
||||
test(S("abcdefghijklmnopqrst"), "", false);
|
||||
test(S("abcdefghijklmnopqrst"), "abcde", false);
|
||||
test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
|
||||
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
|
||||
}
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
{
|
||||
typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
|
||||
constexpr SV sv1;
|
||||
constexpr SV sv2 { "abcde", 5 };
|
||||
static_assert ( sv1 == "", "" );
|
||||
static_assert ( "" == sv1, "" );
|
||||
static_assert (!(sv1 == "abcde"), "" );
|
||||
static_assert (!("abcde" == sv1), "" );
|
||||
|
||||
static_assert ( sv2 == "abcde", "" );
|
||||
static_assert ( "abcde" == sv2, "" );
|
||||
static_assert (!(sv2 == "abcde0"), "" );
|
||||
static_assert (!("abcde0" == sv2), "" );
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits, class Allocator>
|
||||
// bool operator==(const charT* lhs, const basic_string<charT,traits> rhs);
|
||||
// template<class charT, class traits, class Allocator>
|
||||
// bool operator==(const basic_string_view<charT,traits> lhs, const CharT* rhs);
|
||||
|
||||
#include <string_view>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const std::string &lhs, S rhs, bool x)
|
||||
{
|
||||
assert((lhs == rhs) == x);
|
||||
assert((rhs == lhs) == x);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef std::string_view S;
|
||||
test("", S(""), true);
|
||||
test("", S("abcde"), false);
|
||||
test("", S("abcdefghij"), false);
|
||||
test("", S("abcdefghijklmnopqrst"), false);
|
||||
test("abcde", S(""), false);
|
||||
test("abcde", S("abcde"), true);
|
||||
test("abcde", S("abcdefghij"), false);
|
||||
test("abcde", S("abcdefghijklmnopqrst"), false);
|
||||
test("abcdefghij", S(""), false);
|
||||
test("abcdefghij", S("abcde"), false);
|
||||
test("abcdefghij", S("abcdefghij"), true);
|
||||
test("abcdefghij", S("abcdefghijklmnopqrst"), false);
|
||||
test("abcdefghijklmnopqrst", S(""), false);
|
||||
test("abcdefghijklmnopqrst", S("abcde"), false);
|
||||
test("abcdefghijklmnopqrst", S("abcdefghij"), false);
|
||||
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits, class Allocator>
|
||||
// constexpr bool operator==(const basic_string_view<charT,traits> lhs,
|
||||
// const basic_string_view<charT,traits> rhs);
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "constexpr_char_traits.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(S lhs, S rhs, bool x)
|
||||
{
|
||||
assert((lhs == rhs) == x);
|
||||
assert((rhs == lhs) == x);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef std::string_view S;
|
||||
test(S(""), S(""), true);
|
||||
test(S(""), S("abcde"), false);
|
||||
test(S(""), S("abcdefghij"), false);
|
||||
test(S(""), S("abcdefghijklmnopqrst"), false);
|
||||
test(S("abcde"), S(""), false);
|
||||
test(S("abcde"), S("abcde"), true);
|
||||
test(S("abcde"), S("abcdefghij"), false);
|
||||
test(S("abcde"), S("abcdefghijklmnopqrst"), false);
|
||||
test(S("abcdefghij"), S(""), false);
|
||||
test(S("abcdefghij"), S("abcde"), false);
|
||||
test(S("abcdefghij"), S("abcdefghij"), true);
|
||||
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
|
||||
test(S("abcdefghijklmnopqrst"), S(""), false);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcde"), false);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
|
||||
}
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
{
|
||||
typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
|
||||
constexpr SV sv1;
|
||||
constexpr SV sv2;
|
||||
constexpr SV sv3 { "abcde", 5 };
|
||||
static_assert ( sv1 == sv2, "" );
|
||||
static_assert (!(sv1 == sv3), "" );
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits, class Allocator>
|
||||
// constexpr bool operator>=(const charT* lhs, basic_string_view<charT,traits> rhs);
|
||||
// template<class charT, class traits, class Allocator>
|
||||
// constexpr bool operator>=(basic_string_view<charT,traits> lhs, const charT* rhs);
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "constexpr_char_traits.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const typename S::value_type* lhs, const S& rhs, bool x, bool y)
|
||||
{
|
||||
assert((lhs >= rhs) == x);
|
||||
assert((rhs >= lhs) == y);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef std::string_view S;
|
||||
test("", S(""), true, true);
|
||||
test("", S("abcde"), false, true);
|
||||
test("", S("abcdefghij"), false, true);
|
||||
test("", S("abcdefghijklmnopqrst"), false, true);
|
||||
test("abcde", S(""), true, false);
|
||||
test("abcde", S("abcde"), true, true);
|
||||
test("abcde", S("abcdefghij"), false, true);
|
||||
test("abcde", S("abcdefghijklmnopqrst"), false, true);
|
||||
test("abcdefghij", S(""), true, false);
|
||||
test("abcdefghij", S("abcde"), true, false);
|
||||
test("abcdefghij", S("abcdefghij"), true, true);
|
||||
test("abcdefghij", S("abcdefghijklmnopqrst"), false, true);
|
||||
test("abcdefghijklmnopqrst", S(""), true, false);
|
||||
test("abcdefghijklmnopqrst", S("abcde"), true, false);
|
||||
test("abcdefghijklmnopqrst", S("abcdefghij"), true, false);
|
||||
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true, true);
|
||||
}
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
{
|
||||
typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
|
||||
constexpr SV sv1;
|
||||
constexpr SV sv2 { "abcde", 5 };
|
||||
|
||||
static_assert ( sv1 >= "", "" );
|
||||
static_assert ( "" >= sv1, "" );
|
||||
static_assert (!(sv1 >= "abcde"), "" );
|
||||
static_assert ( "abcde" >= sv1, "" );
|
||||
|
||||
static_assert ( sv2 >= "", "" );
|
||||
static_assert (!("" >= sv2), "" );
|
||||
static_assert ( sv2 >= "abcde", "" );
|
||||
static_assert ( "abcde" >= sv2, "" );
|
||||
static_assert (!(sv2 >= "abcde0"), "" );
|
||||
static_assert ( "abcde0" >= sv2, "" );
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits, class Allocator>
|
||||
// bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
|
||||
// basic_string_view<charT,traits> rhs);
|
||||
// bool operator>=(basic_string_view<charT,traits> lhs,
|
||||
// const basic_string<charT,traits,Allocator>& rhs);
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const S& lhs, const typename S::value_type* rhs, bool x, bool y)
|
||||
{
|
||||
assert((lhs >= rhs) == x);
|
||||
assert((rhs >= lhs) == y);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef std::string_view S;
|
||||
test(S(""), "", true, true);
|
||||
test(S(""), "abcde", false, true);
|
||||
test(S(""), "abcdefghij", false, true);
|
||||
test(S(""), "abcdefghijklmnopqrst", false, true);
|
||||
test(S("abcde"), "", true, false);
|
||||
test(S("abcde"), "abcde", true, true);
|
||||
test(S("abcde"), "abcdefghij", false, true);
|
||||
test(S("abcde"), "abcdefghijklmnopqrst", false, true);
|
||||
test(S("abcdefghij"), "", true, false);
|
||||
test(S("abcdefghij"), "abcde", true, false);
|
||||
test(S("abcdefghij"), "abcdefghij", true, true);
|
||||
test(S("abcdefghij"), "abcdefghijklmnopqrst", false, true);
|
||||
test(S("abcdefghijklmnopqrst"), "", true, false);
|
||||
test(S("abcdefghijklmnopqrst"), "abcde", true, false);
|
||||
test(S("abcdefghijklmnopqrst"), "abcdefghij", true, false);
|
||||
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true, true);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits>
|
||||
// constexpr bool operator>=(basic_string_view<charT,traits> lhs,
|
||||
// basic_string_view<charT,traits> rhs);
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "constexpr_char_traits.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const S& lhs, const S& rhs, bool x, bool y)
|
||||
{
|
||||
assert((lhs >= rhs) == x);
|
||||
assert((rhs >= lhs) == y);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef std::string_view S;
|
||||
test(S(""), S(""), true, true);
|
||||
test(S(""), S("abcde"), false, true);
|
||||
test(S(""), S("abcdefghij"), false, true);
|
||||
test(S(""), S("abcdefghijklmnopqrst"), false, true);
|
||||
test(S("abcde"), S(""), true, false);
|
||||
test(S("abcde"), S("abcde"), true, true);
|
||||
test(S("abcde"), S("abcdefghij"), false, true);
|
||||
test(S("abcde"), S("abcdefghijklmnopqrst"), false, true);
|
||||
test(S("abcdefghij"), S(""), true, false);
|
||||
test(S("abcdefghij"), S("abcde"), true, false);
|
||||
test(S("abcdefghij"), S("abcdefghij"), true, true);
|
||||
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false, true);
|
||||
test(S("abcdefghijklmnopqrst"), S(""), true, false);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcde"), true, false);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true, false);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true, true);
|
||||
}
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
{
|
||||
typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
|
||||
constexpr SV sv1;
|
||||
constexpr SV sv2 { "abcde", 5 };
|
||||
|
||||
static_assert ( sv1 >= sv1, "" );
|
||||
static_assert ( sv2 >= sv2, "" );
|
||||
|
||||
static_assert (!(sv1 >= sv2), "" );
|
||||
static_assert ( sv2 >= sv1, "" );
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// constexpr template<class charT, class traits, class Allocator>
|
||||
// bool operator>(const charT* lhs, basic_string_view<charT,traits> rhs);
|
||||
// constexpr template<class charT, class traits, class Allocator>
|
||||
// bool operator>(basic_string_view<charT,traits> lhs, const charT* rhs);
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "constexpr_char_traits.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const typename S::value_type* lhs, const S& rhs, bool x, bool y)
|
||||
{
|
||||
assert((lhs > rhs) == x);
|
||||
assert((rhs > lhs) == y);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef std::string_view S;
|
||||
test("", S(""), false, false);
|
||||
test("", S("abcde"), false, true);
|
||||
test("", S("abcdefghij"), false, true);
|
||||
test("", S("abcdefghijklmnopqrst"), false, true);
|
||||
test("abcde", S(""), true, false);
|
||||
test("abcde", S("abcde"), false, false);
|
||||
test("abcde", S("abcdefghij"), false, true);
|
||||
test("abcde", S("abcdefghijklmnopqrst"), false, true);
|
||||
test("abcdefghij", S(""), true, false);
|
||||
test("abcdefghij", S("abcde"), true, false);
|
||||
test("abcdefghij", S("abcdefghij"), false, false);
|
||||
test("abcdefghij", S("abcdefghijklmnopqrst"), false, true);
|
||||
test("abcdefghijklmnopqrst", S(""), true, false);
|
||||
test("abcdefghijklmnopqrst", S("abcde"), true, false);
|
||||
test("abcdefghijklmnopqrst", S("abcdefghij"), true, false);
|
||||
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false, false);
|
||||
}
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
{
|
||||
typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
|
||||
constexpr SV sv1;
|
||||
constexpr SV sv2 { "abcde", 5 };
|
||||
|
||||
static_assert (!(sv1 > ""), "" );
|
||||
static_assert (!("" > sv1), "" );
|
||||
static_assert (!(sv1 > "abcde"), "" );
|
||||
static_assert ( "abcde" > sv1, "" );
|
||||
|
||||
static_assert ( sv2 > "", "" );
|
||||
static_assert (!("" > sv2), "" );
|
||||
static_assert (!(sv2 > "abcde"), "" );
|
||||
static_assert (!("abcde" > sv2), "" );
|
||||
static_assert (!(sv2 > "abcde0"), "" );
|
||||
static_assert ( "abcde0" > sv2, "" );
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits, class Allocator>
|
||||
// bool operator>(const basic_string<charT,traits,Allocator>& lhs,
|
||||
// basic_string_view<charT,traits> rhs);
|
||||
// bool operator>(basic_string_view<charT,traits> lhs,
|
||||
// const basic_string<charT,traits,Allocator>& rhs);
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const S& lhs, const typename S::value_type* rhs, bool x, bool y)
|
||||
{
|
||||
assert((lhs > rhs) == x);
|
||||
assert((rhs > lhs) == y);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef std::string_view S;
|
||||
test(S(""), "", false, false);
|
||||
test(S(""), "abcde", false, true);
|
||||
test(S(""), "abcdefghij", false, true);
|
||||
test(S(""), "abcdefghijklmnopqrst", false, true);
|
||||
test(S("abcde"), "", true, false);
|
||||
test(S("abcde"), "abcde", false, false);
|
||||
test(S("abcde"), "abcdefghij", false, true);
|
||||
test(S("abcde"), "abcdefghijklmnopqrst", false, true);
|
||||
test(S("abcdefghij"), "", true, false);
|
||||
test(S("abcdefghij"), "abcde", true, false);
|
||||
test(S("abcdefghij"), "abcdefghij", false, false);
|
||||
test(S("abcdefghij"), "abcdefghijklmnopqrst", false, true);
|
||||
test(S("abcdefghijklmnopqrst"), "", true, false);
|
||||
test(S("abcdefghijklmnopqrst"), "abcde", true, false);
|
||||
test(S("abcdefghijklmnopqrst"), "abcdefghij", true, false);
|
||||
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false, false);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits>
|
||||
// constexpr bool operator>(basic_string_view<charT,traits> lhs,
|
||||
// basic_string_view<charT,traits> rhs);
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "constexpr_char_traits.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const S& lhs, const S& rhs, bool x, bool y)
|
||||
{
|
||||
assert((lhs > rhs) == x);
|
||||
assert((rhs > lhs) == y);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef std::string_view S;
|
||||
test(S(""), S(""), false, false);
|
||||
test(S(""), S("abcde"), false, true);
|
||||
test(S(""), S("abcdefghij"), false, true);
|
||||
test(S(""), S("abcdefghijklmnopqrst"), false, true);
|
||||
test(S("abcde"), S(""), true, false);
|
||||
test(S("abcde"), S("abcde"), false, false);
|
||||
test(S("abcde"), S("abcdefghij"), false, true);
|
||||
test(S("abcde"), S("abcdefghijklmnopqrst"), false, true);
|
||||
test(S("abcdefghij"), S(""), true, false);
|
||||
test(S("abcdefghij"), S("abcde"), true, false);
|
||||
test(S("abcdefghij"), S("abcdefghij"), false, false);
|
||||
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false, true);
|
||||
test(S("abcdefghijklmnopqrst"), S(""), true, false);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcde"), true, false);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true, false);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false, false);
|
||||
}
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
{
|
||||
typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
|
||||
constexpr SV sv1;
|
||||
constexpr SV sv2 { "abcde", 5 };
|
||||
|
||||
static_assert (!(sv1 > sv1), "" );
|
||||
static_assert (!(sv2 > sv2), "" );
|
||||
|
||||
static_assert (!(sv1 > sv2), "" );
|
||||
static_assert ( sv2 > sv1, "" );
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits, class Allocator>
|
||||
// constexpr bool operator<=(const charT* lhs, basic_string_view<charT,traits> rhs);
|
||||
// template<class charT, class traits, class Allocator>
|
||||
// constexpr bool operator<=(basic_string_view<charT,traits> lhs, const charT* rhs);
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "constexpr_char_traits.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const typename S::value_type* lhs, const S& rhs, bool x, bool y)
|
||||
{
|
||||
assert((lhs <= rhs) == x);
|
||||
assert((rhs <= lhs) == y);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef std::string_view S;
|
||||
test("", S(""), true, true);
|
||||
test("", S("abcde"), true, false);
|
||||
test("", S("abcdefghij"), true, false);
|
||||
test("", S("abcdefghijklmnopqrst"), true, false);
|
||||
test("abcde", S(""), false, true);
|
||||
test("abcde", S("abcde"), true, true);
|
||||
test("abcde", S("abcdefghij"), true, false);
|
||||
test("abcde", S("abcdefghijklmnopqrst"), true, false);
|
||||
test("abcdefghij", S(""), false, true);
|
||||
test("abcdefghij", S("abcde"), false, true);
|
||||
test("abcdefghij", S("abcdefghij"), true, true);
|
||||
test("abcdefghij", S("abcdefghijklmnopqrst"), true, false);
|
||||
test("abcdefghijklmnopqrst", S(""), false, true);
|
||||
test("abcdefghijklmnopqrst", S("abcde"), false, true);
|
||||
test("abcdefghijklmnopqrst", S("abcdefghij"), false, true);
|
||||
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true, true);
|
||||
}
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
{
|
||||
typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
|
||||
constexpr SV sv1;
|
||||
constexpr SV sv2 { "abcde", 5 };
|
||||
|
||||
static_assert ( sv1 <= "", "" );
|
||||
static_assert ( "" <= sv1, "" );
|
||||
static_assert ( sv1 <= "abcde", "" );
|
||||
static_assert (!("abcde" <= sv1), "" );
|
||||
|
||||
static_assert (!(sv2 <= ""), "" );
|
||||
static_assert ( "" <= sv2, "" );
|
||||
static_assert ( sv2 <= "abcde", "" );
|
||||
static_assert ( "abcde" <= sv2, "" );
|
||||
static_assert ( sv2 <= "abcde0", "" );
|
||||
static_assert (!("abcde0" <= sv2), "" );
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits, class Allocator>
|
||||
// bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
|
||||
// basic_string_view<charT,traits> rhs);
|
||||
// bool operator<=(basic_string_view<charT,traits> lhs,
|
||||
// const basic_string<charT,traits,Allocator>& rhs);
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const S& lhs, const typename S::value_type* rhs, bool x, bool y)
|
||||
{
|
||||
assert((lhs <= rhs) == x);
|
||||
assert((rhs <= lhs) == y);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef std::string_view S;
|
||||
test(S(""), "", true, true);
|
||||
test(S(""), "abcde", true, false);
|
||||
test(S(""), "abcdefghij", true, false);
|
||||
test(S(""), "abcdefghijklmnopqrst", true, false);
|
||||
test(S("abcde"), "", false, true);
|
||||
test(S("abcde"), "abcde", true, true);
|
||||
test(S("abcde"), "abcdefghij", true, false);
|
||||
test(S("abcde"), "abcdefghijklmnopqrst", true, false);
|
||||
test(S("abcdefghij"), "", false, true);
|
||||
test(S("abcdefghij"), "abcde", false, true);
|
||||
test(S("abcdefghij"), "abcdefghij", true, true);
|
||||
test(S("abcdefghij"), "abcdefghijklmnopqrst", true, false);
|
||||
test(S("abcdefghijklmnopqrst"), "", false, true);
|
||||
test(S("abcdefghijklmnopqrst"), "abcde", false, true);
|
||||
test(S("abcdefghijklmnopqrst"), "abcdefghij", false, true);
|
||||
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true, true);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits>
|
||||
// constexpr bool operator<=(basic_string_view<charT,traits> lhs,
|
||||
// basic_string_view<charT,traits> rhs);
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "constexpr_char_traits.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const S& lhs, const S& rhs, bool x, bool y)
|
||||
{
|
||||
assert((lhs <= rhs) == x);
|
||||
assert((rhs <= lhs) == y);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef std::string_view S;
|
||||
test(S(""), S(""), true, true);
|
||||
test(S(""), S("abcde"), true, false);
|
||||
test(S(""), S("abcdefghij"), true, false);
|
||||
test(S(""), S("abcdefghijklmnopqrst"), true, false);
|
||||
test(S("abcde"), S(""), false, true);
|
||||
test(S("abcde"), S("abcde"), true, true);
|
||||
test(S("abcde"), S("abcdefghij"), true, false);
|
||||
test(S("abcde"), S("abcdefghijklmnopqrst"), true, false);
|
||||
test(S("abcdefghij"), S(""), false, true);
|
||||
test(S("abcdefghij"), S("abcde"), false, true);
|
||||
test(S("abcdefghij"), S("abcdefghij"), true, true);
|
||||
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true, false);
|
||||
test(S("abcdefghijklmnopqrst"), S(""), false, true);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcde"), false, true);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false, true);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true, true);
|
||||
}
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
{
|
||||
typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
|
||||
constexpr SV sv1;
|
||||
constexpr SV sv2 { "abcde", 5 };
|
||||
|
||||
static_assert ( sv1 <= sv1, "" );
|
||||
static_assert ( sv2 <= sv2, "" );
|
||||
|
||||
static_assert ( sv1 <= sv2, "" );
|
||||
static_assert (!(sv2 <= sv1), "" );
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits, class Allocator>
|
||||
// constexpr bool operator<(const charT* lhs, basic_string_view<charT,traits> rhs);
|
||||
// template<class charT, class traits, class Allocator>
|
||||
// constexpr bool operator<(basic_string_view<charT,traits> lhs, const charT* rhs);
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "constexpr_char_traits.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const typename S::value_type* lhs, const S& rhs, bool x, bool y)
|
||||
{
|
||||
assert((lhs < rhs) == x);
|
||||
assert((rhs < lhs) == y);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef std::string_view S;
|
||||
test("", S(""), false, false);
|
||||
test("", S("abcde"), true, false);
|
||||
test("", S("abcdefghij"), true, false);
|
||||
test("", S("abcdefghijklmnopqrst"), true, false);
|
||||
test("abcde", S(""), false, true);
|
||||
test("abcde", S("abcde"), false, false);
|
||||
test("abcde", S("abcdefghij"), true, false);
|
||||
test("abcde", S("abcdefghijklmnopqrst"), true, false);
|
||||
test("abcdefghij", S(""), false, true);
|
||||
test("abcdefghij", S("abcde"), false, true);
|
||||
test("abcdefghij", S("abcdefghij"), false, false);
|
||||
test("abcdefghij", S("abcdefghijklmnopqrst"), true, false);
|
||||
test("abcdefghijklmnopqrst", S(""), false, true);
|
||||
test("abcdefghijklmnopqrst", S("abcde"), false, true);
|
||||
test("abcdefghijklmnopqrst", S("abcdefghij"), false, true);
|
||||
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false, false);
|
||||
}
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
{
|
||||
typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
|
||||
constexpr SV sv1;
|
||||
constexpr SV sv2 { "abcde", 5 };
|
||||
|
||||
static_assert (!(sv1 < ""), "" );
|
||||
static_assert (!("" < sv1), "" );
|
||||
static_assert ( sv1 < "abcde", "" );
|
||||
static_assert (!("abcde" < sv1), "" );
|
||||
|
||||
static_assert (!(sv2 < ""), "" );
|
||||
static_assert ( "" < sv2, "" );
|
||||
static_assert (!(sv2 < "abcde"), "" );
|
||||
static_assert (!("abcde" < sv2), "" );
|
||||
static_assert ( sv2 < "abcde0", "" );
|
||||
static_assert (!("abcde0" < sv2), "" );
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits, class Allocator>
|
||||
// bool operator<(const basic_string<charT,traits,Allocator>& lhs,
|
||||
// basic_string_view<charT,traits> rhs);
|
||||
// bool operator<(basic_string_view<charT,traits> lhs,
|
||||
// const basic_string<charT,traits,Allocator>& rhs);
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const S& lhs, const typename S::value_type* rhs, bool x, bool y)
|
||||
{
|
||||
assert((lhs < rhs) == x);
|
||||
assert((rhs < lhs) == y);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef std::string_view S;
|
||||
test(S(""), "", false, false);
|
||||
test(S(""), "abcde", true, false);
|
||||
test(S(""), "abcdefghij", true, false);
|
||||
test(S(""), "abcdefghijklmnopqrst", true, false);
|
||||
test(S("abcde"), "", false, true);
|
||||
test(S("abcde"), "abcde", false, false);
|
||||
test(S("abcde"), "abcdefghij", true, false);
|
||||
test(S("abcde"), "abcdefghijklmnopqrst", true, false);
|
||||
test(S("abcdefghij"), "", false, true);
|
||||
test(S("abcdefghij"), "abcde", false, true);
|
||||
test(S("abcdefghij"), "abcdefghij", false, false);
|
||||
test(S("abcdefghij"), "abcdefghijklmnopqrst", true, false);
|
||||
test(S("abcdefghijklmnopqrst"), "", false, true);
|
||||
test(S("abcdefghijklmnopqrst"), "abcde", false, true);
|
||||
test(S("abcdefghijklmnopqrst"), "abcdefghij", false, true);
|
||||
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false, false);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits>
|
||||
// constexpr bool operator<(basic_string_view<charT,traits> lhs,
|
||||
// basic_string_view<charT,traits> rhs);
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "constexpr_char_traits.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const S& lhs, const S& rhs, bool x, bool y)
|
||||
{
|
||||
assert((lhs < rhs) == x);
|
||||
assert((rhs < lhs) == y);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef std::string_view S;
|
||||
test(S(""), S(""), false, false);
|
||||
test(S(""), S("abcde"), true, false);
|
||||
test(S(""), S("abcdefghij"), true, false);
|
||||
test(S(""), S("abcdefghijklmnopqrst"), true, false);
|
||||
test(S("abcde"), S(""), false, true);
|
||||
test(S("abcde"), S("abcde"), false, false);
|
||||
test(S("abcde"), S("abcdefghij"), true, false);
|
||||
test(S("abcde"), S("abcdefghijklmnopqrst"), true, false);
|
||||
test(S("abcdefghij"), S(""), false, true);
|
||||
test(S("abcdefghij"), S("abcde"), false, true);
|
||||
test(S("abcdefghij"), S("abcdefghij"), false, false);
|
||||
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true, false);
|
||||
test(S("abcdefghijklmnopqrst"), S(""), false, true);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcde"), false, true);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false, true);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false, false);
|
||||
}
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
{
|
||||
typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
|
||||
constexpr SV sv1;
|
||||
constexpr SV sv2 { "abcde", 5 };
|
||||
|
||||
static_assert (!(sv1 < sv1), "" );
|
||||
static_assert (!(sv2 < sv2), "" );
|
||||
|
||||
static_assert ( sv1 < sv2, "" );
|
||||
static_assert (!(sv2 < sv1), "" );
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits>
|
||||
// constexpr bool operator!=(basic_string_view<charT,traits> lhs, const charT* rhs);
|
||||
// template<class charT, class traits>
|
||||
// constexpr bool operator!=(const charT* lhs, basic_string_view<charT,traits> rhs);
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "constexpr_char_traits.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(S lhs, const typename S::value_type* rhs, bool x)
|
||||
{
|
||||
assert((lhs != rhs) == x);
|
||||
assert((rhs != lhs) == x);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef std::string_view S;
|
||||
test(S(""), "", false);
|
||||
test(S(""), "abcde", true);
|
||||
test(S(""), "abcdefghij", true);
|
||||
test(S(""), "abcdefghijklmnopqrst", true);
|
||||
test(S("abcde"), "", true);
|
||||
test(S("abcde"), "abcde", false);
|
||||
test(S("abcde"), "abcdefghij", true);
|
||||
test(S("abcde"), "abcdefghijklmnopqrst", true);
|
||||
test(S("abcdefghij"), "", true);
|
||||
test(S("abcdefghij"), "abcde", true);
|
||||
test(S("abcdefghij"), "abcdefghij", false);
|
||||
test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
|
||||
test(S("abcdefghijklmnopqrst"), "", true);
|
||||
test(S("abcdefghijklmnopqrst"), "abcde", true);
|
||||
test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
|
||||
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
|
||||
}
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
{
|
||||
typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
|
||||
constexpr SV sv1;
|
||||
constexpr SV sv2 { "abcde", 5 };
|
||||
|
||||
static_assert (!(sv1 != ""), "" );
|
||||
static_assert (!("" != sv1), "" );
|
||||
static_assert ( sv1 != "abcde", "" );
|
||||
static_assert ( "abcde" != sv1, "" );
|
||||
|
||||
static_assert (!(sv2 != "abcde"), "" );
|
||||
static_assert (!("abcde" != sv2), "" );
|
||||
static_assert ( sv2 != "abcde0", "" );
|
||||
static_assert ( "abcde0" != sv2, "" );
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits, class Allocator>
|
||||
// bool operator!=(const basic_string<charT, traits, Allocator> &lhs, basic_string_view<charT,traits> rhs);
|
||||
// template<class charT, class traits, class Allocator>
|
||||
// bool operator!=(basic_string_view<charT,traits> lhs, const basic_string<charT, traits, Allocator> &rhs);
|
||||
|
||||
#include <string_view>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(const std::string &lhs, S rhs, bool x)
|
||||
{
|
||||
assert((lhs != rhs) == x);
|
||||
assert((rhs != lhs) == x);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef std::string_view S;
|
||||
test("", S(""), false);
|
||||
test("", S("abcde"), true);
|
||||
test("", S("abcdefghij"), true);
|
||||
test("", S("abcdefghijklmnopqrst"), true);
|
||||
test("abcde", S(""), true);
|
||||
test("abcde", S("abcde"), false);
|
||||
test("abcde", S("abcdefghij"), true);
|
||||
test("abcde", S("abcdefghijklmnopqrst"), true);
|
||||
test("abcdefghij", S(""), true);
|
||||
test("abcdefghij", S("abcde"), true);
|
||||
test("abcdefghij", S("abcdefghij"), false);
|
||||
test("abcdefghij", S("abcdefghijklmnopqrst"), true);
|
||||
test("abcdefghijklmnopqrst", S(""), true);
|
||||
test("abcdefghijklmnopqrst", S("abcde"), true);
|
||||
test("abcdefghijklmnopqrst", S("abcdefghij"), true);
|
||||
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string_view>
|
||||
|
||||
// template<class charT, class traits, class Allocator>
|
||||
// constexpr bool operator!=(const basic_string_view<charT,traits> lhs,
|
||||
// const basic_string_view<charT,traits> rhs);
|
||||
|
||||
#include <string_view>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "constexpr_char_traits.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
test(S lhs, S rhs, bool x)
|
||||
{
|
||||
assert((lhs != rhs) == x);
|
||||
assert((rhs != lhs) == x);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef std::string_view S;
|
||||
test(S(""), S(""), false);
|
||||
test(S(""), S("abcde"), true);
|
||||
test(S(""), S("abcdefghij"), true);
|
||||
test(S(""), S("abcdefghijklmnopqrst"), true);
|
||||
test(S("abcde"), S(""), true);
|
||||
test(S("abcde"), S("abcde"), false);
|
||||
test(S("abcde"), S("abcdefghij"), true);
|
||||
test(S("abcde"), S("abcdefghijklmnopqrst"), true);
|
||||
test(S("abcdefghij"), S(""), true);
|
||||
test(S("abcdefghij"), S("abcde"), true);
|
||||
test(S("abcdefghij"), S("abcdefghij"), false);
|
||||
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
|
||||
test(S("abcdefghijklmnopqrst"), S(""), true);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcde"), true);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
|
||||
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
|
||||
}
|
||||
|
||||
#if TEST_STD_VER > 11
|
||||
{
|
||||
typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
|
||||
constexpr SV sv1;
|
||||
constexpr SV sv2;
|
||||
constexpr SV sv3 { "abcde", 5 };
|
||||
static_assert (!( sv1 != sv2), "" );
|
||||
static_assert ( sv1 != sv3, "" );
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue