///////////////////////////////////////////////////////////////////////////// // Copyright (c) Electronic Arts Inc. All rights reserved. ///////////////////////////////////////////////////////////////////////////// #include "TestSet.h" #include "EASTLTest.h" #include #include #include #include #include EA_DISABLE_ALL_VC_WARNINGS() #ifndef EA_COMPILER_NO_STANDARD_CPP_LIBRARY #include #endif EA_RESTORE_ALL_VC_WARNINGS() using namespace eastl; // Template instantations. // These tell the compiler to compile all the functions for the given class. template class eastl::vector_set; template class eastl::vector_multiset; template class eastl::vector_set; template class eastl::vector_multiset; /////////////////////////////////////////////////////////////////////////////// // typedefs // typedef eastl::vector_set VS1; typedef eastl::vector_set, EASTLAllocatorType, eastl::deque > VS2; typedef eastl::vector_set VS4; typedef eastl::vector_set, EASTLAllocatorType, eastl::deque > VS5; typedef eastl::vector_multiset VMS1; typedef eastl::vector_multiset, EASTLAllocatorType, eastl::deque > VMS2; typedef eastl::vector_multiset VMS4; typedef eastl::vector_multiset, EASTLAllocatorType, eastl::deque > VMS5; #ifndef EA_COMPILER_NO_STANDARD_CPP_LIBRARY typedef std::set VS3; typedef std::set VS6; typedef std::multiset VMS3; typedef std::multiset VMS6; #endif /////////////////////////////////////////////////////////////////////////////// int TestVectorSet() { int nErrorCount = 0; #ifndef EA_COMPILER_NO_STANDARD_CPP_LIBRARY { // Test construction nErrorCount += TestSetConstruction(); nErrorCount += TestSetConstruction(); nErrorCount += TestSetConstruction(); nErrorCount += TestSetConstruction(); nErrorCount += TestSetConstruction(); nErrorCount += TestSetConstruction(); nErrorCount += TestSetConstruction(); nErrorCount += TestSetConstruction(); } { // Test mutating functionality. nErrorCount += TestSetMutation(); nErrorCount += TestSetMutation(); nErrorCount += TestSetMutation(); nErrorCount += TestSetMutation(); nErrorCount += TestSetMutation(); nErrorCount += TestSetMutation(); nErrorCount += TestSetMutation(); nErrorCount += TestSetMutation(); } #endif // EA_COMPILER_NO_STANDARD_CPP_LIBRARY { // Test search functionality. nErrorCount += TestSetSearch(); nErrorCount += TestSetSearch(); nErrorCount += TestSetSearch(); nErrorCount += TestSetSearch(); nErrorCount += TestSetSearch(); nErrorCount += TestSetSearch(); nErrorCount += TestSetSearch(); nErrorCount += TestSetSearch(); } { // C++11 emplace and related functionality nErrorCount += TestSetCpp11(); nErrorCount += TestSetCpp11(); nErrorCount += TestMultisetCpp11(); nErrorCount += TestMultisetCpp11(); } { // insert at the upper bound of a range VMS1 vms = {0}; VERIFY(vms.insert(0) != vms.begin()); } { // Misc tests { // const key_compare& key_comp() const; // key_compare& key_comp(); VS2 vs; const VS2 vsc; // ensure count can be called from a const object const VS2::key_compare& kc = vsc.key_comp(); vs.key_comp() = kc; vsc.count(0); } { // ensure count can be called from a const object const VMS1 vms; vms.count(0); } } { // find_as predicate { // vector_set eastl::vector_set vss = {"abc", "def", "ghi", "jklmnop", "qrstu", "vw", "x", "yz"}; VERIFY(vss.find_as("GHI", TestStrCmpI_2()) != vss.end()); } { // const vector_set const eastl::vector_set vss = {"abc", "def", "ghi", "jklmnop", "qrstu", "vw", "x", "yz"}; VERIFY(vss.find_as("GHI", TestStrCmpI_2()) != vss.end()); } { // vector_multiset eastl::vector_multiset vss = {"abc", "def", "ghi", "jklmnop", "qrstu", "vw", "x", "yz"}; VERIFY(vss.find_as("GHI", TestStrCmpI_2()) != vss.end()); } { // const vector_multiset const eastl::vector_multiset vss = {"abc", "def", "ghi", "jklmnop", "qrstu", "vw", "x", "yz"}; VERIFY(vss.find_as("GHI", TestStrCmpI_2()) != vss.end()); } } return nErrorCount; }