tests: respect naming conventions and improve nesting of some test suites
Change-Id: I255c27b552b32570871a9d5f8bda814ba8723c80
Refs: #2497
diff --git a/tests/unit-tests/util/config-file.t.cpp b/tests/unit-tests/util/config-file.t.cpp
index af03156..e72d0f2 100644
--- a/tests/unit-tests/util/config-file.t.cpp
+++ b/tests/unit-tests/util/config-file.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -20,79 +20,51 @@
*/
#include "util/config-file.hpp"
-#include "../util/test-home-environment-fixture.hpp"
-
-#include <cstdlib>
+#include "../test-home-env-saver.hpp"
#include "boost-test.hpp"
+#include <cstdlib>
+
namespace ndn {
namespace tests {
-BOOST_FIXTURE_TEST_SUITE(UtilConfigFile, util::TestHomeEnvironmentFixture)
+BOOST_AUTO_TEST_SUITE(Util)
+BOOST_FIXTURE_TEST_SUITE(TestConfigFile, TestHomeEnvSaver)
-BOOST_AUTO_TEST_CASE(TestParse)
+BOOST_AUTO_TEST_CASE(Parse)
{
- using namespace boost::filesystem;
- // std::cerr << "current home = " << std::getenv("TEST_HOME") << std::endl;
+ namespace fs = boost::filesystem;
setenv("TEST_HOME", "tests/unit-tests/util/config-file-home", 1);
- path homePath(absolute(std::getenv("TEST_HOME")));
+ fs::path homePath(fs::absolute(std::getenv("TEST_HOME")));
homePath /= ".ndn/client.conf";
- try
- {
- ConfigFile config;
+ ConfigFile config;
+ BOOST_REQUIRE_EQUAL(config.getPath(), homePath);
- BOOST_REQUIRE_EQUAL(config.getPath(), homePath);
-
- const ConfigFile::Parsed& parsed = config.getParsedConfiguration();
- BOOST_CHECK_EQUAL(parsed.get<std::string>("a"), "/path/to/nowhere");
- BOOST_CHECK_EQUAL(parsed.get<std::string>("b"), "some-othervalue.01");
- }
- catch (const std::runtime_error& error)
- {
- BOOST_FAIL("Unexpected exception: " << error.what());
- }
+ const ConfigFile::Parsed& parsed = config.getParsedConfiguration();
+ BOOST_CHECK_EQUAL(parsed.get<std::string>("a"), "/path/to/nowhere");
+ BOOST_CHECK_EQUAL(parsed.get<std::string>("b"), "some-othervalue.01");
}
-BOOST_AUTO_TEST_CASE(EmptyPathParse)
+BOOST_AUTO_TEST_CASE(ParseEmptyPath)
{
- // std::cerr << "current home = " << std::getenv("TEST_HOME") << std::endl;
-
setenv("TEST_HOME", "tests/unit-tests/util/does/not/exist", 1);
- try
- {
- ConfigFile config;
- }
- catch (const std::runtime_error& error)
- {
- BOOST_FAIL("Unexpected exception: " << error.what());
- }
+
+ BOOST_CHECK_NO_THROW(ConfigFile config);
}
-BOOST_AUTO_TEST_CASE(MalformedParse)
+BOOST_AUTO_TEST_CASE(ParseMalformed)
{
- using namespace boost::filesystem;
- // std::cerr << "current home = " << std::getenv("TEST_HOME") << std::endl;
-
setenv("TEST_HOME", "tests/unit-tests/util/config-file-malformed-home", 1);
- bool fileWasMalformed = false;
- try
- {
- ConfigFile config;
- }
- catch (const ConfigFile::Error& error)
- {
- fileWasMalformed = true;
- }
-
- BOOST_REQUIRE(fileWasMalformed);
+ BOOST_CHECK_THROW(ConfigFile config, ConfigFile::Error);
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestConfigFile
+BOOST_AUTO_TEST_SUITE_END() // Util
} // namespace tests
} // namespace ndn
diff --git a/tests/unit-tests/util/digest.t.cpp b/tests/unit-tests/util/digest.t.cpp
index 62be5d4..25f75dd 100644
--- a/tests/unit-tests/util/digest.t.cpp
+++ b/tests/unit-tests/util/digest.t.cpp
@@ -29,7 +29,8 @@
namespace util {
namespace test {
-BOOST_AUTO_TEST_SUITE(UtilDigest)
+BOOST_AUTO_TEST_SUITE(Util)
+BOOST_AUTO_TEST_SUITE(TestDigest)
BOOST_AUTO_TEST_CASE(Sha256Digest)
{
@@ -185,7 +186,6 @@
digest2->buf() + digest2->size());
}
-
BOOST_AUTO_TEST_CASE(Error)
{
uint64_t origin = 256;
@@ -234,7 +234,8 @@
BOOST_CHECK_EQUAL(digest.toString(), hexString);
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestDigest
+BOOST_AUTO_TEST_SUITE_END() // Util
} // namespace test
} // namespace util
diff --git a/tests/unit-tests/util/dns.t.cpp b/tests/unit-tests/util/dns.t.cpp
index be94ba9..e76d593 100644
--- a/tests/unit-tests/util/dns.t.cpp
+++ b/tests/unit-tests/util/dns.t.cpp
@@ -24,8 +24,7 @@
#include "boost-test.hpp"
#include "../network-configuration-detector.hpp"
-#include <boost/asio.hpp>
-#include <boost/lexical_cast.hpp>
+#include <boost/asio/io_service.hpp>
namespace ndn {
namespace util {
@@ -51,24 +50,19 @@
bool isValid,
bool shouldCheckAddress = false)
{
- BOOST_TEST_MESSAGE("Resolved to: " << resolvedAddress);
-
++m_nSuccesses;
- if (!isValid)
- {
- BOOST_FAIL("Resolved to " + boost::lexical_cast<std::string>(resolvedAddress)
- + ", but should have failed");
- }
+ if (!isValid) {
+ BOOST_FAIL("Resolved to " + resolvedAddress.to_string() + ", but should have failed");
+ }
BOOST_CHECK_EQUAL(resolvedAddress.is_v4(), expectedAddress.is_v4());
// checking address is not deterministic and should be enabled only
// if only one IP address will be returned by resolution
- if (shouldCheckAddress)
- {
- BOOST_CHECK_EQUAL(resolvedAddress, expectedAddress);
- }
+ if (shouldCheckAddress) {
+ BOOST_CHECK_EQUAL(resolvedAddress, expectedAddress);
+ }
}
void
@@ -76,27 +70,26 @@
{
++m_nFailures;
- if (!isValid)
- {
- BOOST_FAIL("Resolution should not have failed");
- }
+ if (!isValid) {
+ BOOST_FAIL("Resolution should not have failed");
+ }
BOOST_CHECK_MESSAGE(true, "Resolution failed as expected");
}
-public:
+protected:
uint32_t m_nFailures;
uint32_t m_nSuccesses;
-
boost::asio::io_service m_ioService;
};
-BOOST_FIXTURE_TEST_SUITE(UtilDns, DnsFixture)
+BOOST_AUTO_TEST_SUITE(Util)
+BOOST_FIXTURE_TEST_SUITE(TestDns, DnsFixture)
BOOST_AUTO_TEST_CASE(Asynchronous)
{
if (!NetworkConfigurationDetector::hasIpv4() && !NetworkConfigurationDetector::hasIpv6()) {
- BOOST_TEST_MESSAGE("Platform does not support both IPv4 and IPv6, skipping test case");
+ BOOST_WARN_MESSAGE(false, "skipping assertions that require either IPv4 or IPv6 support");
return;
}
@@ -113,10 +106,7 @@
BOOST_AUTO_TEST_CASE(AsynchronousV4)
{
- if (!NetworkConfigurationDetector::hasIpv4()) {
- BOOST_TEST_MESSAGE("Platform does not support IPv4, skipping the test case");
- return;
- }
+ SKIP_IF_IPV4_UNAVAILABLE();
dns::asyncResolve("192.0.2.1",
bind(&DnsFixture::onSuccess, this, _1,
@@ -132,10 +122,7 @@
BOOST_AUTO_TEST_CASE(AsynchronousV6)
{
- if (!NetworkConfigurationDetector::hasIpv6()) {
- BOOST_TEST_MESSAGE("Platform does not support IPv6, skipping the test case");
- return;
- }
+ SKIP_IF_IPV6_UNAVAILABLE();
dns::asyncResolve("ipv6.google.com", // only IPv6 address should be available
bind(&DnsFixture::onSuccess, this, _1,
@@ -158,10 +145,8 @@
BOOST_AUTO_TEST_CASE(AsynchronousV4AndV6)
{
- if (!NetworkConfigurationDetector::hasIpv4() || !NetworkConfigurationDetector::hasIpv6()) {
- BOOST_TEST_MESSAGE("Platform does not support either IPv4 or IPv6, skipping test case");
- return;
- }
+ SKIP_IF_IPV4_UNAVAILABLE();
+ SKIP_IF_IPV6_UNAVAILABLE();
dns::asyncResolve("www.named-data.net",
bind(&DnsFixture::onSuccess, this, _1,
@@ -206,7 +191,7 @@
BOOST_AUTO_TEST_CASE(Synchronous)
{
if (!NetworkConfigurationDetector::hasIpv4() && !NetworkConfigurationDetector::hasIpv6()) {
- BOOST_TEST_MESSAGE("Platform does not support both IPv4 and IPv6, skipping test case");
+ BOOST_WARN_MESSAGE(false, "skipping assertions that require either IPv4 or IPv6 support");
return;
}
dns::IpAddress address;
@@ -215,7 +200,8 @@
BOOST_CHECK(address.is_v4() || address.is_v6());
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestDns
+BOOST_AUTO_TEST_SUITE_END() // Util
} // namespace tests
} // namespace util
diff --git a/tests/unit-tests/util/ethernet.t.cpp b/tests/unit-tests/util/ethernet.t.cpp
index 9b7aa35..e8e59e5 100644
--- a/tests/unit-tests/util/ethernet.t.cpp
+++ b/tests/unit-tests/util/ethernet.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California,
+ * Copyright (c) 2013-2016 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -33,9 +33,10 @@
namespace util {
namespace tests {
-BOOST_AUTO_TEST_SUITE(UtilEthernet)
+BOOST_AUTO_TEST_SUITE(Util)
+BOOST_AUTO_TEST_SUITE(TestEthernet)
-BOOST_AUTO_TEST_CASE(BasicChecks)
+BOOST_AUTO_TEST_CASE(Basic)
{
ethernet::Address a;
BOOST_CHECK(a.isNull());
@@ -110,7 +111,8 @@
BOOST_CHECK_NO_THROW(h(ethernet::getDefaultMulticastAddress()));
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestEthernet
+BOOST_AUTO_TEST_SUITE_END() // Util
} // namespace tests
} // namespace util
diff --git a/tests/unit-tests/util/face-uri.t.cpp b/tests/unit-tests/util/face-uri.t.cpp
index b860e2f..6cf52d9 100644
--- a/tests/unit-tests/util/face-uri.t.cpp
+++ b/tests/unit-tests/util/face-uri.t.cpp
@@ -36,7 +36,8 @@
using ndn::tests::NetworkConfigurationDetector;
-BOOST_AUTO_TEST_SUITE(UtilFaceUri)
+BOOST_AUTO_TEST_SUITE(Util)
+BOOST_AUTO_TEST_SUITE(TestFaceUri)
class CanonizeFixture : noncopyable
{
@@ -196,10 +197,7 @@
BOOST_FIXTURE_TEST_CASE(CanonizeUdpV4, CanonizeFixture)
{
- if (!NetworkConfigurationDetector::hasIpv4()) {
- BOOST_TEST_MESSAGE("Platform does not support IPv4, skipping the test case");
- return;
- }
+ SKIP_IF_IPV4_UNAVAILABLE();
// IPv4 unicast
addTest("udp4://192.0.2.1:6363", true, "udp4://192.0.2.1:6363");
@@ -221,10 +219,7 @@
BOOST_FIXTURE_TEST_CASE(CanonizeUdpV6, CanonizeFixture)
{
- if (!NetworkConfigurationDetector::hasIpv6()) {
- BOOST_TEST_MESSAGE("Platform does not support IPv6, skipping the test case");
- return;
- }
+ SKIP_IF_IPV6_UNAVAILABLE();
// IPv6 unicast
addTest("udp6://[2001:db8::1]:6363", true, "udp6://[2001:db8::1]:6363");
@@ -287,10 +282,7 @@
BOOST_FIXTURE_TEST_CASE(CanonizeTcpV4, CanonizeFixture)
{
- if (!NetworkConfigurationDetector::hasIpv4()) {
- BOOST_TEST_MESSAGE("Platform does not support IPv4, skipping the test case");
- return;
- }
+ SKIP_IF_IPV4_UNAVAILABLE();
// IPv4 unicast
addTest("tcp4://192.0.2.1:6363", true, "tcp4://192.0.2.1:6363");
@@ -312,10 +304,7 @@
BOOST_FIXTURE_TEST_CASE(CanonizeTcpV6, CanonizeFixture)
{
- if (!NetworkConfigurationDetector::hasIpv6()) {
- BOOST_TEST_MESSAGE("Platform does not support IPv6, skipping the test case");
- return;
- }
+ SKIP_IF_IPV6_UNAVAILABLE();
// IPv6 unicast
addTest("tcp6://[2001:db8::1]:6363", true, "tcp6://[2001:db8::1]:6363");
@@ -486,6 +475,9 @@
io, time::milliseconds(1));
io.run(); // should not crash
+
+ // avoid "test case [...] did not check any assertions" message from Boost.Test
+ BOOST_CHECK(true);
}
BOOST_FIXTURE_TEST_CASE(CanonizeUnsupported, CanonizeFixture)
@@ -523,7 +515,8 @@
BOOST_CHECK_EQUAL(uri.toString(), "wsclient://76.90.11.239:56366");
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestFaceUri
+BOOST_AUTO_TEST_SUITE_END() // Util
} // namespace tests
} // namespace util
diff --git a/tests/unit-tests/util/in-memory-storage-common.t.cpp b/tests/unit-tests/util/in-memory-storage-common.t.cpp
index da87929..e6a3ab7 100644
--- a/tests/unit-tests/util/in-memory-storage-common.t.cpp
+++ b/tests/unit-tests/util/in-memory-storage-common.t.cpp
@@ -41,20 +41,15 @@
BOOST_AUTO_TEST_SUITE(TestInMemoryStorage)
BOOST_AUTO_TEST_SUITE(Common)
-typedef boost::mpl::list<InMemoryStoragePersistent, InMemoryStorageFifo, InMemoryStorageLfu,
- InMemoryStorageLru> InMemoryStorages;
+using InMemoryStorages = boost::mpl::list<InMemoryStoragePersistent,
+ InMemoryStorageFifo,
+ InMemoryStorageLfu,
+ InMemoryStorageLru>;
BOOST_AUTO_TEST_CASE_TEMPLATE(Insertion, T, InMemoryStorages)
{
T ims;
- ims.insert(*makeData("/insertion"));
-}
-
-BOOST_AUTO_TEST_CASE_TEMPLATE(Insertion2, T, InMemoryStorages)
-{
- T ims;
-
ims.insert(*makeData("/a"));
ims.insert(*makeData("/b"));
ims.insert(*makeData("/c"));
@@ -63,7 +58,7 @@
BOOST_CHECK_EQUAL(ims.size(), 4);
}
-BOOST_AUTO_TEST_CASE_TEMPLATE(Insertion3, T, InMemoryStorages)
+BOOST_AUTO_TEST_CASE_TEMPLATE(Insertion2, T, InMemoryStorages)
{
T ims;
@@ -347,6 +342,9 @@
shared_ptr<Data> data7 = makeData("/c/c/1");
ims.insert(*data7);
+
+ // avoid "test case [...] did not check any assertions" message from Boost.Test
+ BOOST_CHECK(true);
}
BOOST_AUTO_TEST_CASE_TEMPLATE(EraseCanonical, T, InMemoryStorages)
@@ -627,8 +625,9 @@
BOOST_CHECK_EQUAL(found3->getName(), "/c/a");
}
-typedef boost::mpl::list<InMemoryStorageFifo, InMemoryStorageLfu, InMemoryStorageLru>
- InMemoryStoragesLimited;
+using InMemoryStoragesLimited = boost::mpl::list<InMemoryStorageFifo,
+ InMemoryStorageLfu,
+ InMemoryStorageLru>;
BOOST_AUTO_TEST_CASE_TEMPLATE(SetCapacity, T, InMemoryStoragesLimited)
{
diff --git a/tests/unit-tests/util/indented-stream.t.cpp b/tests/unit-tests/util/indented-stream.t.cpp
index 91dff26..bc033ff 100644
--- a/tests/unit-tests/util/indented-stream.t.cpp
+++ b/tests/unit-tests/util/indented-stream.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -24,13 +24,14 @@
#include "boost-test.hpp"
#include <boost/test/output_test_stream.hpp>
-using boost::test_tools::output_test_stream;
-
namespace ndn {
namespace util {
namespace tests {
-BOOST_AUTO_TEST_SUITE(UtilIndentedStream)
+using boost::test_tools::output_test_stream;
+
+BOOST_AUTO_TEST_SUITE(Util)
+BOOST_AUTO_TEST_SUITE(TestIndentedStream)
BOOST_AUTO_TEST_CASE(Basic)
{
@@ -72,7 +73,8 @@
));
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestIndentedStream
+BOOST_AUTO_TEST_SUITE_END() // Util
} // namespace tests
} // namespace util
diff --git a/tests/unit-tests/util/notification-stream.t.cpp b/tests/unit-tests/util/notification-stream.t.cpp
index 8ac084a..8ec6c6f 100644
--- a/tests/unit-tests/util/notification-stream.t.cpp
+++ b/tests/unit-tests/util/notification-stream.t.cpp
@@ -36,7 +36,8 @@
namespace util {
namespace tests {
-BOOST_FIXTURE_TEST_SUITE(UtilNotificationStream, ndn::tests::IdentityManagementTimeFixture)
+BOOST_AUTO_TEST_SUITE(Util)
+BOOST_FIXTURE_TEST_SUITE(TestNotificationStream, ndn::tests::IdentityManagementTimeFixture)
BOOST_AUTO_TEST_CASE(Post)
{
@@ -69,7 +70,8 @@
BOOST_CHECK_EQUAL(decoded2.getMessage(), "msg2");
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestNotificationStream
+BOOST_AUTO_TEST_SUITE_END() // Util
} // namespace tests
} // namespace util
diff --git a/tests/unit-tests/util/regex.t.cpp b/tests/unit-tests/util/regex.t.cpp
index e7cdea5..fc46c23 100644
--- a/tests/unit-tests/util/regex.t.cpp
+++ b/tests/unit-tests/util/regex.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -37,11 +37,11 @@
using std::string;
-BOOST_AUTO_TEST_SUITE(UtilRegex)
+BOOST_AUTO_TEST_SUITE(Util)
+BOOST_AUTO_TEST_SUITE(TestRegex)
BOOST_AUTO_TEST_CASE(ComponentMatcher)
{
-
shared_ptr<RegexBackrefManager> backRef = make_shared<RegexBackrefManager>();
shared_ptr<RegexComponentMatcher> cm = make_shared<RegexComponentMatcher>("a", backRef);
bool res = cm->match(Name("/a/b/"), 0, 1);
@@ -69,7 +69,6 @@
BOOST_AUTO_TEST_CASE(ComponentSetMatcher)
{
-
shared_ptr<RegexBackrefManager> backRef = make_shared<RegexBackrefManager>();
shared_ptr<RegexComponentSetMatcher> cm = make_shared<RegexComponentSetMatcher>("<a>", backRef);
bool res = cm->match(Name("/a/b/"), 0, 1);
@@ -102,12 +101,10 @@
BOOST_CHECK_EQUAL(res, true);
BOOST_CHECK_EQUAL(cm->getMatchResult().size(), 1);
BOOST_CHECK_EQUAL(cm->getMatchResult()[0].toUri(), string("d"));
-
}
BOOST_AUTO_TEST_CASE(RepeatMatcher)
{
-
shared_ptr<RegexBackrefManager> backRef = make_shared<RegexBackrefManager>();
shared_ptr<RegexRepeatMatcher> cm = make_shared<RegexRepeatMatcher>("[<a><b>]*", backRef, 8);
bool res = cm->match(Name("/a/b/c"), 0, 0);
@@ -120,8 +117,6 @@
BOOST_CHECK_EQUAL(cm->getMatchResult()[0].toUri(), string("a"));
BOOST_CHECK_EQUAL(cm->getMatchResult()[1].toUri(), string("b"));
-
-
backRef = make_shared<RegexBackrefManager>();
cm = make_shared<RegexRepeatMatcher>("[<a><b>]+", backRef, 8);
res = cm->match(Name("/a/b/c"), 0, 0);
@@ -134,8 +129,6 @@
BOOST_CHECK_EQUAL(cm->getMatchResult()[0].toUri(), string("a"));
BOOST_CHECK_EQUAL(cm->getMatchResult()[1].toUri(), string("b"));
-
-
backRef = make_shared<RegexBackrefManager>();
cm = make_shared<RegexRepeatMatcher>("<.*>*", backRef, 4);
res = cm->match(Name("/a/b/c/d/e/f/"), 0, 6);
@@ -148,8 +141,6 @@
BOOST_CHECK_EQUAL(cm->getMatchResult()[4].toUri(), string("e"));
BOOST_CHECK_EQUAL(cm->getMatchResult()[5].toUri(), string("f"));
-
-
backRef = make_shared<RegexBackrefManager>();
cm = make_shared<RegexRepeatMatcher>("<>*", backRef, 2);
res = cm->match(Name("/a/b/c/d/e/f/"), 0, 6);
@@ -162,8 +153,6 @@
BOOST_CHECK_EQUAL(cm->getMatchResult()[4].toUri(), string("e"));
BOOST_CHECK_EQUAL(cm->getMatchResult()[5].toUri(), string("f"));
-
-
backRef = make_shared<RegexBackrefManager>();
cm = make_shared<RegexRepeatMatcher>("<a>?", backRef, 3);
res = cm->match(Name("/a/b/c"), 0, 0);
@@ -181,8 +170,6 @@
BOOST_CHECK_EQUAL(res, false);
BOOST_CHECK_EQUAL(cm->getMatchResult().size(), 0);
-
-
backRef = make_shared<RegexBackrefManager>();
cm = make_shared<RegexRepeatMatcher>("[<a><b>]{3}", backRef, 8);
res = cm->match(Name("/a/b/a/d/"), 0, 2);
@@ -200,8 +187,6 @@
BOOST_CHECK_EQUAL(res, false);
BOOST_CHECK_EQUAL(cm->getMatchResult().size(), 0);
-
-
backRef = make_shared<RegexBackrefManager>();
cm = make_shared<RegexRepeatMatcher>("[<a><b>]{2,3}", backRef, 8);
res = cm->match(Name("/a/b/a/d/e/"), 0, 2);
@@ -225,7 +210,6 @@
BOOST_CHECK_EQUAL(res, false);
BOOST_CHECK_EQUAL(cm->getMatchResult().size(), 0);
-
backRef = make_shared<RegexBackrefManager>();
cm = make_shared<RegexRepeatMatcher>("[<a><b>]{2,}", backRef, 8);
res = cm->match(Name("/a/b/a/d/e/"), 0, 2);
@@ -246,8 +230,6 @@
BOOST_CHECK_EQUAL(res, false);
BOOST_CHECK_EQUAL(cm->getMatchResult().size(), 0);
-
-
backRef = make_shared<RegexBackrefManager>();
cm = make_shared<RegexRepeatMatcher>("[<a><b>]{,2}", backRef, 8);
res = cm->match(Name("/a/b/a/b/e/"), 0, 3);
@@ -272,7 +254,6 @@
BOOST_AUTO_TEST_CASE(BackRefMatcher)
{
-
shared_ptr<RegexBackrefManager> backRef = make_shared<RegexBackrefManager>();
shared_ptr<RegexBackrefMatcher> cm = make_shared<RegexBackrefMatcher>("(<a><b>)", backRef);
backRef->pushRef(static_pointer_cast<RegexMatcher>(cm));
@@ -301,7 +282,6 @@
BOOST_AUTO_TEST_CASE(BackRefMatcherAdvanced)
{
-
shared_ptr<RegexBackrefManager> backRef = make_shared<RegexBackrefManager>();
shared_ptr<RegexRepeatMatcher> cm = make_shared<RegexRepeatMatcher>("([<a><b>])+", backRef, 10);
bool res = cm->match(Name("/a/b/c"), 0, 2);
@@ -315,7 +295,6 @@
BOOST_AUTO_TEST_CASE(BackRefMatcherAdvanced2)
{
-
shared_ptr<RegexBackrefManager> backRef = make_shared<RegexBackrefManager>();
shared_ptr<RegexPatternListMatcher> cm = make_shared<RegexPatternListMatcher>("(<a>(<b>))<c>", backRef);
bool res = cm->match(Name("/a/b/c"), 0, 3);
@@ -332,7 +311,6 @@
BOOST_AUTO_TEST_CASE(PatternListMatcher)
{
-
shared_ptr<RegexBackrefManager> backRef = make_shared<RegexBackrefManager>();
shared_ptr<RegexPatternListMatcher> cm = make_shared<RegexPatternListMatcher>("<a>[<a><b>]", backRef);
bool res = cm->match(Name("/a/b/c"), 0, 2);
@@ -362,12 +340,10 @@
BOOST_CHECK_EQUAL(cm->getMatchResult()[0].toUri(), string("a"));
BOOST_CHECK_EQUAL(cm->getMatchResult()[1].toUri(), string("b"));
BOOST_CHECK_EQUAL(cm->getMatchResult()[2].toUri(), string("c"));
-
}
BOOST_AUTO_TEST_CASE(TopMatcher)
{
-
shared_ptr<RegexTopMatcher> cm = make_shared<RegexTopMatcher>("^<a><b><c>");
bool res = cm->match(Name("/a/b/c/d"));
BOOST_CHECK_EQUAL(res, true);
@@ -408,7 +384,6 @@
BOOST_CHECK_EQUAL(cm->getMatchResult()[2].toUri(), string("c"));
BOOST_CHECK_EQUAL(cm->getMatchResult()[3].toUri(), string("d"));
-
cm = make_shared<RegexTopMatcher>("<b><c>");
res = cm->match(Name("/a/b/c/d"));
BOOST_CHECK_EQUAL(res, true);
@@ -464,7 +439,8 @@
BOOST_CHECK_EQUAL(cm->expand(), Name("/ndn/edu/ucla/yingdi/mac/"));
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestRegex
+BOOST_AUTO_TEST_SUITE_END() // Util
} // namespace tests
} // namespace ndn
diff --git a/tests/unit-tests/util/scheduler.t.cpp b/tests/unit-tests/util/scheduler.t.cpp
index 72db284..8189f01 100644
--- a/tests/unit-tests/util/scheduler.t.cpp
+++ b/tests/unit-tests/util/scheduler.t.cpp
@@ -48,6 +48,8 @@
BOOST_AUTO_TEST_SUITE(Util)
BOOST_FIXTURE_TEST_SUITE(TestScheduler, SchedulerFixture)
+BOOST_AUTO_TEST_SUITE(General)
+
BOOST_AUTO_TEST_CASE(Events)
{
size_t count1 = 0;
@@ -97,6 +99,9 @@
{
EventId i;
scheduler.cancelEvent(i);
+
+ // avoid "test case [...] did not check any assertions" message from Boost.Test
+ BOOST_CHECK(true);
}
BOOST_AUTO_TEST_CASE(SelfCancel)
@@ -233,8 +238,13 @@
eid = sched.scheduleEvent(time::milliseconds(10), []{});
sched.cancelAllEvents();
eid.cancel(); // should not crash
+
+ // avoid "test case [...] did not check any assertions" message from Boost.Test
+ BOOST_CHECK(true);
}
+BOOST_AUTO_TEST_SUITE_END() // General
+
BOOST_AUTO_TEST_SUITE(EventId)
using scheduler::EventId;
@@ -243,6 +253,9 @@
{
EventId eid;
eid = nullptr;
+
+ // avoid "test case [...] did not check any assertions" message from Boost.Test
+ BOOST_CHECK(true);
}
BOOST_AUTO_TEST_CASE(Compare)
diff --git a/tests/unit-tests/util/signal.t.cpp b/tests/unit-tests/util/signal.t.cpp
index c06c4ac..eb02324 100644
--- a/tests/unit-tests/util/signal.t.cpp
+++ b/tests/unit-tests/util/signal.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -28,7 +28,8 @@
namespace signal {
namespace tests {
-BOOST_AUTO_TEST_SUITE(UtilSignal)
+BOOST_AUTO_TEST_SUITE(Util)
+BOOST_AUTO_TEST_SUITE(TestSignal)
class SignalOwner0
{
@@ -420,7 +421,8 @@
BOOST_CHECK_EQUAL(hit, 2); // handler called
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestSignal
+BOOST_AUTO_TEST_SUITE_END() // Util
} // namespace tests
} // namespace signal
diff --git a/tests/unit-tests/util/simple-notification.hpp b/tests/unit-tests/util/simple-notification.hpp
index 66e4641..ce6ec90 100644
--- a/tests/unit-tests/util/simple-notification.hpp
+++ b/tests/unit-tests/util/simple-notification.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California,
+ * Copyright (c) 2014-2016, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -25,8 +25,8 @@
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
*/
-#ifndef NDN_UNIT_TESTS_UTIL_SIMPLE_NOTIFICATION_HPP
-#define NDN_UNIT_TESTS_UTIL_SIMPLE_NOTIFICATION_HPP
+#ifndef NDN_TESTS_UNIT_TESTS_UTIL_SIMPLE_NOTIFICATION_HPP
+#define NDN_TESTS_UNIT_TESTS_UTIL_SIMPLE_NOTIFICATION_HPP
#include "common.hpp"
@@ -40,9 +40,7 @@
class SimpleNotification
{
public:
- SimpleNotification()
- {
- }
+ SimpleNotification() = default;
explicit
SimpleNotification(const Block& block)
@@ -55,10 +53,6 @@
{
}
- ~SimpleNotification()
- {
- }
-
Block
wireEncode() const
{
@@ -80,7 +74,6 @@
BOOST_THROW_EXCEPTION(tlv::Error("0x07 error"));
}
-public:
const std::string&
getMessage() const
{
@@ -101,4 +94,4 @@
} // namespace util
} // namespace ndn
-#endif // NDN_UNIT_TESTS_UTIL_CORE_SIMPLE_NOTIFICATION_HPP
+#endif // NDN_TESTS_UNIT_TESTS_UTIL_SIMPLE_NOTIFICATION_HPP
diff --git a/tests/unit-tests/util/sqlite3-statement.t.cpp b/tests/unit-tests/util/sqlite3-statement.t.cpp
index a7fa29a..b440f7a 100644
--- a/tests/unit-tests/util/sqlite3-statement.t.cpp
+++ b/tests/unit-tests/util/sqlite3-statement.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -21,9 +21,9 @@
#include "util/sqlite3-statement.hpp"
-#include <boost/filesystem.hpp>
#include "boost-test.hpp"
+#include <boost/filesystem.hpp>
#include <sqlite3.h>
namespace ndn {
@@ -64,7 +64,8 @@
sqlite3* db;
};
-BOOST_FIXTURE_TEST_SUITE(UtilSqlite3Statement, Sqlite3StatementTestFixture)
+BOOST_AUTO_TEST_SUITE(Util)
+BOOST_FIXTURE_TEST_SUITE(TestSqlite3Statement, Sqlite3StatementTestFixture)
BOOST_AUTO_TEST_CASE(Basic)
{
@@ -149,7 +150,8 @@
}
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestSqlite3Statement
+BOOST_AUTO_TEST_SUITE_END() // Util
} // namespace tests
} // namespace util
diff --git a/tests/unit-tests/util/string-helper.t.cpp b/tests/unit-tests/util/string-helper.t.cpp
index 82c30d7..22e8659 100644
--- a/tests/unit-tests/util/string-helper.t.cpp
+++ b/tests/unit-tests/util/string-helper.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -22,13 +22,13 @@
#include "util/string-helper.hpp"
#include "boost-test.hpp"
-#include <iostream>
namespace ndn {
namespace util {
namespace test {
-BOOST_AUTO_TEST_SUITE(UtilStringHelper)
+BOOST_AUTO_TEST_SUITE(Util)
+BOOST_AUTO_TEST_SUITE(TestStringHelper)
BOOST_AUTO_TEST_CASE(ToHex)
{
@@ -170,7 +170,8 @@
"\x01\x2a\x3b\xc4\xde\xfa\xb5\xcd\xef");
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestStringHelper
+BOOST_AUTO_TEST_SUITE_END() // Util
} // namespace test
} // namespace util
diff --git a/tests/unit-tests/util/test-home-environment-fixture.hpp b/tests/unit-tests/util/test-home-environment-fixture.hpp
deleted file mode 100644
index 4fd5dca..0000000
--- a/tests/unit-tests/util/test-home-environment-fixture.hpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2014 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- */
-
-#ifndef NDN_TESTS_UNIT_TESTS_UTIL_HOME_ENVIRONMENT_FIXTURE_HPP
-#define NDN_TESTS_UNIT_TESTS_UTIL_HOME_ENVIRONMENT_FIXTURE_HPP
-
-namespace ndn {
-namespace util {
-
-class TestHomeEnvironmentFixture
-{
-public:
- TestHomeEnvironmentFixture()
- {
- if (std::getenv("TEST_HOME"))
- m_HOME = std::getenv("TEST_HOME");
- }
-
- virtual
- ~TestHomeEnvironmentFixture()
- {
- if (!m_HOME.empty())
- setenv("TEST_HOME", m_HOME.c_str(), 1);
- else
- unsetenv("TEST_HOME");
- }
-
-protected:
- std::string m_HOME;
-};
-
-} // namespace tests
-} // namespace ndn
-
-#endif // NDN_TESTS_UNIT_TESTS_UTIL_HOME_ENVIRONMENT_FIXTURE_HPP
diff --git a/tests/unit-tests/util/time-unit-test-clock.t.cpp b/tests/unit-tests/util/time-unit-test-clock.t.cpp
index 658f043..17ceb39 100644
--- a/tests/unit-tests/util/time-unit-test-clock.t.cpp
+++ b/tests/unit-tests/util/time-unit-test-clock.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -23,35 +23,18 @@
#include "util/scheduler.hpp"
#include "boost-test.hpp"
+#include "../unit-test-time-fixture.hpp"
+
#include <boost/lexical_cast.hpp>
#include <thread>
namespace ndn {
namespace tests {
-BOOST_AUTO_TEST_SUITE(UtilTimeUnitTestClock)
+BOOST_AUTO_TEST_SUITE(Util)
+BOOST_FIXTURE_TEST_SUITE(TestTimeUnitTestClock, UnitTestTimeFixture)
-class UnitTestTimeFixture
-{
-public:
- UnitTestTimeFixture()
- : steadyClock(make_shared<time::UnitTestSteadyClock>())
- , systemClock(make_shared<time::UnitTestSystemClock>())
- {
- time::setCustomClocks(steadyClock, systemClock);
- }
-
- ~UnitTestTimeFixture()
- {
- time::setCustomClocks(nullptr, nullptr);
- }
-
-public:
- shared_ptr<time::UnitTestSteadyClock> steadyClock;
- shared_ptr<time::UnitTestSystemClock> systemClock;
-};
-
-BOOST_FIXTURE_TEST_CASE(SystemClock, UnitTestTimeFixture)
+BOOST_AUTO_TEST_CASE(SystemClock)
{
BOOST_CHECK_EQUAL(time::system_clock::now().time_since_epoch(),
time::UnitTestClockTraits<time::system_clock>::getDefaultStartTime());
@@ -106,7 +89,7 @@
time::fromUnixTimestamp(time::seconds(1390953600)));
}
-BOOST_FIXTURE_TEST_CASE(SteadyClock, UnitTestTimeFixture)
+BOOST_AUTO_TEST_CASE(SteadyClock)
{
BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(),
time::steady_clock::duration::zero());
@@ -132,9 +115,8 @@
"100 nanoseconds since unit test clock advancements");
}
-BOOST_FIXTURE_TEST_CASE(Scheduler, UnitTestTimeFixture)
+BOOST_AUTO_TEST_CASE(Scheduler)
{
- boost::asio::io_service io;
ndn::Scheduler scheduler(io);
bool hasFired = false;
@@ -149,7 +131,8 @@
BOOST_CHECK_EQUAL(hasFired, true);
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestTimeUnitTestClock
+BOOST_AUTO_TEST_SUITE_END() // Util
} // namespace tests
} // namespace ndn