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. 24
      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;
}; };

24
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) {

Loading…
Cancel
Save