Browse Source

Added some basic tests, minor compilation fix

master
Jessica James 5 years ago
parent
commit
7765f6eb1d
  1. 3
      src/include/object.hpp
  2. 28
      src/test/object.cpp

3
src/include/object.hpp

@ -72,8 +72,7 @@ public:
template<typename T> template<typename T>
struct is_backing<T, typename std::enable_if<is_associative_container<T>::value>::type> { struct is_backing<T, typename std::enable_if<is_associative_container<T>::value>::type> {
static constexpr bool value = std::is_same<typename is_associative_container<T>::key_type, std::string>::value static constexpr bool value = std::is_same<typename is_associative_container<T>::key_type, std::string>::value;
&& std::is_same<typename is_associative_container<T>::value_type, object>::value;
using type = map_t; using type = map_t;
}; };

28
src/test/object.cpp

@ -148,6 +148,30 @@ TEST(ObjectTest, basic_has_unordered_set) {
EXPECT_FALSE(obj.has<std::unordered_set<object>>()); EXPECT_FALSE(obj.has<std::unordered_set<object>>());
} }
using map_str_str = std::map<std::string, std::string>;
using map_str_strv = std::map<std::string, std::string_view>;
using map_str_obj = std::map<std::string, object>;
using unordered_map_str_str = std::unordered_map<std::string, std::string>;
using unordered_map_str_strv = std::unordered_map<std::string, std::string_view>;
using unordered_map_str_obj = std::unordered_map<std::string, object>;
TEST(ObjectTest, basic_has_map) {
object obj;
EXPECT_FALSE(obj.has<map_str_str>());
EXPECT_FALSE(obj.has<map_str_strv>());
EXPECT_FALSE(obj.has<map_str_obj>());
}
TEST(ObjectTest, basic_has_unordered_map) {
object obj;
EXPECT_FALSE(obj.has<unordered_map_str_str>());
EXPECT_FALSE(obj.has<unordered_map_str_strv>());
EXPECT_FALSE(obj.has<unordered_map_str_obj>());
}
/** basic_get tests */ /** basic_get tests */
TEST(ObjectTest, basic_get) { TEST(ObjectTest, basic_get) {
@ -301,7 +325,7 @@ TEST(ObjectTest, basic_get_unordered_multiset) {
{ object test_object__{ in_type {} }; \ { object test_object__{ in_type {} }; \
EXPECT_TRUE(test_object__ .has< in_type >()); \ EXPECT_TRUE(test_object__ .has< in_type >()); \
EXPECT_EQ(test_object__.get< in_type >(), in_type {} ); } EXPECT_EQ(test_object__.get< in_type >(), in_type {} ); }
// asdf // asdf
TEST(ObjectTest, basic_value_constructor) { TEST(ObjectTest, basic_value_constructor) {
@ -445,7 +469,7 @@ TEST(ObjectTest, basic_value_constructor_unordered_multiset) {
OBJECT_BASIC_VALUE_CONSTRUCTOR_TEST(std::unordered_multiset<std::string>); OBJECT_BASIC_VALUE_CONSTRUCTOR_TEST(std::unordered_multiset<std::string>);
OBJECT_BASIC_VALUE_CONSTRUCTOR_TEST(std::unordered_set<object>); OBJECT_BASIC_VALUE_CONSTRUCTOR_TEST(std::unordered_set<object>);
} }
/** basic_set */ /** basic_set */
#define OBJECT_BASIC_SET_TEST(in_object, in_type) \ #define OBJECT_BASIC_SET_TEST(in_object, in_type) \

Loading…
Cancel
Save