#include "../traits.h" #include #include using namespace std; using namespace ReflectiveRapidJSON; // treat some types differently to test Treat... traits struct Foo { }; struct Bar { }; REFLECTIVE_RAPIDJSON_TREAT_AS_MAP_OR_HASH(Foo); REFLECTIVE_RAPIDJSON_TREAT_AS_MULTI_MAP_OR_HASH(Foo); REFLECTIVE_RAPIDJSON_TREAT_AS_SET(Bar); REFLECTIVE_RAPIDJSON_TREAT_AS_MULTI_SET(Foo); // test traits static_assert(IsArray>::value, "vector mapped to array"); static_assert(IsArray>::value, "list mapped to array"); static_assert(!IsArray>::value, "set not considered an array"); static_assert(!IsArray>::value, "multiset not considered an array"); static_assert(IsArrayOrSet>::value, "set is array or set"); static_assert(IsArrayOrSet>::value, "multiset is array or set"); static_assert(IsArrayOrSet::value, "Foo is array or set via TreatAsMultiSet"); static_assert(IsArrayOrSet::value, "Foo is array or set via TreatAsSet"); static_assert(!IsArrayOrSet::value, "string not mapped to array or set though it is iteratable"); static_assert(IsSet>::value, "set mapped to set"); static_assert(IsSet>::value, "unordered_set mapped to set"); static_assert(IsSet::value, "Bar mapped to set via TreatAsSet"); static_assert(!IsSet::value, "string not mapped to set"); static_assert(IsMultiSet>::value, "multiset"); static_assert(IsMultiSet::value, "Foo mapped to multiset via TreatAsMultiSet"); static_assert(!IsMultiSet::value, "string not mapped to multiset"); static_assert(!IsArray::value, "string not mapped to array though it is iteratable"); static_assert(IsMapOrHash>::value, "map mapped to object"); static_assert(IsMapOrHash>::value, "hash mapped to object"); static_assert(!IsMapOrHash>::value, "vector not mapped to object"); static_assert(IsMapOrHash::value, "Foo mapped to object via TreatAsMapOrHash"); static_assert(IsMultiMapOrHash>::value, "multimap mapped to object"); static_assert(IsMultiMapOrHash>::value, "unordered multimap mapped to object"); static_assert(!IsMultiMapOrHash>::value, "vector not mapped to object"); static_assert(IsMultiMapOrHash::value, "Foo mapped to object via TreatAsMultiMapOrHash"); static_assert(IsIteratableExceptString>::value, "vector is iteratable"); static_assert(!IsIteratableExceptString::value, "string not iteratable"); static_assert(!IsIteratableExceptString::value, "wstring not iteratable"); static_assert(!IsIteratableExceptString::value, "string not iteratable");