[libcxx-commits] [libcxx] [libc++][test] Use LIBCPP_ASSERT in some `system_category`-related tests (PR #78834)
Will Hawkins via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Jan 20 16:59:18 PST 2024
================
@@ -23,47 +23,46 @@
// See https://llvm.org/D65667
struct StaticInit {
- const std::error_category* ec;
- ~StaticInit() {
- std::string str = ec->name();
- assert(str == "system") ;
- }
+ const std::error_category* ec;
+ ~StaticInit() {
+ std::string str = ec->name();
+ assert(str == "system");
+ }
};
static StaticInit foo;
-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());
- e_cond = e_cat1.default_error_condition(5000);
- assert(e_cond.value() == 5000);
- assert(e_cond.category() == std::system_category());
- }
+int main(int, char**) {
+ {
+ const std::error_category& e_cat1 = std::system_category();
+ std::error_condition e_cond = e_cat1.default_error_condition(5);
+ LIBCPP_ASSERT(e_cond.value() == 5);
----------------
hawkinsw wrote:
I find this fascinating. Thank you for doing these checks. Does it seem like we should rework this test so that we check whether the result of
```C++
e_cat1.default_error_condition(e)
```
,where `e` corresponds to a *POSIX errno value*), compares equal to
```C++
error_condition(e, generic_category())
```
as required by [the standard](http://eel.is/c++draft/syserr.errcat.objects#4.sentence-5)?
https://github.com/llvm/llvm-project/pull/78834
More information about the libcxx-commits
mailing list