summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-01-05 21:12:43 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2016-01-05 21:15:24 +0000
commitb496888597a6bcc0617ca78dba55da7edcaaac06 (patch)
tree1c886e29a04554368602cb8d36432d5b126da468
parentSupport testing a resource validity on return to the pool (diff)
downloadlibadhocutil-b496888597a6bcc0617ca78dba55da7edcaaac06.tar.bz2
libadhocutil-b496888597a6bcc0617ca78dba55da7edcaaac06.tar.xz
libadhocutil-b496888597a6bcc0617ca78dba55da7edcaaac06.zip
Test with a class that has suitable semantics instead of a POD type
-rw-r--r--libadhocutil/unittests/testCache.cpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/libadhocutil/unittests/testCache.cpp b/libadhocutil/unittests/testCache.cpp
index 6520aa3..650e3c7 100644
--- a/libadhocutil/unittests/testCache.cpp
+++ b/libadhocutil/unittests/testCache.cpp
@@ -9,12 +9,34 @@
BOOST_TEST_DONT_PRINT_LOG_VALUE(std::nullptr_t);
// LCOV_EXCL_STOP
+class Obj {
+ public:
+ Obj(int i) : v(i) { }
+ bool operator==(const int & i) const {
+ return v == i;
+ }
+ int v;
+};
+
+bool
+operator==(const int & i, const Obj & o)
+{
+ return i == o.v;
+}
+
+namespace std {
+ ostream & operator<<(ostream & s, const Obj & o)
+ {
+ return s << o.v;
+ }
+}
+
namespace AdHoc {
- typedef Cache<int, std::string> TestCache;
- template class Cache<int, std::string>;
- template class Cacheable<int, std::string>;
- template class ObjectCacheable<int, std::string>;
- template class CallCacheable<int, std::string>;
+ typedef Cache<Obj, std::string> TestCache;
+ template class Cache<Obj, std::string>;
+ template class Cacheable<Obj, std::string>;
+ template class ObjectCacheable<Obj, std::string>;
+ template class CallCacheable<Obj, std::string>;
}
using namespace AdHoc;