[libc++][test] Use LIBCPP_ASSERT in some system_category-related tests (#78834)

This commit is contained in:
S. B. Tam 2024-01-23 13:25:13 +08:00 committed by GitHub
parent 8c3304453c
commit f1d3ebc991
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 119 additions and 119 deletions

View File

@ -22,8 +22,7 @@
#include "test_macros.h"
int main(int, char**)
{
int main(int, char**) {
std::error_code e_code1(5, std::generic_category());
std::error_code e_code2(5, std::system_category());
std::error_code e_code3(6, std::generic_category());
@ -46,9 +45,9 @@ int main(int, char**)
assert(e_code2 == e_code2);
assert(e_code2 != e_code3);
assert(e_code2 != e_code4);
assert(e_code2 == e_condition1); // ?
LIBCPP_ASSERT(e_code2 == e_condition1);
assert(e_code2 == e_condition2);
assert(e_code2 != e_condition3);
LIBCPP_ASSERT(e_code2 != e_condition3);
assert(e_code2 != e_condition4);
assert(e_code3 != e_code1);
@ -64,15 +63,15 @@ int main(int, char**)
assert(e_code4 != e_code2);
assert(e_code4 != e_code3);
assert(e_code4 == e_code4);
assert(e_code4 != e_condition1);
LIBCPP_ASSERT(e_code4 != e_condition1);
assert(e_code4 != e_condition2);
assert(e_code4 == e_condition3); // ?
LIBCPP_ASSERT(e_code4 == e_condition3);
assert(e_code4 == e_condition4);
assert(e_condition1 == e_code1);
assert(e_condition1 == e_code2); // ?
LIBCPP_ASSERT(e_condition1 == e_code2);
assert(e_condition1 != e_code3);
assert(e_condition1 != e_code4);
LIBCPP_ASSERT(e_condition1 != e_code4);
assert(e_condition1 == e_condition1);
assert(e_condition1 != e_condition2);
assert(e_condition1 != e_condition3);
@ -88,9 +87,9 @@ int main(int, char**)
assert(e_condition2 != e_condition4);
assert(e_condition3 != e_code1);
assert(e_condition3 != e_code2);
LIBCPP_ASSERT(e_condition3 != e_code2);
assert(e_condition3 == e_code3);
assert(e_condition3 == e_code4); // ?
LIBCPP_ASSERT(e_condition3 == e_code4);
assert(e_condition3 != e_condition1);
assert(e_condition3 != e_condition2);
assert(e_condition3 == e_condition3);

View File

@ -20,8 +20,7 @@
#include "test_macros.h"
int main(int, char**)
{
int main(int, char**) {
const std::error_category& e_cat1 = std::generic_category();
const std::error_category& e_cat2 = std::system_category();
std::string m1 = e_cat1.message(5);
@ -30,7 +29,7 @@ int main(int, char**)
assert(!m1.empty());
assert(!m2.empty());
assert(!m3.empty());
assert(m1 == m2);
LIBCPP_ASSERT(m1 == m2);
assert(m1 != m3);
return 0;

View File

@ -31,16 +31,18 @@ struct StaticInit {
};
static StaticInit foo;
int main(int, char**)
{
int main(int, char**) {
{
const std::error_category& e_cat1 = std::system_category();
std::error_condition e_cond = e_cat1.default_error_condition(5);
assert(e_cond.value() == 5);
assert(e_cond.category() == std::generic_category());
LIBCPP_ASSERT(e_cond.value() == 5);
LIBCPP_ASSERT(e_cond.category() == std::generic_category());
assert(e_cat1.equivalent(5, e_cond));
e_cond = e_cat1.default_error_condition(5000);
assert(e_cond.value() == 5000);
assert(e_cond.category() == std::system_category());
LIBCPP_ASSERT(e_cond.value() == 5000);
LIBCPP_ASSERT(e_cond.category() == std::system_category());
assert(e_cat1.equivalent(5000, e_cond));
}
// Test the result of message(int cond) when given a bad error condition