mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-23 23:29:50 +00:00
Add string comparison tests
This commit is contained in:
parent
ff86dce342
commit
c0674ccbab
@ -6,6 +6,7 @@
|
||||
#include <numeric>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
extern "C" void cxx_test_suite_set_correct() noexcept;
|
||||
extern "C" tests::R *cxx_test_suite_get_box() noexcept;
|
||||
@ -656,6 +657,24 @@ extern "C" const char *cxx_run_test() noexcept {
|
||||
ASSERT(Shared{1} == Shared{1});
|
||||
ASSERT(Shared{1} != Shared{2});
|
||||
|
||||
rust::String first = "first", second = "second", sec = "sec";
|
||||
bool (rust::String::*cmp)(const rust::String &) const;
|
||||
bool first_first, first_second, sec_second, second_sec;
|
||||
for (auto test : (std::tuple<decltype(cmp), bool, bool, bool, bool>[]) {
|
||||
{&rust::String::operator==, true, false, false, false},
|
||||
{&rust::String::operator!=, false, true, true, true},
|
||||
{&rust::String::operator<, false, true, true, false},
|
||||
{&rust::String::operator<=, true, true, true, false},
|
||||
{&rust::String::operator>, false, false, false, true},
|
||||
{&rust::String::operator>=, true, false, false, true},
|
||||
}) {
|
||||
std::tie(cmp, first_first, first_second, sec_second, second_sec) = test;
|
||||
ASSERT((first.*cmp)(first) == first_first);
|
||||
ASSERT((first.*cmp)(second) == first_second);
|
||||
ASSERT((sec.*cmp)(second) == sec_second);
|
||||
ASSERT((second.*cmp)(sec) == second_sec);
|
||||
}
|
||||
|
||||
cxx_test_suite_set_correct();
|
||||
return nullptr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user