diff options
| author | Lexi Winter <lexi@hemlock.eden.le-fay.org> | 2025-03-29 07:27:04 +0000 |
|---|---|---|
| committer | Lexi Winter <lexi@hemlock.eden.le-fay.org> | 2025-03-29 07:27:04 +0000 |
| commit | 9d36060ce292f27a6427f87d71a45ed93e171bb8 (patch) | |
| tree | 6fed4340ebee925523d501309206b5f0160bf4b7 | |
| parent | 4a789145cfecc2fe63c5a1100e8a02b009c94144 (diff) | |
| download | libnvxx-9d36060ce292f27a6427f87d71a45ed93e171bb8.tar.gz libnvxx-9d36060ce292f27a6427f87d71a45ed93e171bb8.tar.bz2 | |
add tests for flags()
| -rw-r--r-- | libnvxx/const_nv_list.cc | 2 | ||||
| -rw-r--r-- | libnvxx/nvxx_base.h | 2 | ||||
| -rw-r--r-- | libnvxx/tests/nvxx_basic.cc | 30 |
3 files changed, 32 insertions, 2 deletions
diff --git a/libnvxx/const_nv_list.cc b/libnvxx/const_nv_list.cc index 0098d60..e27554f 100644 --- a/libnvxx/const_nv_list.cc +++ b/libnvxx/const_nv_list.cc @@ -94,7 +94,7 @@ __const_nv_list::empty() const noexcept } int -__const_nv_list::flags() const noexcept +__const_nv_list::flags() const { __throw_if_error(); return (::nvlist_flags(__m_nv)); diff --git a/libnvxx/nvxx_base.h b/libnvxx/nvxx_base.h index 07cd9e7..7c12921 100644 --- a/libnvxx/nvxx_base.h +++ b/libnvxx/nvxx_base.h @@ -143,7 +143,7 @@ struct __const_nv_list : virtual __nv_list_base { /* * Return the flags used to create this nv_list. */ - [[nodiscard]] int flags() const noexcept; + [[nodiscard]] int flags() const; /* * Returns true if this nv_list is part of an array contained inside diff --git a/libnvxx/tests/nvxx_basic.cc b/libnvxx/tests/nvxx_basic.cc index 31d2b11..edd9937 100644 --- a/libnvxx/tests/nvxx_basic.cc +++ b/libnvxx/tests/nvxx_basic.cc @@ -319,6 +319,32 @@ TEST_CASE(nvxx_set_error_null) } /* + * flags + */ + +TEST_CASE(nvxx_flags) +{ + auto nvl = bsd::nv_list(NV_FLAG_IGNORE_CASE); + + ATF_REQUIRE_EQ(NV_FLAG_IGNORE_CASE, nvl.flags()); +} + +TEST_CASE(nvxx_flags_empty) +{ + auto cnv = bsd::const_nv_list(); + + ATF_REQUIRE_THROW(std::logic_error, (void)cnv.flags()); +} + +TEST_CASE(nvxx_flags_error) +{ + auto nvl = bsd::nv_list(); + nvl.set_error(std::errc::invalid_argument); + + ATF_REQUIRE_THROW(bsd::nv_error_state, (void)nvl.flags()); +} + +/* * pack/unpack */ @@ -2007,6 +2033,10 @@ ATF_INIT_TEST_CASES(tcs) ATF_ADD_TEST_CASE(tcs, nvxx_set_error_null); ATF_ADD_TEST_CASE(tcs, nvxx_error_null); + ATF_ADD_TEST_CASE(tcs, nvxx_flags); + ATF_ADD_TEST_CASE(tcs, nvxx_flags_empty); + ATF_ADD_TEST_CASE(tcs, nvxx_flags_error); + ATF_ADD_TEST_CASE(tcs, nvxx_pack); ATF_ADD_TEST_CASE(tcs, nvxx_pack_error); ATF_ADD_TEST_CASE(tcs, nvxx_pack_empty); |
