|
| 1 | +// |
| 2 | +// GA-SDK-CPP |
| 3 | +// Copyright 2015 GameAnalytics. All rights reserved. |
| 4 | +// |
| 5 | + |
| 6 | +#include <gtest/gtest.h> |
| 7 | +#include <gmock/gmock.h> |
| 8 | + |
| 9 | +#include <GAState.h> |
| 10 | +//#include "rapidjson/document.h" |
| 11 | +// |
| 12 | +//#include "helpers/GATestHelpers.h" |
| 13 | +// |
| 14 | +//TEST(GAStateTest, testValidateAndCleanCustomFields) |
| 15 | +//{ |
| 16 | +// rapidjson::Document map; |
| 17 | +// rapidjson::Value v; |
| 18 | +// |
| 19 | +// { |
| 20 | +// v = rapidjson::Value(); |
| 21 | +// map.SetObject(); |
| 22 | +// rapidjson::Document::AllocatorType& a = map.GetAllocator(); |
| 23 | +// while(map.MemberCount() < 100) |
| 24 | +// { |
| 25 | +// map.AddMember(rapidjson::Value(GATestHelpers::getRandomString(4).c_str(), a), rapidjson::Value(GATestHelpers::getRandomString(4).c_str(), a), a); |
| 26 | +// } |
| 27 | +// } |
| 28 | +// ASSERT_EQ(100, map.MemberCount()); |
| 29 | +// gameanalytics::state::GAState::validateAndCleanCustomFields(map, v); |
| 30 | +// ASSERT_TRUE(v.MemberCount() == 50); |
| 31 | +// |
| 32 | +// { |
| 33 | +// v = rapidjson::Value(); |
| 34 | +// map.SetObject(); |
| 35 | +// rapidjson::Document::AllocatorType& a = map.GetAllocator(); |
| 36 | +// while(map.MemberCount() < 50) |
| 37 | +// { |
| 38 | +// map.AddMember(rapidjson::Value(GATestHelpers::getRandomString(4).c_str(), a), rapidjson::Value(GATestHelpers::getRandomString(4).c_str(), a), a); |
| 39 | +// } |
| 40 | +// } |
| 41 | +// ASSERT_EQ(50, map.MemberCount()); |
| 42 | +// gameanalytics::state::GAState::validateAndCleanCustomFields(map, v); |
| 43 | +// ASSERT_EQ(50, v.MemberCount()); |
| 44 | +// |
| 45 | +// { |
| 46 | +// v = rapidjson::Value(); |
| 47 | +// map.SetObject(); |
| 48 | +// rapidjson::Document::AllocatorType& a = map.GetAllocator(); |
| 49 | +// map.AddMember(rapidjson::Value(GATestHelpers::getRandomString(4).c_str(), a), rapidjson::Value("", a), a); |
| 50 | +// } |
| 51 | +// gameanalytics::state::GAState::validateAndCleanCustomFields(map, v); |
| 52 | +// ASSERT_TRUE(v.MemberCount() == 0); |
| 53 | +// |
| 54 | +// { |
| 55 | +// v = rapidjson::Value(); |
| 56 | +// map.SetObject(); |
| 57 | +// rapidjson::Document::AllocatorType& a = map.GetAllocator(); |
| 58 | +// map.AddMember(rapidjson::Value(GATestHelpers::getRandomString(4).c_str(), a), rapidjson::Value(GATestHelpers::getRandomString(257).c_str(), a), a); |
| 59 | +// } |
| 60 | +// gameanalytics::state::GAState::validateAndCleanCustomFields(map, v); |
| 61 | +// ASSERT_TRUE(v.MemberCount() == 0); |
| 62 | +// |
| 63 | +// { |
| 64 | +// v = rapidjson::Value(); |
| 65 | +// map.SetObject(); |
| 66 | +// rapidjson::Document::AllocatorType& a = map.GetAllocator(); |
| 67 | +// map.AddMember("", rapidjson::Value(GATestHelpers::getRandomString(4).c_str(), a), a); |
| 68 | +// } |
| 69 | +// gameanalytics::state::GAState::validateAndCleanCustomFields(map, v); |
| 70 | +// ASSERT_TRUE(v.MemberCount() == 0); |
| 71 | +// |
| 72 | +// { |
| 73 | +// v = rapidjson::Value(); |
| 74 | +// map.SetObject(); |
| 75 | +// rapidjson::Document::AllocatorType& a = map.GetAllocator(); |
| 76 | +// map.AddMember(rapidjson::Value("___", a), rapidjson::Value(GATestHelpers::getRandomString(4).c_str(), a), a); |
| 77 | +// } |
| 78 | +// gameanalytics::state::GAState::validateAndCleanCustomFields(map, v); |
| 79 | +// ASSERT_TRUE(v.MemberCount() == 1); |
| 80 | +// |
| 81 | +// { |
| 82 | +// v = rapidjson::Value(); |
| 83 | +// map.SetObject(); |
| 84 | +// rapidjson::Document::AllocatorType& a = map.GetAllocator(); |
| 85 | +// map.AddMember(rapidjson::Value("_&_", a), rapidjson::Value(GATestHelpers::getRandomString(4).c_str(), a), a); |
| 86 | +// } |
| 87 | +// gameanalytics::state::GAState::validateAndCleanCustomFields(map, v); |
| 88 | +// ASSERT_TRUE(v.MemberCount() == 0); |
| 89 | +// |
| 90 | +// { |
| 91 | +// v = rapidjson::Value(); |
| 92 | +// map.SetObject(); |
| 93 | +// rapidjson::Document::AllocatorType& a = map.GetAllocator(); |
| 94 | +// map.AddMember(rapidjson::Value(GATestHelpers::getRandomString(65).c_str(), a), rapidjson::Value(GATestHelpers::getRandomString(4).c_str(), a), a); |
| 95 | +// } |
| 96 | +// gameanalytics::state::GAState::validateAndCleanCustomFields(map, v); |
| 97 | +// ASSERT_TRUE(v.MemberCount() == 0); |
| 98 | +// |
| 99 | +// { |
| 100 | +// v = rapidjson::Value(); |
| 101 | +// map.SetObject(); |
| 102 | +// rapidjson::Document::AllocatorType& a = map.GetAllocator(); |
| 103 | +// map.AddMember(rapidjson::Value(GATestHelpers::getRandomString(4).c_str(), a), rapidjson::Value(100), a); |
| 104 | +// } |
| 105 | +// gameanalytics::state::GAState::validateAndCleanCustomFields(map, v); |
| 106 | +// ASSERT_TRUE(v.MemberCount() == 1); |
| 107 | +// |
| 108 | +// { |
| 109 | +// v = rapidjson::Value(); |
| 110 | +// map.SetObject(); |
| 111 | +// rapidjson::Document::AllocatorType& a = map.GetAllocator(); |
| 112 | +// map.AddMember(rapidjson::Value(GATestHelpers::getRandomString(4).c_str(), a), rapidjson::Value(true), a); |
| 113 | +// } |
| 114 | +// gameanalytics::state::GAState::validateAndCleanCustomFields(map, v); |
| 115 | +// ASSERT_TRUE(v.MemberCount() == 0); |
| 116 | +//} |
0 commit comments