mirror of
https://github.com/tristanpenman/valijson.git
synced 2024-12-13 02:22:57 +01:00
Adapt existing tests to cover GenericRapidJsonAdapter when using a value type backed by RapidJson's CrtAllocator
This commit is contained in:
parent
414c46b423
commit
6546a9a945
@ -868,6 +868,19 @@ struct AdapterTraits<valijson::adapters::RapidJsonAdapter>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct AdapterTraits<valijson::adapters::GenericRapidJsonAdapter<
|
||||||
|
rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::CrtAllocator> > >
|
||||||
|
{
|
||||||
|
typedef rapidjson::GenericDocument<rapidjson::UTF8<>,
|
||||||
|
rapidjson::CrtAllocator> DocumentType;
|
||||||
|
|
||||||
|
static std::string adapterName()
|
||||||
|
{
|
||||||
|
return "GenericRapidJsonAdapter (using CrtAllocator)";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace adapters
|
} // namespace adapters
|
||||||
} // namespace valijson
|
} // namespace valijson
|
||||||
|
|
||||||
|
@ -125,6 +125,13 @@ TEST_F(TestAdapterComparison, JsonCppVsJsonCpp)
|
|||||||
valijson::adapters::JsonCppAdapter>();
|
valijson::adapters::JsonCppAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(TestAdapterComparison, JsonCppVsPicoJson)
|
||||||
|
{
|
||||||
|
testComparison<
|
||||||
|
valijson::adapters::JsonCppAdapter,
|
||||||
|
valijson::adapters::PicoJsonAdapter>();
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, JsonCppVsPropertyTree)
|
TEST_F(TestAdapterComparison, JsonCppVsPropertyTree)
|
||||||
{
|
{
|
||||||
testComparison<
|
testComparison<
|
||||||
@ -139,10 +146,19 @@ TEST_F(TestAdapterComparison, JsonCppVsRapidJson)
|
|||||||
valijson::adapters::RapidJsonAdapter>();
|
valijson::adapters::RapidJsonAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, JsonCppVsPicoJson)
|
TEST_F(TestAdapterComparison, JsonCppVsRapidJsonCrtAlloc)
|
||||||
{
|
{
|
||||||
testComparison<
|
testComparison<
|
||||||
valijson::adapters::JsonCppAdapter,
|
valijson::adapters::JsonCppAdapter,
|
||||||
|
valijson::adapters::GenericRapidJsonAdapter<
|
||||||
|
rapidjson::GenericValue<rapidjson::UTF8<>,
|
||||||
|
rapidjson::CrtAllocator> > >();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(TestAdapterComparison, PropertyTreeVsPicoJson)
|
||||||
|
{
|
||||||
|
testComparison<
|
||||||
|
valijson::adapters::PropertyTreeAdapter,
|
||||||
valijson::adapters::PicoJsonAdapter>();
|
valijson::adapters::PicoJsonAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,11 +176,13 @@ TEST_F(TestAdapterComparison, PropertyTreeVsRapidJson)
|
|||||||
valijson::adapters::RapidJsonAdapter>();
|
valijson::adapters::RapidJsonAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, PropertyTreeVsPicoJson)
|
TEST_F(TestAdapterComparison, PropertyTreeVsRapidJsonCrtAlloc)
|
||||||
{
|
{
|
||||||
testComparison<
|
testComparison<
|
||||||
valijson::adapters::PropertyTreeAdapter,
|
valijson::adapters::PropertyTreeAdapter,
|
||||||
valijson::adapters::PicoJsonAdapter>();
|
valijson::adapters::GenericRapidJsonAdapter<
|
||||||
|
rapidjson::GenericValue<rapidjson::UTF8<>,
|
||||||
|
rapidjson::CrtAllocator> > >();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, RapidJsonVsRapidJson)
|
TEST_F(TestAdapterComparison, RapidJsonVsRapidJson)
|
||||||
@ -174,6 +192,15 @@ TEST_F(TestAdapterComparison, RapidJsonVsRapidJson)
|
|||||||
valijson::adapters::RapidJsonAdapter>();
|
valijson::adapters::RapidJsonAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(TestAdapterComparison, RapidJsonVsRapidJsonCrtAlloc)
|
||||||
|
{
|
||||||
|
testComparison<
|
||||||
|
valijson::adapters::RapidJsonAdapter,
|
||||||
|
valijson::adapters::GenericRapidJsonAdapter<
|
||||||
|
rapidjson::GenericValue<rapidjson::UTF8<>,
|
||||||
|
rapidjson::CrtAllocator> > >();
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(TestAdapterComparison, RapidJsonVsPicoJson)
|
TEST_F(TestAdapterComparison, RapidJsonVsPicoJson)
|
||||||
{
|
{
|
||||||
testComparison<
|
testComparison<
|
||||||
@ -187,3 +214,23 @@ TEST_F(TestAdapterComparison, PicoJsonVsPicoJson)
|
|||||||
valijson::adapters::PicoJsonAdapter,
|
valijson::adapters::PicoJsonAdapter,
|
||||||
valijson::adapters::PicoJsonAdapter>();
|
valijson::adapters::PicoJsonAdapter>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(TestAdapterComparison, PicoJsonVsRapidJsonCrtAlloc)
|
||||||
|
{
|
||||||
|
testComparison<
|
||||||
|
valijson::adapters::PicoJsonAdapter,
|
||||||
|
valijson::adapters::GenericRapidJsonAdapter<
|
||||||
|
rapidjson::GenericValue<rapidjson::UTF8<>,
|
||||||
|
rapidjson::CrtAllocator> > >();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(TestAdapterComparison, RapidJsonCrtAllocVsRapidJsonCrtAlloc)
|
||||||
|
{
|
||||||
|
testComparison<
|
||||||
|
valijson::adapters::GenericRapidJsonAdapter<
|
||||||
|
rapidjson::GenericValue<rapidjson::UTF8<>,
|
||||||
|
rapidjson::CrtAllocator> >,
|
||||||
|
valijson::adapters::GenericRapidJsonAdapter<
|
||||||
|
rapidjson::GenericValue<rapidjson::UTF8<>,
|
||||||
|
rapidjson::CrtAllocator> > >();
|
||||||
|
}
|
||||||
|
@ -10,7 +10,8 @@ class TestRapidJsonAdapter : public testing::Test
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(TestRapidJsonAdapter, BasicArrayIteration)
|
template<class ValueType>
|
||||||
|
void testBasicArrayIteration()
|
||||||
{
|
{
|
||||||
const unsigned int numElements = 10;
|
const unsigned int numElements = 10;
|
||||||
|
|
||||||
@ -47,7 +48,8 @@ TEST_F(TestRapidJsonAdapter, BasicArrayIteration)
|
|||||||
EXPECT_EQ(numElements, expectedValue);
|
EXPECT_EQ(numElements, expectedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestRapidJsonAdapter, BasicObjectIteration)
|
template<typename ValueType>
|
||||||
|
void testBasicObjectIteration()
|
||||||
{
|
{
|
||||||
const unsigned int numElements = 10;
|
const unsigned int numElements = 10;
|
||||||
|
|
||||||
@ -86,3 +88,23 @@ TEST_F(TestRapidJsonAdapter, BasicObjectIteration)
|
|||||||
// Ensure that the correct number of elements were iterated over
|
// Ensure that the correct number of elements were iterated over
|
||||||
EXPECT_EQ( numElements, expectedValue );
|
EXPECT_EQ( numElements, expectedValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(TestRapidJsonAdapter, BasicArrayIteration)
|
||||||
|
{
|
||||||
|
// Test using default RapidJson value type, which uses MemoryPoolAllocator
|
||||||
|
testBasicArrayIteration<rapidjson::Value>();
|
||||||
|
|
||||||
|
// Test using value type based on CrtAllocator
|
||||||
|
testBasicArrayIteration<rapidjson::GenericValue<rapidjson::UTF8<>,
|
||||||
|
rapidjson::CrtAllocator> >();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(TestRapidJsonAdapter, BasicObjectIteration)
|
||||||
|
{
|
||||||
|
// Test using default RapidJson value type, which uses MemoryPoolAllocator
|
||||||
|
testBasicObjectIteration<rapidjson::Value>();
|
||||||
|
|
||||||
|
// Test using value type based on CrtAllocator
|
||||||
|
testBasicObjectIteration<rapidjson::GenericValue<rapidjson::UTF8<>,
|
||||||
|
rapidjson::CrtAllocator> >();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user