diff options
author | Kozoriz <kozorizandriy@gmail.com> | 2016-04-26 12:41:54 +0300 |
---|---|---|
committer | Kozoriz <kozorizandriy@gmail.com> | 2016-04-26 15:50:21 +0300 |
commit | 4ecdb2a83871784f34430ed09d5ef6a2c0855506 (patch) | |
tree | dc36b449e5d32ac3e493e16865cf9d88d9991817 /src/components/rpc_base/test | |
parent | cf58bb97d09c536dce3b492d1517da0b837bc8eb (diff) | |
download | sdl_core-4ecdb2a83871784f34430ed09d5ef6a2c0855506.tar.gz |
Format all code in project
Formated all code in appMain, components, plugins to correct coding-style
Used clang-format-3.6
Used 2 commands :
find src/appMain/ -name "*.h" -o -name "*.cc" -o -name "*.hpp" -o -name "*.cpp" | xargs clang-format-3.6 -i -style=file
find src/components/ -name "*.h" -o -name "*.cc" -o -name "*.hpp" -o -name "*.cpp" | xargs clang-format-3.6 -i -style=file
find src/plugins/ -name "*.h" -o -name "*.cc" -o -name "*.hpp" -o -name "*.cpp" | xargs clang-format-3.6 -i -style=file
Diffstat (limited to 'src/components/rpc_base/test')
-rw-r--r-- | src/components/rpc_base/test/rpc_base_dbus_test.cc | 99 | ||||
-rw-r--r-- | src/components/rpc_base/test/rpc_base_json_test.cc | 39 | ||||
-rw-r--r-- | src/components/rpc_base/test/rpc_base_test.cc | 57 | ||||
-rw-r--r-- | src/components/rpc_base/test/validation_report_test.cc | 28 |
4 files changed, 105 insertions, 118 deletions
diff --git a/src/components/rpc_base/test/rpc_base_dbus_test.cc b/src/components/rpc_base/test/rpc_base_dbus_test.cc index e217eff476..f26ce25c5d 100644 --- a/src/components/rpc_base/test/rpc_base_dbus_test.cc +++ b/src/components/rpc_base/test/rpc_base_dbus_test.cc @@ -38,11 +38,7 @@ namespace test { using namespace rpc; using namespace dbus; -enum TestEnum { - kValue0, - kValue1, - kInvalidValue -}; +enum TestEnum { kValue0, kValue1, kInvalidValue }; bool IsValidEnum(TestEnum val) { return val == kValue0 || val == kValue1; @@ -74,8 +70,7 @@ const char* EnumToJsonString(TestEnum enm) { struct DbusDeserialization : public testing::Test { dbus::MessageRef msgref; DbusDeserialization() - : msgref(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL)) { - } + : msgref(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL)) {} }; TEST_F(DbusDeserialization, DeserializeBool) { @@ -97,7 +92,7 @@ TEST_F(DbusDeserialization, DeserializeByte) { } { dbus::MessageReader reader(msgref); - Integer < uint8_t, 1, 220 > byte(&reader); + Integer<uint8_t, 1, 220> byte(&reader); ASSERT_TRUE(byte.is_initialized()); ASSERT_TRUE(byte.is_valid()); ASSERT_EQ(byte, 200); @@ -113,7 +108,7 @@ TEST_F(DbusDeserialization, DeserializeInt64) { } { dbus::MessageReader reader(msgref); - Integer < int64_t, -5, 220 > int64(&reader); + Integer<int64_t, -5, 220> int64(&reader); ASSERT_TRUE(int64.is_initialized()); ASSERT_TRUE(int64.is_valid()); ASSERT_EQ(int64, -1); @@ -129,7 +124,7 @@ TEST_F(DbusDeserialization, DeserializeFloat) { } { dbus::MessageReader reader(msgref); - Float < 3, 4 > pi(&reader); + Float<3, 4> pi(&reader); ASSERT_TRUE(pi.is_initialized()); ASSERT_TRUE(pi.is_valid()); ASSERT_DOUBLE_EQ(pi, 3.14); @@ -145,7 +140,7 @@ TEST_F(DbusDeserialization, DeserializeString) { } { dbus::MessageReader reader(msgref); - String < 3, 10 > hello(&reader); + String<3, 10> hello(&reader); ASSERT_TRUE(hello.is_initialized()); ASSERT_TRUE(hello.is_valid()); ASSERT_EQ(std::string(hello), "Hello"); @@ -174,9 +169,9 @@ TEST_F(DbusDeserialization, DeserializeArray) { { dbus::MessageWriter writer(msgref); std::string array_signature; - rpc::DbusSignature<Integer<int32_t, 1, 50> >(&array_signature); - dbus::MessageWriter array_writer(&writer, dbus::kArray, - array_signature.c_str()); + rpc::DbusSignature<Integer<int32_t, 1, 50>>(&array_signature); + dbus::MessageWriter array_writer( + &writer, dbus::kArray, array_signature.c_str()); array_writer.PutInt32(5); array_writer.PutInt32(33); } @@ -190,7 +185,6 @@ TEST_F(DbusDeserialization, DeserializeArray) { ASSERT_EQ(array.size(), 2u); ASSERT_EQ(array[0], 5); ASSERT_EQ(array[1], 33); - } } @@ -198,15 +192,15 @@ TEST_F(DbusDeserialization, DeserializeArrayOfArrays) { { dbus::MessageWriter writer(msgref); std::string array_signature; - rpc::DbusSignature<Array<Integer<int32_t, 1, 50>, 1, 5> >(&array_signature); - dbus::MessageWriter array_writer(&writer, dbus::kArray, - array_signature.c_str()); + rpc::DbusSignature<Array<Integer<int32_t, 1, 50>, 1, 5>>(&array_signature); + dbus::MessageWriter array_writer( + &writer, dbus::kArray, array_signature.c_str()); int val = 5; for (int i = 0; i < 2; ++i) { std::string subarray_signature; - rpc::DbusSignature<Integer<int32_t, 1, 50> >(&subarray_signature); - dbus::MessageWriter subarray_wirter(&array_writer, dbus::kArray, - subarray_signature.c_str()); + rpc::DbusSignature<Integer<int32_t, 1, 50>>(&subarray_signature); + dbus::MessageWriter subarray_wirter( + &array_writer, dbus::kArray, subarray_signature.c_str()); subarray_wirter.PutInt32(val++); subarray_wirter.PutInt32(val++); @@ -226,7 +220,6 @@ TEST_F(DbusDeserialization, DeserializeArrayOfArrays) { ASSERT_EQ(array[0][1], 6); ASSERT_EQ(array[1][0], 7); ASSERT_EQ(array[1][1], 8); - } } @@ -235,9 +228,9 @@ TEST_F(DbusDeserialization, DeserializeMap) { dbus::MessageWriter writer(msgref); std::string dict_signature; rpc::DbusSignature<Map<Enum<TestEnum>, 1, 5>::value_type>(&dict_signature); - dbus::MessageWriter array_writer(&writer, dbus::kArray, - dict_signature.c_str()); - const char* keys[] = { "Hello", "World" }; + dbus::MessageWriter array_writer( + &writer, dbus::kArray, dict_signature.c_str()); + const char* keys[] = {"Hello", "World"}; int val = 0; for (int i = 0; i < 2; ++i) { dbus::MessageWriter dictval_wirter(&array_writer, dbus::kDictEntry, NULL); @@ -255,7 +248,6 @@ TEST_F(DbusDeserialization, DeserializeMap) { ASSERT_EQ(amap.size(), 2u); ASSERT_EQ(amap["Hello"], kValue0); ASSERT_EQ(amap["World"], kValue1); - } } @@ -283,7 +275,7 @@ TEST_F(DbusDeserialization, DeserializeOptionalString) { } { dbus::MessageReader reader(msgref); - Optional < String<1, 100> > readback(&reader); + Optional<String<1, 100>> readback(&reader); ASSERT_TRUE(readback.is_initialized()); ASSERT_TRUE(readback.is_valid()); ASSERT_EQ(std::string(*readback), "Hello dear"); @@ -301,16 +293,14 @@ TEST_F(DbusDeserialization, DeserializeOptionalInt) { } { dbus::MessageReader reader(msgref); - Optional < Integer<int32_t, 1, 90>> readback(&reader); + Optional<Integer<int32_t, 1, 90>> readback(&reader); ASSERT_FALSE(readback.is_initialized()); ASSERT_TRUE(readback.is_valid()); ASSERT_FALSE(reader.has_failed()); ASSERT_FALSE(reader.HasNext()); - } } - TEST_F(DbusDeserialization, SerializeDeserializeBool) { { Boolean true_bool(true); @@ -330,13 +320,13 @@ TEST_F(DbusDeserialization, SerializeDeserializeBool) { TEST_F(DbusDeserialization, SerializeDeserializeInt8t) { { - Integer < int8_t, 1, 100 > int8(42); + Integer<int8_t, 1, 100> int8(42); dbus::MessageWriter writer(msgref); int8.ToDbusWriter(&writer); } { dbus::MessageReader reader(msgref); - Integer < int8_t, 1, 100 > readback(&reader); + Integer<int8_t, 1, 100> readback(&reader); ASSERT_TRUE(readback.is_initialized()); ASSERT_TRUE(readback.is_valid()); ASSERT_EQ(readback, 42); @@ -347,13 +337,13 @@ TEST_F(DbusDeserialization, SerializeDeserializeInt8t) { TEST_F(DbusDeserialization, BadSerializeDeserializeInt8t) { { - Integer < int8_t, 1, 12 > int8(42); + Integer<int8_t, 1, 12> int8(42); dbus::MessageWriter writer(msgref); int8.ToDbusWriter(&writer); } { dbus::MessageReader reader(msgref); - Integer < int8_t, 1, 12 > readback(&reader); + Integer<int8_t, 1, 12> readback(&reader); ASSERT_TRUE(readback.is_initialized()); ASSERT_FALSE(readback.is_valid()); ASSERT_FALSE(reader.has_failed()); @@ -363,13 +353,13 @@ TEST_F(DbusDeserialization, BadSerializeDeserializeInt8t) { TEST_F(DbusDeserialization, SerializeDeserializeInt64t) { { - Integer < int64_t, 1, 0xFFFFFFFFFF > int64(0xFFFFFFFFF1); + Integer<int64_t, 1, 0xFFFFFFFFFF> int64(0xFFFFFFFFF1); dbus::MessageWriter writer(msgref); int64.ToDbusWriter(&writer); } { dbus::MessageReader reader(msgref); - Integer < int64_t, 1, 0xFFFFFFFFFF > readback(&reader); + Integer<int64_t, 1, 0xFFFFFFFFFF> readback(&reader); ASSERT_TRUE(readback.is_initialized()); ASSERT_TRUE(readback.is_valid()); ASSERT_EQ(readback, 0xFFFFFFFFF1); @@ -378,16 +368,15 @@ TEST_F(DbusDeserialization, SerializeDeserializeInt64t) { } } - TEST_F(DbusDeserialization, SerializeDeserializeDouble) { { - Float < 1, 5 > flt(3.14); + Float<1, 5> flt(3.14); dbus::MessageWriter writer(msgref); flt.ToDbusWriter(&writer); } { dbus::MessageReader reader(msgref); - Float < 1, 5 > readback(&reader); + Float<1, 5> readback(&reader); ASSERT_TRUE(readback.is_initialized()); ASSERT_TRUE(readback.is_valid()); ASSERT_DOUBLE_EQ(readback, 3.14); @@ -398,13 +387,13 @@ TEST_F(DbusDeserialization, SerializeDeserializeDouble) { TEST_F(DbusDeserialization, SerializeDeserializeString) { { - String < 1, 12 > hello("Hello"); + String<1, 12> hello("Hello"); dbus::MessageWriter writer(msgref); hello.ToDbusWriter(&writer); } { dbus::MessageReader reader(msgref); - String < 1, 12 > readback(&reader); + String<1, 12> readback(&reader); ASSERT_TRUE(readback.is_initialized()); ASSERT_TRUE(readback.is_valid()); ASSERT_EQ(std::string(readback), "Hello"); @@ -505,61 +494,61 @@ TEST(ValidatedTypes, TestBooleanDbusSignature) { TEST(ValidatedTypes, TestIntDbusSignature) { std::string sign; - DbusSignature<Integer<int32_t, 1, 2> >(&sign); + DbusSignature<Integer<int32_t, 1, 2>>(&sign); ASSERT_EQ(sign, "i"); } TEST(ValidatedTypes, TestFloatDbusSignature) { std::string sign; - DbusSignature<Float<1, 2> >(&sign); + DbusSignature<Float<1, 2>>(&sign); ASSERT_EQ(sign, "d"); } TEST(ValidatedTypes, TestStringDbusSignature) { std::string sign; - DbusSignature<String<1, 2> >(&sign); + DbusSignature<String<1, 2>>(&sign); ASSERT_EQ(sign, "s"); } TEST(ValidatedTypes, TestEnumDbusSignature) { std::string sign; - DbusSignature<Enum<TestEnum> >(&sign); + DbusSignature<Enum<TestEnum>>(&sign); ASSERT_EQ(sign, "i"); } TEST(ValidatedTypes, TestIntArrayDbusSignature) { std::string sign; - DbusSignature<Array<Integer<int32_t, 1, 2>, 1, 3> >(&sign); + DbusSignature<Array<Integer<int32_t, 1, 2>, 1, 3>>(&sign); ASSERT_EQ(sign, "ai"); } TEST(ValidatedTypes, TestIntArrayArrayDbusSignature) { std::string sign; - DbusSignature<Array<Array<Integer<int32_t, 1, 2>, 1, 3>, 4, 5> >(&sign); + DbusSignature<Array<Array<Integer<int32_t, 1, 2>, 1, 3>, 4, 5>>(&sign); ASSERT_EQ(sign, "aai"); } TEST(ValidatedTypes, TestMapDbusSignature) { std::string sign; - DbusSignature<Map<Integer<int32_t, 1, 2>, 3, 4> >(&sign); + DbusSignature<Map<Integer<int32_t, 1, 2>, 3, 4>>(&sign); ASSERT_EQ(sign, "a{si}"); } TEST(ValidatedTypes, TestMandatoryEnumDbusSignature) { std::string sign; - DbusSignature<Enum<TestEnum> >(&sign); + DbusSignature<Enum<TestEnum>>(&sign); ASSERT_EQ(sign, "i"); } TEST(ValidatedTypes, TestOptionalEnumDbusSignature) { std::string sign; - DbusSignature<Optional<Enum<TestEnum> > >(&sign); + DbusSignature<Optional<Enum<TestEnum>>>(&sign); ASSERT_EQ(sign, "(bi)"); } TEST(ValidatedTypes, TestOptionalFloatArrayDbusSignature) { std::string sign; - DbusSignature<Optional<Array<Float<1, 2>, 3, 4> > >(&sign); + DbusSignature<Optional<Array<Float<1, 2>, 3, 4>>>(&sign); ASSERT_EQ(sign, "(bad)"); } @@ -571,9 +560,7 @@ TEST(DbusMessageConstructionTest, DbusMessageConstruction) { class DbusTest : public testing::Test { public: dbus::MessageRef msgref; - DbusTest() - : msgref(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL)) { - } + DbusTest() : msgref(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL)) {} }; TEST_F(DbusTest, DbusWriterConstructionTest) { @@ -637,8 +624,8 @@ TEST_F(DbusTest, DbusMultipleParamsReadWrite) { TEST_F(DbusTest, DbusArrayTest) { { dbus::MessageWriter writer(msgref); - dbus::MessageWriter array_writer(&writer, dbus::kArray, - DBUS_TYPE_INT16_AS_STRING); + dbus::MessageWriter array_writer( + &writer, dbus::kArray, DBUS_TYPE_INT16_AS_STRING); array_writer.PutInt16(3); array_writer.PutInt16(4); array_writer.PutInt16(5); diff --git a/src/components/rpc_base/test/rpc_base_json_test.cc b/src/components/rpc_base/test/rpc_base_json_test.cc index 3a536937ba..07ac0418e0 100644 --- a/src/components/rpc_base/test/rpc_base_json_test.cc +++ b/src/components/rpc_base/test/rpc_base_json_test.cc @@ -39,11 +39,7 @@ using namespace rpc; using Json::Value; namespace { -enum TestEnum { - kValue0, - kValue1, - kInvalidValue -}; +enum TestEnum { kValue0, kValue1, kInvalidValue }; bool EnumFromJsonString(const std::string& value, TestEnum* enm) { if (value == "kValue0") { @@ -58,10 +54,13 @@ bool EnumFromJsonString(const std::string& value, TestEnum* enm) { } const char* EnumToJsonString(TestEnum enm) { - switch(enm) { - case kValue0: return "kValue0"; - case kValue1: return "kValue1"; - default: return "UNKNOWN"; + switch (enm) { + case kValue0: + return "kValue0"; + case kValue1: + return "kValue1"; + default: + return "UNKNOWN"; } } @@ -272,7 +271,7 @@ TEST(ValidatedTypesJson, MandatoryMapNullTest) { TEST(ValidatedTypesJson, OptionalMapAbsentValueTest) { Value* novalue = NULL; - Optional< Map<String<1, 32>, 0, 5> > map(novalue); + Optional<Map<String<1, 32>, 0, 5> > map(novalue); ASSERT_FALSE(map.is_initialized()); ASSERT_TRUE(map.is_valid()); } @@ -305,7 +304,7 @@ TEST(ValidatedTypesJson, MapFromNonArrayJsonTest) { TEST(ValidatedTypesJson, OptionalBoolFromJsonTest) { Value bool_value(true); - Optional< Boolean > optional_bool; + Optional<Boolean> optional_bool; *optional_bool = Boolean(&bool_value); ASSERT_TRUE(optional_bool.is_initialized()); ASSERT_TRUE(optional_bool.is_valid()); @@ -316,7 +315,7 @@ TEST(ValidatedTypesJson, OptionalBoolFromJsonTest) { TEST(ValidatedTypesJson, OptionalBoolFromAbsentValueTest) { Value* none = NULL; - Optional< Boolean > optional_bool; + Optional<Boolean> optional_bool; *optional_bool = Boolean(none); ASSERT_FALSE(optional_bool.is_initialized()); // It is ok for Optional value to be absent @@ -324,7 +323,7 @@ TEST(ValidatedTypesJson, OptionalBoolFromAbsentValueTest) { } TEST(ValidatedTypesJson, OptionalBoolFromNullValueTest) { - Optional< Boolean > optional_bool; + Optional<Boolean> optional_bool; *optional_bool = Boolean(&Value::null); ASSERT_TRUE(optional_bool.is_initialized()); // Optional values should not be absent @@ -332,7 +331,7 @@ TEST(ValidatedTypesJson, OptionalBoolFromNullValueTest) { } TEST(ValidatedTypesJson, NullableIntFromNullValueTest) { - Nullable< Integer<int8_t, 1, 15> > nullable_int(&Value::null); + Nullable<Integer<int8_t, 1, 15> > nullable_int(&Value::null); ASSERT_TRUE(nullable_int.is_initialized()); ASSERT_TRUE(nullable_int.is_valid()); ASSERT_TRUE(nullable_int.is_null()); @@ -340,7 +339,7 @@ TEST(ValidatedTypesJson, NullableIntFromNullValueTest) { TEST(ValidatedTypesJson, NullableIntFromNonNullValueTest) { Value json(3); - Nullable< Integer<int8_t, 1, 15> > nullable_int(&json); + Nullable<Integer<int8_t, 1, 15> > nullable_int(&json); ASSERT_TRUE(nullable_int.is_initialized()); ASSERT_TRUE(nullable_int.is_valid()); ASSERT_FALSE(nullable_int.is_null()); @@ -349,7 +348,7 @@ TEST(ValidatedTypesJson, NullableIntFromNonNullValueTest) { TEST(ValidatedTypesJson, NullableIntFromAbsentValueTest) { Value* noval = NULL; - Nullable< Integer<int8_t, 1, 15> > nullable_int(noval); + Nullable<Integer<int8_t, 1, 15> > nullable_int(noval); ASSERT_FALSE(nullable_int.is_initialized()); ASSERT_FALSE(nullable_int.is_valid()); ASSERT_FALSE(nullable_int.is_null()); @@ -357,8 +356,8 @@ TEST(ValidatedTypesJson, NullableIntFromAbsentValueTest) { TEST(ValidatedTypesJson, OptionalIntFromJsonTest) { Value int_value(42); - Optional< Integer<int64_t, 42, 43> > optional_int; - *optional_int = Integer<int64_t, 42, 43> (&int_value); + Optional<Integer<int64_t, 42, 43> > optional_int; + *optional_int = Integer<int64_t, 42, 43>(&int_value); ASSERT_TRUE(optional_int.is_initialized()); ASSERT_TRUE(optional_int.is_valid()); Value readback = optional_int->ToJsonValue(); @@ -366,8 +365,4 @@ TEST(ValidatedTypesJson, OptionalIntFromJsonTest) { ASSERT_EQ(readback.asInt(), 42); } - } // namespace test - - - diff --git a/src/components/rpc_base/test/rpc_base_test.cc b/src/components/rpc_base/test/rpc_base_test.cc index 553dacb85d..37a64b319e 100644 --- a/src/components/rpc_base/test/rpc_base_test.cc +++ b/src/components/rpc_base/test/rpc_base_test.cc @@ -40,11 +40,7 @@ using namespace rpc; namespace { -enum TestEnum { - kValue0, - kValue1, - kInvalidValue -}; +enum TestEnum { kValue0, kValue1, kInvalidValue }; bool IsValidEnum(TestEnum val) { return val == kValue0 || val == kValue1; @@ -190,7 +186,7 @@ TEST(ValidatedTypes, TestArrayInitializingConstructor) { } TEST(ValidatedTypes, TestOptionalEmptyArray) { - Optional< Array<Integer<int8_t, 0, 10>, 0, 5> > ai; + Optional<Array<Integer<int8_t, 0, 10>, 0, 5> > ai; ASSERT_RPCTYPE_VALID(ai); ASSERT_FALSE(ai.is_initialized()); Json::FastWriter fw; @@ -220,10 +216,10 @@ TEST(ValidatedTypes, TestMap) { } TEST(ValidatedTypes, TestMapInitializingConstructor) { - std::map< std::string, std::string > init_map; + std::map<std::string, std::string> init_map; init_map["a"] = "Hello"; init_map["b"] = "World"; - Map<String<1, 6>, 2, 10 > map(init_map); + Map<String<1, 6>, 2, 10> map(init_map); ASSERT_TRUE(map.is_initialized()); ASSERT_RPCTYPE_VALID(map); } @@ -251,7 +247,7 @@ TEST(ValidatedTypes, TestEnumConstructor) { } TEST(ValidatedTypes, TestNullableConstructor) { - Nullable< Integer<int8_t, 2, 10> >nullable_int; + Nullable<Integer<int8_t, 2, 10> > nullable_int; ASSERT_FALSE(nullable_int.is_initialized()); ASSERT_FALSE(nullable_int.is_null()); ASSERT_FALSE(nullable_int.is_valid()); @@ -266,7 +262,7 @@ TEST(ValidatedTypes, TestNullableConstructor) { } TEST(ValidatedTypes, TestOptionalNullableConstructor) { - Optional< Nullable< Integer<int8_t, 2, 10> > > optional_nullable_int; + Optional<Nullable<Integer<int8_t, 2, 10> > > optional_nullable_int; ASSERT_FALSE(optional_nullable_int.is_initialized()); ASSERT_FALSE(optional_nullable_int->is_null()); ASSERT_RPCTYPE_VALID(optional_nullable_int); @@ -286,7 +282,7 @@ TEST(ValidatedTypes, TestOptionalNullableConstructor) { } TEST(ValidatedTypes, TestOptionalConstructor) { - Optional< Integer<int16_t, 3, 15> > optional_int; + Optional<Integer<int16_t, 3, 15> > optional_int; ASSERT_FALSE(optional_int.is_initialized()); ASSERT_RPCTYPE_VALID(optional_int); *optional_int = 42; @@ -300,7 +296,7 @@ TEST(ValidatedTypes, TestOptionalConstructor) { } TEST(ValidatedTypes, TestOptionalInitializingConstructor) { - Optional< String<1, 12> > optional_string("Hello world"); + Optional<String<1, 12> > optional_string("Hello world"); ASSERT_TRUE(optional_string.is_initialized()); ASSERT_RPCTYPE_VALID(optional_string); std::string value = *optional_string; @@ -334,7 +330,7 @@ TEST(ValidatedTypes, ReportIncorrectInitializedIntType) { } TEST(ValidatedTypes, ReportUninitializedOptionalType) { - Optional< Integer<int8_t, 1, 3> > val; + Optional<Integer<int8_t, 1, 3> > val; ASSERT_RPCTYPE_VALID(val); ValidationReport report("val"); val.ReportErrors(&report); @@ -342,7 +338,7 @@ TEST(ValidatedTypes, ReportUninitializedOptionalType) { } TEST(ValidatedTypes, ReportIncorrectInitializedOptionalType) { - Optional< Integer<int8_t, 1, 3> > val(5); + Optional<Integer<int8_t, 1, 3> > val(5); ASSERT_FALSE(val.is_valid()); ValidationReport report("val"); val.ReportErrors(&report); @@ -350,7 +346,7 @@ TEST(ValidatedTypes, ReportIncorrectInitializedOptionalType) { } TEST(ValidatedTypes, ReportUninitializedNullableIntType) { - Nullable< Integer<int8_t, 1, 3> > val; + Nullable<Integer<int8_t, 1, 3> > val; ASSERT_FALSE(val.is_valid()); ValidationReport report("val"); val.ReportErrors(&report); @@ -358,7 +354,7 @@ TEST(ValidatedTypes, ReportUninitializedNullableIntType) { } TEST(ValidatedTypes, ReportNullInitializedNullableIntType) { - Nullable< Integer<int8_t, 1, 3> > val; + Nullable<Integer<int8_t, 1, 3> > val; val.set_to_null(); ASSERT_RPCTYPE_VALID(val); ValidationReport report("val"); @@ -367,7 +363,7 @@ TEST(ValidatedTypes, ReportNullInitializedNullableIntType) { } TEST(ValidatedTypes, ReportNoninitializedIntArray) { - Array< Enum<TestEnum>, 1, 3 > array; + Array<Enum<TestEnum>, 1, 3> array; ASSERT_FALSE(array.is_valid()); ValidationReport report("array"); array.ReportErrors(&report); @@ -375,7 +371,7 @@ TEST(ValidatedTypes, ReportNoninitializedIntArray) { } TEST(ValidatedTypes, ReportIncorrectlyInitializedIntArray1) { - Array< Integer<int8_t, 1, 10>, 1, 3 > array; + Array<Integer<int8_t, 1, 10>, 1, 3> array; array.push_back(11); ASSERT_FALSE(array.is_valid()); ValidationReport report("array"); @@ -384,7 +380,7 @@ TEST(ValidatedTypes, ReportIncorrectlyInitializedIntArray1) { } TEST(ValidatedTypes, ReportIncorrectlyInitializedIntArray2) { - Array< Integer<int8_t, 1, 10>, 1, 3 > array; + Array<Integer<int8_t, 1, 10>, 1, 3> array; array.push_back(1); array.push_back(2); array.push_back(3); @@ -396,42 +392,47 @@ TEST(ValidatedTypes, ReportIncorrectlyInitializedIntArray2) { } TEST(ValidatedTypes, ReportIncorrectlyInitializedArray3) { - Array< Integer<int8_t, 1, 10>, 1, 3 > array; + Array<Integer<int8_t, 1, 10>, 1, 3> array; array.push_back(1); array.push_back(2); array.push_back(42); array.push_back(4); ValidationReport report("array"); array.ReportErrors(&report); - ASSERT_EQ("array: array has invalid size\n" - "array[2]: value initialized incorrectly\n", PrettyFormat(report)); + ASSERT_EQ( + "array: array has invalid size\n" + "array[2]: value initialized incorrectly\n", + PrettyFormat(report)); } TEST(ValidatedTypes, ReportUninitializedMap) { - Map< Integer<int8_t, 1, 10>, 1, 3 > map; + Map<Integer<int8_t, 1, 10>, 1, 3> map; ValidationReport report("map"); map.ReportErrors(&report); ASSERT_EQ("map: object is not initialized\n", PrettyFormat(report)); } TEST(ValidatedTypes, ReportIncorrectlyInitializedMap1) { - Map< Integer<int8_t, 1, 10>, 1, 3 > map; + Map<Integer<int8_t, 1, 10>, 1, 3> map; map["aha"] = 42; ValidationReport report("map"); map.ReportErrors(&report); - ASSERT_EQ("map[\"aha\"]: value initialized incorrectly\n", PrettyFormat(report)); + ASSERT_EQ("map[\"aha\"]: value initialized incorrectly\n", + PrettyFormat(report)); } TEST(ValidatedTypes, ReportIncorrectlyInitializedMap2) { - Map< Integer<int8_t, 1, 10>, 1, 3 > map; + Map<Integer<int8_t, 1, 10>, 1, 3> map; map["aha"] = 3; map["haha"] = 12; map["muhahaha"] = 17; map["muhahaha"] = 22; ValidationReport report("map"); map.ReportErrors(&report); - ASSERT_EQ("map[\"haha\"]: value initialized incorrectly\n" - "map[\"muhahaha\"]: value initialized incorrectly\n", PrettyFormat(report)); + ASSERT_EQ( + "map[\"haha\"]: value initialized incorrectly\n" + "map[\"muhahaha\"]: value initialized incorrectly\n", + PrettyFormat(report)); } } // namespace codegen diff --git a/src/components/rpc_base/test/validation_report_test.cc b/src/components/rpc_base/test/validation_report_test.cc index 1493de3957..e7dded342c 100644 --- a/src/components/rpc_base/test/validation_report_test.cc +++ b/src/components/rpc_base/test/validation_report_test.cc @@ -50,10 +50,12 @@ class ValidationReportTest : public testing::Test { static const std::string parent_object_name_; static void SetUpTestCase() { - report_ = new ValidationReport(object_name_); - report_2 = new ValidationReport(object_name_2); + report_ = new ValidationReport(object_name_); + report_2 = new ValidationReport(object_name_2); + } + virtual void TearDown() { + ClearReports(); } - virtual void TearDown() { ClearReports(); } void ClearReports() { ValidationReports& temp = @@ -61,16 +63,17 @@ class ValidationReportTest : public testing::Test { temp.clear(); } - void GeneratePrettyFormatResult(std::string& result, const std::string& parent_name, - const std::string& obj_name, const std::string& val_info) { + void GeneratePrettyFormatResult(std::string& result, + const std::string& parent_name, + const std::string& obj_name, + const std::string& val_info) { std::string temp; if (obj_name[0] != '[') { - temp = "."; + temp = "."; } else { - temp = ""; + temp = ""; } - result = parent_name + temp + obj_name + ":" + " " + - val_info + "\n"; + result = parent_name + temp + obj_name + ":" + " " + val_info + "\n"; } void ClearValidationInfo() { @@ -101,7 +104,6 @@ const std::string ValidationReportTest::test_validation_info_ = "test_validation_info"; const std::string ValidationReportTest::parent_object_name_ = "test_parent"; - TEST_F(ValidationReportTest, Ctor_and_object_name_test_ExpectDataCorrect) { EXPECT_EQ(object_name_, report_->object_name()); } @@ -145,9 +147,11 @@ TEST_F(ValidationReportTest, PrettyFormat_ExpectDataCorrect) { impl::PrettyFormat(*report_, parent_object_name_, &result1); impl::PrettyFormat(*report_2, parent_object_name_, &result2); std::string temp1; - GeneratePrettyFormatResult(temp1, parent_object_name_, object_name_, test_validation_info_); + GeneratePrettyFormatResult( + temp1, parent_object_name_, object_name_, test_validation_info_); std::string temp2; - GeneratePrettyFormatResult(temp2, parent_object_name_, object_name_2, test_validation_info_); + GeneratePrettyFormatResult( + temp2, parent_object_name_, object_name_2, test_validation_info_); // Checks EXPECT_EQ(temp1, result1); EXPECT_EQ(temp2, result2); |