aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libnvxx/const_nv_list.cc2
-rw-r--r--libnvxx/nvxx_base.h2
-rw-r--r--libnvxx/tests/nvxx_basic.cc36
3 files changed, 38 insertions, 2 deletions
diff --git a/libnvxx/const_nv_list.cc b/libnvxx/const_nv_list.cc
index e27554f..2c2465f 100644
--- a/libnvxx/const_nv_list.cc
+++ b/libnvxx/const_nv_list.cc
@@ -87,7 +87,7 @@ __const_nv_list::exists(std::string_view key) const
bool
-__const_nv_list::empty() const noexcept
+__const_nv_list::empty() const
{
__throw_if_error();
return (::nvlist_empty(__m_nv));
diff --git a/libnvxx/nvxx_base.h b/libnvxx/nvxx_base.h
index 7c12921..43e53cf 100644
--- a/libnvxx/nvxx_base.h
+++ b/libnvxx/nvxx_base.h
@@ -138,7 +138,7 @@ struct __const_nv_list : virtual __nv_list_base {
/*
* Returns true if this nvlist is empty (contains no values).
*/
- [[nodiscard]] bool empty() const noexcept;
+ [[nodiscard]] bool empty() const;
/*
* Return the flags used to create this nv_list.
diff --git a/libnvxx/tests/nvxx_basic.cc b/libnvxx/tests/nvxx_basic.cc
index edd9937..835d2b2 100644
--- a/libnvxx/tests/nvxx_basic.cc
+++ b/libnvxx/tests/nvxx_basic.cc
@@ -345,6 +345,38 @@ TEST_CASE(nvxx_flags_error)
}
/*
+ * empty
+ */
+
+TEST_CASE(nvxx_empty)
+{
+ using namespace std::literals;
+ auto constexpr key = "test"sv;
+ auto constexpr value = 42u;
+
+ auto nvl = bsd::nv_list();
+ ATF_REQUIRE_EQ(true, nvl.empty());
+
+ nvl.add_number(key, value);
+ ATF_REQUIRE_EQ(false, nvl.empty());
+}
+
+TEST_CASE(nvxx_empty_empty)
+{
+ auto cnv = bsd::const_nv_list();
+
+ ATF_REQUIRE_THROW(std::logic_error, (void)cnv.empty());
+}
+
+TEST_CASE(nvxx_empty_error)
+{
+ auto nvl = bsd::nv_list();
+ nvl.set_error(std::errc::invalid_argument);
+
+ ATF_REQUIRE_THROW(bsd::nv_error_state, (void)nvl.empty());
+}
+
+/*
* pack/unpack
*/
@@ -2037,6 +2069,10 @@ ATF_INIT_TEST_CASES(tcs)
ATF_ADD_TEST_CASE(tcs, nvxx_flags_empty);
ATF_ADD_TEST_CASE(tcs, nvxx_flags_error);
+ ATF_ADD_TEST_CASE(tcs, nvxx_empty);
+ ATF_ADD_TEST_CASE(tcs, nvxx_empty_empty);
+ ATF_ADD_TEST_CASE(tcs, nvxx_empty_error);
+
ATF_ADD_TEST_CASE(tcs, nvxx_pack);
ATF_ADD_TEST_CASE(tcs, nvxx_pack_error);
ATF_ADD_TEST_CASE(tcs, nvxx_pack_empty);