summaryrefslogtreecommitdiff
path: root/libadhocutil/unittests/testLazyPointer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libadhocutil/unittests/testLazyPointer.cpp')
-rw-r--r--libadhocutil/unittests/testLazyPointer.cpp50
1 files changed, 26 insertions, 24 deletions
diff --git a/libadhocutil/unittests/testLazyPointer.cpp b/libadhocutil/unittests/testLazyPointer.cpp
index 31b92a5..df9c257 100644
--- a/libadhocutil/unittests/testLazyPointer.cpp
+++ b/libadhocutil/unittests/testLazyPointer.cpp
@@ -6,12 +6,9 @@
using namespace AdHoc;
class Test {
- public:
- explicit Test(int v) :
- val(v)
- {
- }
- const int val;
+public:
+ explicit Test(int v) : val(v) { }
+ const int val;
};
using TestLazyPointer = LazyPointer<Test>;
@@ -22,23 +19,23 @@ BOOST_TEST_DONT_PRINT_LOG_VALUE(TestLazyPointer);
BOOST_TEST_DONT_PRINT_LOG_VALUE(RawLazyPointer);
/// LCOV_EXCL_STOP
-static
-TestLazyPointer::pointer_type
+static TestLazyPointer::pointer_type
factory()
{
return std::make_shared<Test>(3);
}
-static
-TestLazyPointer::pointer_type
+static TestLazyPointer::pointer_type
paramFactory(const std::string & str)
{
return std::make_shared<Test>(str.length());
}
-BOOST_AUTO_TEST_CASE ( islazy )
+BOOST_AUTO_TEST_CASE(islazy)
{
- TestLazyPointer p([]{ return factory(); });
+ TestLazyPointer p([] {
+ return factory();
+ });
BOOST_REQUIRE_EQUAL(false, p.hasValue());
Test * t = p.get();
BOOST_REQUIRE(t);
@@ -49,40 +46,44 @@ BOOST_AUTO_TEST_CASE ( islazy )
BOOST_REQUIRE_EQUAL(3, p->val);
}
-BOOST_AUTO_TEST_CASE ( preinit )
+BOOST_AUTO_TEST_CASE(preinit)
{
Test * t = new Test(4);
- TestLazyPointer p(TestLazyPointer::pointer_type{ t });
+ TestLazyPointer p(TestLazyPointer::pointer_type {t});
BOOST_REQUIRE_EQUAL(true, p.hasValue());
BOOST_REQUIRE_EQUAL(p, t);
BOOST_REQUIRE_EQUAL(4, p->val);
}
-BOOST_AUTO_TEST_CASE ( reset )
+BOOST_AUTO_TEST_CASE(reset)
{
Test * t = new Test(4);
- TestLazyPointer p(TestLazyPointer::pointer_type{ t });
+ TestLazyPointer p(TestLazyPointer::pointer_type {t});
BOOST_REQUIRE_EQUAL(true, p.hasValue());
BOOST_REQUIRE_EQUAL(4, p->val);
p = nullptr;
BOOST_REQUIRE_EQUAL(true, p.hasValue());
BOOST_REQUIRE_EQUAL(true, !p);
- p = []{ return factory(); };
+ p = [] {
+ return factory();
+ };
BOOST_REQUIRE_EQUAL(false, p.hasValue());
BOOST_REQUIRE(p.get());
BOOST_REQUIRE_EQUAL(true, p.hasValue());
BOOST_REQUIRE_EQUAL(3, p->val);
}
-BOOST_AUTO_TEST_CASE ( nondefault )
+BOOST_AUTO_TEST_CASE(nondefault)
{
- TestLazyPointer p([]{ return paramFactory("some string"); });
+ TestLazyPointer p([] {
+ return paramFactory("some string");
+ });
BOOST_REQUIRE_EQUAL(false, p.hasValue());
BOOST_REQUIRE_EQUAL(11, (*p).val);
BOOST_REQUIRE_EQUAL(true, p.hasValue());
}
-BOOST_AUTO_TEST_CASE( rawPointerNull )
+BOOST_AUTO_TEST_CASE(rawPointerNull)
{
RawLazyPointer null;
BOOST_REQUIRE(null.hasValue());
@@ -90,7 +91,7 @@ BOOST_AUTO_TEST_CASE( rawPointerNull )
BOOST_REQUIRE(!null.get());
}
-BOOST_AUTO_TEST_CASE( rawPointerNonNull )
+BOOST_AUTO_TEST_CASE(rawPointerNonNull)
{
RawLazyPointer value(new int(3));
BOOST_REQUIRE(value.hasValue());
@@ -108,12 +109,13 @@ rawFactory(const std::string & s)
return new int(s.length());
}
-BOOST_AUTO_TEST_CASE( rawPointerFactory )
+BOOST_AUTO_TEST_CASE(rawPointerFactory)
{
- RawLazyPointer value([]{ return rawFactory(std::string("four")); });
+ RawLazyPointer value([] {
+ return rawFactory(std::string("four"));
+ });
BOOST_REQUIRE(!value.hasValue());
BOOST_REQUIRE_EQUAL(*value, 4);
BOOST_REQUIRE(value.hasValue());
delete (int *)value;
}
-