tests: respect naming conventions and improve nesting of some test suites
Change-Id: I255c27b552b32570871a9d5f8bda814ba8723c80
Refs: #2497
diff --git a/tests/unit-tests/mgmt/dispatcher.t.cpp b/tests/unit-tests/mgmt/dispatcher.t.cpp
index 877ec02..76e5c6c 100644
--- a/tests/unit-tests/mgmt/dispatcher.t.cpp
+++ b/tests/unit-tests/mgmt/dispatcher.t.cpp
@@ -98,7 +98,7 @@
};
}
-BOOST_FIXTURE_TEST_CASE(BasicUsageSemantics, DispatcherFixture)
+BOOST_FIXTURE_TEST_CASE(Basic, DispatcherFixture)
{
BOOST_CHECK_NO_THROW(dispatcher
.addControlCommand<VoidParameters>("test/1", makeAcceptAllAuthorization(),
diff --git a/tests/unit-tests/mgmt/status-dataset-context.t.cpp b/tests/unit-tests/mgmt/status-dataset-context.t.cpp
index b1876db..cff721b 100644
--- a/tests/unit-tests/mgmt/status-dataset-context.t.cpp
+++ b/tests/unit-tests/mgmt/status-dataset-context.t.cpp
@@ -20,6 +20,7 @@
*/
#include "mgmt/status-dataset-context.hpp"
+
#include "boost-test.hpp"
#include "unit-tests/make-interest-data.hpp"
@@ -31,7 +32,7 @@
class StatusDatasetContextFixture
{
-public:
+private:
struct SendDataArgs
{
Name dataName;
@@ -40,6 +41,7 @@
bool isFinalBlock;
};
+protected:
StatusDatasetContextFixture()
: interest(makeInterest("/test/context/interest"))
, contentBlock(makeStringBlock(tlv::Content, "/test/data/content"))
@@ -57,18 +59,18 @@
}
Name
- makeSegmentName(size_t segmentNo)
+ makeSegmentName(size_t segmentNo) const
{
auto name = context.getPrefix();
return name.appendSegment(segmentNo);
}
Block
- concatenateDataContent()
+ concatenateDataContent() const
{
EncodingBuffer encoder;
size_t valueLength = 0;
- for (auto args : sendDataHistory) {
+ for (const auto& args : sendDataHistory) {
const auto& content = args.content;
valueLength += encoder.appendByteArray(content.value(), content.value_size());
}
@@ -77,7 +79,7 @@
return encoder.block();
}
-public:
+protected:
std::vector<SendDataArgs> sendDataHistory;
std::vector<ControlResponse> sendNackHistory;
shared_ptr<Interest> interest;
@@ -89,16 +91,16 @@
BOOST_AUTO_TEST_SUITE(Mgmt)
BOOST_FIXTURE_TEST_SUITE(TestStatusDatasetContext, StatusDatasetContextFixture)
-BOOST_AUTO_TEST_CASE(GetPrefix)
+BOOST_AUTO_TEST_SUITE(Prefix)
+
+BOOST_AUTO_TEST_CASE(Get)
{
Name dataName = context.getPrefix();
BOOST_CHECK(dataName[-1].isVersion());
BOOST_CHECK(dataName.getPrefix(-1) == interest->getName());
}
-BOOST_AUTO_TEST_SUITE(SetPrefix)
-
-BOOST_AUTO_TEST_CASE(Valid)
+BOOST_AUTO_TEST_CASE(SetValid)
{
Name validPrefix = Name(interest->getName()).append("/valid");
BOOST_CHECK_NO_THROW(context.setPrefix(validPrefix));
@@ -106,44 +108,49 @@
BOOST_CHECK(context.getPrefix().getPrefix(-1) == validPrefix);
}
-BOOST_AUTO_TEST_CASE(Invalid)
+BOOST_AUTO_TEST_CASE(SetInvalid)
{
Name invalidPrefix = Name(interest->getName()).getPrefix(-1).append("/invalid");
BOOST_CHECK_THROW(context.setPrefix(invalidPrefix), std::invalid_argument);
}
-BOOST_AUTO_TEST_CASE(ValidWithAppendCalled)
+BOOST_AUTO_TEST_CASE(SetValidWithAppendCalled)
{
Name validPrefix = Name(interest->getName()).append("/valid");
context.append(contentBlock);
BOOST_CHECK_THROW(context.setPrefix(validPrefix), std::domain_error);
}
-BOOST_AUTO_TEST_CASE(ValidWithEndCalled)
+BOOST_AUTO_TEST_CASE(SetValidWithEndCalled)
{
Name validPrefix = Name(interest->getName()).append("/valid");
context.end();
BOOST_CHECK_THROW(context.setPrefix(validPrefix), std::domain_error);
}
-BOOST_AUTO_TEST_CASE(ValidWithRejectCalled)
+BOOST_AUTO_TEST_CASE(SetValidWithRejectCalled)
{
Name validPrefix = Name(interest->getName()).append("/valid");
context.reject();
BOOST_CHECK_THROW(context.setPrefix(validPrefix), std::domain_error);
}
-BOOST_AUTO_TEST_SUITE_END() // SetPrefix
+BOOST_AUTO_TEST_SUITE_END() // Prefix
-BOOST_AUTO_TEST_CASE(Expiry)
+BOOST_AUTO_TEST_SUITE(Expiry)
+
+BOOST_AUTO_TEST_CASE(GetAndSet)
{
- // getExpiry & setExpiry
auto period = time::milliseconds(9527);
BOOST_CHECK_EQUAL(context.getExpiry(), time::milliseconds(1000));
BOOST_CHECK_EQUAL(context.setExpiry(period).getExpiry(), period);
}
-BOOST_AUTO_TEST_CASE(Respond)
+BOOST_AUTO_TEST_SUITE_END() // Expiry
+
+BOOST_AUTO_TEST_SUITE(Respond)
+
+BOOST_AUTO_TEST_CASE(Basic)
{
BOOST_CHECK_NO_THROW(context.append(contentBlock));
BOOST_CHECK(sendDataHistory.empty()); // does not call end yet
@@ -159,7 +166,7 @@
BOOST_CHECK_EQUAL(args.isFinalBlock, true);
}
-BOOST_AUTO_TEST_CASE(RespondLarge)
+BOOST_AUTO_TEST_CASE(Large)
{
static Block largeBlock = [] () -> Block {
EncodingBuffer encoder;
@@ -195,7 +202,7 @@
BOOST_CHECK(contentLargeBlock.elements()[0] == largeBlock);
}
-BOOST_AUTO_TEST_CASE(ResponseMultipleSmall)
+BOOST_AUTO_TEST_CASE(MultipleSmall)
{
size_t nBlocks = 100;
for (size_t i = 0 ; i < nBlocks ; i ++) {
@@ -217,22 +224,28 @@
}
}
-BOOST_AUTO_TEST_CASE(Reject)
+BOOST_AUTO_TEST_SUITE_END() // Respond
+
+BOOST_AUTO_TEST_SUITE(Reject)
+
+BOOST_AUTO_TEST_CASE(Basic)
{
BOOST_CHECK_NO_THROW(context.reject());
BOOST_REQUIRE_EQUAL(sendNackHistory.size(), 1);
BOOST_CHECK_EQUAL(sendNackHistory[0].getCode(), 400);
}
+BOOST_AUTO_TEST_SUITE_END() // Reject
+
class AbnormalStateTestFixture
{
-public:
+protected:
AbnormalStateTestFixture()
: context(Interest("/abnormal-state"), bind([]{}), bind([]{}))
{
}
-public:
+protected:
mgmt::StatusDatasetContext context;
};
@@ -283,6 +296,7 @@
}
BOOST_AUTO_TEST_SUITE_END() // AbnormalState
+
BOOST_AUTO_TEST_SUITE_END() // TestStatusDatasetContext
BOOST_AUTO_TEST_SUITE_END() // Mgmt