tests: use BOOST_REQUIRE and Name::at() to prevent out-of-bound accesses
Various other cleanups
Change-Id: Ie099e618b12b7b6cf36c32be96d753221f14a8b6
diff --git a/tests/test-bloom-filter.cpp b/tests/test-bloom-filter.cpp
index 77a56a0..1788cd1 100644
--- a/tests/test-bloom-filter.cpp
+++ b/tests/test-bloom-filter.cpp
@@ -19,7 +19,8 @@
#include "PSync/detail/bloom-filter.hpp"
-#include <boost/test/unit_test.hpp>
+#include "tests/boost-test.hpp"
+
#include <ndn-cxx/name.hpp>
namespace psync {
@@ -42,18 +43,17 @@
Name bfName("/test");
BloomFilter bf(100, 0.001);
bf.insert("/memphis");
-
bf.appendToName(bfName);
- BloomFilter bfFromName(100, 0.001, bfName.get(-1));
+ BloomFilter bfFromName(100, 0.001, bfName.at(-1));
- BOOST_CHECK_EQUAL(bfName.get(1).toNumber(), 100);
- BOOST_CHECK_EQUAL(bfName.get(2).toNumber(), 1);
+ BOOST_CHECK_EQUAL(bfName.at(1).toNumber(), 100);
+ BOOST_CHECK_EQUAL(bfName.at(2).toNumber(), 1);
BOOST_CHECK_EQUAL(bf, bfFromName);
- BOOST_CHECK_THROW(BloomFilter inCompatibleBf(200, 0.001, bfName.get(-1)), std::runtime_error);
+ BOOST_CHECK_THROW(BloomFilter(200, 0.001, bfName.at(-1)), std::runtime_error);
}
BOOST_AUTO_TEST_SUITE_END()
-} // namespace psync
\ No newline at end of file
+} // namespace psync