9 #include "gtest/gtest.h"
11 TEST(FlDartProjectTest, Null) {
16 TEST(FlValueTest, NullEqual) {
22 TEST(FlValueTest, NullToString) {
25 EXPECT_STREQ(text,
"null");
28 TEST(FlValueTest, BoolTrue) {
34 TEST(FlValueTest, BoolFalse) {
40 TEST(FlValueTest, BoolEqual) {
46 TEST(FlValueTest, BoolNotEqual) {
52 TEST(FlValueTest, BoolTrueToString) {
55 EXPECT_STREQ(text,
"true");
58 TEST(FlValueTest, BoolFalseToString) {
61 EXPECT_STREQ(text,
"false");
64 TEST(FlValueTest, IntZero) {
70 TEST(FlValueTest, IntOne) {
76 TEST(FlValueTest, IntMinusOne) {
82 TEST(FlValueTest, IntMin) {
88 TEST(FlValueTest, IntMax) {
94 TEST(FlValueTest, IntEqual) {
100 TEST(FlValueTest, IntNotEqual) {
106 TEST(FlValueTest, IntToString) {
109 EXPECT_STREQ(text,
"42");
124 TEST(FlValueTest, FloatMinusOne) {
136 TEST(FlValueTest, FloatEqual) {
142 TEST(FlValueTest, FloatNotEqual) {
148 TEST(FlValueTest, FloatToString) {
151 EXPECT_STREQ(text,
"3.1415926535897931");
160 TEST(FlValueTest, StringEmpty) {
166 TEST(FlValueTest, StringSized) {
172 TEST(FlValueTest, StringSizedNullptr) {
178 TEST(FlValueTest, StringSizedZeroLength) {
184 TEST(FlValueTest, StringEqual) {
190 TEST(FlValueTest, StringNotEqual) {
196 TEST(FlValueTest, StringToString) {
199 EXPECT_STREQ(text,
"hello");
203 uint8_t data[] = {0x00, 0x01, 0xFE, 0xFF};
213 TEST(FlValueTest, Uint8ListNullptr) {
219 TEST(FlValueTest, Uint8ListEqual) {
220 uint8_t data1[] = {1, 2, 3};
222 uint8_t data2[] = {1, 2, 3};
227 TEST(FlValueTest, Uint8ListEmptyEqual) {
233 TEST(FlValueTest, Uint8ListNotEqualSameSize) {
234 uint8_t data1[] = {1, 2, 3};
236 uint8_t data2[] = {1, 2, 4};
241 TEST(FlValueTest, Uint8ListNotEqualDifferentSize) {
242 uint8_t data1[] = {1, 2, 3};
244 uint8_t data2[] = {1, 2, 3, 4};
249 TEST(FlValueTest, Uint8ListEmptyNotEqual) {
251 uint8_t data[] = {1, 2, 3};
256 TEST(FlValueTest, Uint8ListToString) {
257 uint8_t data[] = {0x00, 0x01, 0xFE, 0xFF};
260 EXPECT_STREQ(text,
"[0, 1, 254, 255]");
264 int32_t data[] = {0, -1, G_MAXINT32, G_MININT32};
274 TEST(FlValueTest, Int32ListNullptr) {
280 TEST(FlValueTest, Int32ListEqual) {
281 int32_t data1[] = {0, G_MAXINT32, G_MININT32};
283 int32_t data2[] = {0, G_MAXINT32, G_MININT32};
288 TEST(FlValueTest, Int32ListEmptyEqual) {
294 TEST(FlValueTest, Int32ListNotEqualSameSize) {
295 int32_t data1[] = {0, G_MAXINT32, G_MININT32};
297 int32_t data2[] = {0, G_MININT32, G_MAXINT32};
302 TEST(FlValueTest, Int32ListNotEqualDifferentSize) {
303 int32_t data1[] = {0, G_MAXINT32, G_MININT32};
305 int32_t data2[] = {0, G_MAXINT32, G_MININT32, -1};
310 TEST(FlValueTest, Int32ListEmptyNotEqual) {
312 int32_t data[] = {0, G_MAXINT32, G_MININT32};
317 TEST(FlValueTest, Int32ListToString) {
318 int32_t data[] = {0, G_MAXINT32, G_MININT32};
321 EXPECT_STREQ(text,
"[0, 2147483647, -2147483648]");
325 int64_t data[] = {0, -1, G_MAXINT64, G_MININT64};
335 TEST(FlValueTest, Int64ListNullptr) {
341 TEST(FlValueTest, Int64ListEqual) {
342 int64_t data1[] = {0, G_MAXINT64, G_MININT64};
344 int64_t data2[] = {0, G_MAXINT64, G_MININT64};
349 TEST(FlValueTest, Int64ListEmptyEqual) {
355 TEST(FlValueTest, Int64ListNotEqualSameSize) {
356 int64_t data1[] = {0, G_MAXINT64, G_MININT64};
358 int64_t data2[] = {0, G_MININT64, G_MAXINT64};
363 TEST(FlValueTest, Int64ListNotEqualDifferentSize) {
364 int64_t data1[] = {0, G_MAXINT64, G_MININT64};
366 int64_t data2[] = {0, G_MAXINT64, G_MININT64, -1};
371 TEST(FlValueTest, Int64ListEmptyNotEqual) {
373 int64_t data[] = {0, G_MAXINT64, G_MININT64};
378 TEST(FlValueTest, Int64ListToString) {
379 int64_t data[] = {0, G_MAXINT64, G_MININT64};
382 EXPECT_STREQ(text,
"[0, 9223372036854775807, -9223372036854775808]");
386 double data[] = {0.0, -1.0, M_PI};
395 TEST(FlValueTest, FloatListNullptr) {
401 TEST(FlValueTest, FloatListEqual) {
402 double data1[] = {0, -0.5, M_PI};
404 double data2[] = {0, -0.5, M_PI};
409 TEST(FlValueTest, FloatListEmptyEqual) {
415 TEST(FlValueTest, FloatListNotEqualSameSize) {
416 double data1[] = {0, -0.5, M_PI};
418 double data2[] = {0, -0.5, M_E};
423 TEST(FlValueTest, FloatListNotEqualDifferentSize) {
424 double data1[] = {0, -0.5, M_PI};
426 double data2[] = {0, -0.5, M_PI, 42};
431 TEST(FlValueTest, FloatListEmptyNotEqual) {
433 double data[] = {0, -0.5, M_PI};
438 TEST(FlValueTest, FloatListToString) {
439 double data[] = {0, -0.5, M_PI};
442 EXPECT_STREQ(text,
"[0.0, -0.5, 3.1415926535897931]");
461 TEST(FlValueTest, ListAddTake) {
470 TEST(FlValueTest, ListChildTypes) {
507 g_auto(GStrv) words = g_strsplit(
"hello:world",
":", -1);
519 TEST(FlValueTest, ListStrvEmpty) {
520 g_auto(GStrv) words = g_strsplit(
"",
":", -1);
538 TEST(FlValueTest, ListEmptyEqual) {
544 TEST(FlValueTest, ListNotEqualSameSize) {
556 TEST(FlValueTest, ListNotEqualDifferentSize) {
569 TEST(FlValueTest, ListEmptyNotEqual) {
578 TEST(FlValueTest, ListToString) {
592 "[null, true, 42, 3.1415926535897931, [], [], [], [], [], {}]");
616 TEST(FlValueTest, MapSetTake) {
629 TEST(FlValueTest, MapSetString) {
643 TEST(FlValueTest, MapSetStringTake) {
664 ASSERT_NE(v,
nullptr);
669 ASSERT_EQ(v,
nullptr);
672 TEST(FlValueTest, MapLookupString) {
678 ASSERT_NE(v,
nullptr);
682 ASSERT_EQ(v,
nullptr);
685 TEST(FlValueTest, MapValueypes) {
727 TEST(FlValueTest, MapKeyTypes) {
781 TEST(FlValueTest, MapEqualDifferentOrder) {
793 TEST(FlValueTest, MapEmptyEqual) {
799 TEST(FlValueTest, MapNotEqualSameSizeDifferentKeys) {
811 TEST(FlValueTest, MapNotEqualSameSizeDifferentValues) {
823 TEST(FlValueTest, MapNotEqualDifferentSize) {
836 TEST(FlValueTest, MapEmptyNotEqual) {
845 TEST(FlValueTest, MapToString) {
881 "{null: null, bool: true, int: 42, float: 3.1415926535897931, "
882 "uint8_list: [], int32_list: [], int64_list: [], float_list: "
883 "[], list: [], map: {}, null: null, true: bool, 42: int, "
884 "3.1415926535897931: float, []: uint8_list, []: int32_list, []: "
885 "int64_list, []: float_list, []: list, {}: map}");
888 TEST(FlDartProjectTest, Custom) {
897 TEST(FlDartProjectTest, CustomNoDestroyNotify) {
905 TEST(FlDartProjectTest, CustomObject) {
906 g_autoptr(GObject) v = G_OBJECT(g_object_new(G_TYPE_OBJECT,
nullptr));
913 TEST(FlDartProjectTest, CustomObjectTake) {
915 128, G_OBJECT(g_object_new(G_TYPE_OBJECT,
nullptr)));
921 TEST(FlValueTest, CustomEqual) {
927 TEST(FlValueTest, CustomToString) {
930 EXPECT_STREQ(text,
"(custom 128)");
933 TEST(FlValueTest, EqualSameObject) {
938 TEST(FlValueTest, NullIntNotEqual) {
944 TEST(FlValueTest, NullBoolNotEqual) {
950 TEST(FlValueTest, StringUint8ListNotEqual) {
951 uint8_t data[] = {
'h',
'e',
'l',
'l',
'o'};
957 TEST(FlValueTest, Uint8ListInt32ListNotEqual) {
958 uint8_t data8[] = {0, 1, 2, 3, 4};
959 int32_t data32[] = {0, 1, 2, 3, 4};
965 TEST(FlValueTest, Int32ListInt64ListNotEqual) {
966 int32_t data32[] = {0, 1, 2, 3, 4};
967 int64_t data64[] = {0, 1, 2, 3, 4};
973 TEST(FlValueTest, Int64ListFloatListNotEqual) {
974 int64_t data64[] = {0, 1, 2, 3, 4};
975 double dataf[] = {0.0, 1.0, 2.0, 3.0, 4.0};
981 TEST(FlValueTest, ListMapNotEqual) {