5#include "flutter/shell/platform/linux/public/flutter_linux/fl_value.h"
9#include "gtest/gtest.h"
16TEST(FlValueTest, NullEqual) {
22TEST(FlValueTest, NullToString) {
25 EXPECT_STREQ(
text,
"null");
28TEST(FlValueTest, BoolTrue) {
34TEST(FlValueTest, BoolFalse) {
40TEST(FlValueTest, BoolEqual) {
46TEST(FlValueTest, BoolNotEqual) {
52TEST(FlValueTest, BoolTrueToString) {
55 EXPECT_STREQ(
text,
"true");
58TEST(FlValueTest, BoolFalseToString) {
61 EXPECT_STREQ(
text,
"false");
64TEST(FlValueTest, IntZero) {
76TEST(FlValueTest, IntMinusOne) {
94TEST(FlValueTest, IntEqual) {
100TEST(FlValueTest, IntNotEqual) {
106TEST(FlValueTest, IntToString) {
109 EXPECT_STREQ(
text,
"42");
124TEST(FlValueTest, FloatMinusOne) {
142TEST(FlValueTest, FloatNotEqual) {
148TEST(FlValueTest, FloatToString) {
151 EXPECT_STREQ(
text,
"3.1415926535897931");
160TEST(FlValueTest, StringEmpty) {
166TEST(FlValueTest, StringSized) {
172TEST(FlValueTest, StringSizedNullptr) {
178TEST(FlValueTest, StringSizedZeroLength) {
184TEST(FlValueTest, StringEqual) {
190TEST(FlValueTest, StringNotEqual) {
196TEST(FlValueTest, StringToString) {
199 EXPECT_STREQ(
text,
"hello");
203 uint8_t
data[] = {0x00, 0x01, 0xFE, 0xFF};
213TEST(FlValueTest, Uint8ListNullptr) {
219TEST(FlValueTest, Uint8ListEqual) {
220 uint8_t data1[] = {1, 2, 3};
222 uint8_t data2[] = {1, 2, 3};
227TEST(FlValueTest, Uint8ListEmptyEqual) {
233TEST(FlValueTest, Uint8ListNotEqualSameSize) {
234 uint8_t data1[] = {1, 2, 3};
236 uint8_t data2[] = {1, 2, 4};
241TEST(FlValueTest, Uint8ListNotEqualDifferentSize) {
242 uint8_t data1[] = {1, 2, 3};
244 uint8_t data2[] = {1, 2, 3, 4};
249TEST(FlValueTest, Uint8ListEmptyNotEqual) {
251 uint8_t
data[] = {1, 2, 3};
256TEST(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};
274TEST(FlValueTest, Int32ListNullptr) {
280TEST(FlValueTest, Int32ListEqual) {
281 int32_t data1[] = {0, G_MAXINT32, G_MININT32};
283 int32_t data2[] = {0, G_MAXINT32, G_MININT32};
288TEST(FlValueTest, Int32ListEmptyEqual) {
294TEST(FlValueTest, Int32ListNotEqualSameSize) {
295 int32_t data1[] = {0, G_MAXINT32, G_MININT32};
297 int32_t data2[] = {0, G_MININT32, G_MAXINT32};
302TEST(FlValueTest, Int32ListNotEqualDifferentSize) {
303 int32_t data1[] = {0, G_MAXINT32, G_MININT32};
305 int32_t data2[] = {0, G_MAXINT32, G_MININT32, -1};
310TEST(FlValueTest, Int32ListEmptyNotEqual) {
312 int32_t
data[] = {0, G_MAXINT32, G_MININT32};
317TEST(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};
335TEST(FlValueTest, Int64ListNullptr) {
341TEST(FlValueTest, Int64ListEqual) {
342 int64_t data1[] = {0, G_MAXINT64, G_MININT64};
344 int64_t data2[] = {0, G_MAXINT64, G_MININT64};
349TEST(FlValueTest, Int64ListEmptyEqual) {
355TEST(FlValueTest, Int64ListNotEqualSameSize) {
356 int64_t data1[] = {0, G_MAXINT64, G_MININT64};
358 int64_t data2[] = {0, G_MININT64, G_MAXINT64};
363TEST(FlValueTest, Int64ListNotEqualDifferentSize) {
364 int64_t data1[] = {0, G_MAXINT64, G_MININT64};
366 int64_t data2[] = {0, G_MAXINT64, G_MININT64, -1};
371TEST(FlValueTest, Int64ListEmptyNotEqual) {
373 int64_t
data[] = {0, G_MAXINT64, G_MININT64};
378TEST(FlValueTest, Int64ListToString) {
379 int64_t
data[] = {0, G_MAXINT64, G_MININT64};
382 EXPECT_STREQ(
text,
"[0, 9223372036854775807, -9223372036854775808]");
395TEST(FlValueTest, FloatListNullptr) {
401TEST(FlValueTest, FloatListEqual) {
402 double data1[] = {0, -0.5,
M_PI};
404 double data2[] = {0, -0.5,
M_PI};
409TEST(FlValueTest, FloatListEmptyEqual) {
415TEST(FlValueTest, FloatListNotEqualSameSize) {
416 double data1[] = {0, -0.5,
M_PI};
418 double data2[] = {0, -0.5, M_E};
423TEST(FlValueTest, FloatListNotEqualDifferentSize) {
424 double data1[] = {0, -0.5,
M_PI};
426 double data2[] = {0, -0.5,
M_PI, 42};
431TEST(FlValueTest, FloatListEmptyNotEqual) {
438TEST(FlValueTest, FloatListToString) {
442 EXPECT_STREQ(
text,
"[0.0, -0.5, 3.1415926535897931]");
461TEST(FlValueTest, ListAddTake) {
470TEST(FlValueTest, ListChildTypes) {
507 g_auto(GStrv) words = g_strsplit(
"hello:world",
":", -1);
519TEST(FlValueTest, ListStrvEmpty) {
520 g_auto(GStrv) words = g_strsplit(
"",
":", -1);
538TEST(FlValueTest, ListEmptyEqual) {
544TEST(FlValueTest, ListNotEqualSameSize) {
556TEST(FlValueTest, ListNotEqualDifferentSize) {
569TEST(FlValueTest, ListEmptyNotEqual) {
578TEST(FlValueTest, ListToString) {
592 "[null, true, 42, 3.1415926535897931, [], [], [], [], [], {}]");
629TEST(FlValueTest, MapSetString) {
643TEST(FlValueTest, MapSetStringTake) {
664 ASSERT_NE(v,
nullptr);
669 ASSERT_EQ(v,
nullptr);
672TEST(FlValueTest, MapLookupString) {
678 ASSERT_NE(v,
nullptr);
682 ASSERT_EQ(v,
nullptr);
685TEST(FlValueTest, MapValueypes) {
727TEST(FlValueTest, MapKeyTypes) {
781TEST(FlValueTest, MapEqualDifferentOrder) {
793TEST(FlValueTest, MapEmptyEqual) {
799TEST(FlValueTest, MapNotEqualSameSizeDifferentKeys) {
811TEST(FlValueTest, MapNotEqualSameSizeDifferentValues) {
823TEST(FlValueTest, MapNotEqualDifferentSize) {
836TEST(FlValueTest, MapEmptyNotEqual) {
845TEST(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}");
888TEST(FlDartProjectTest, Custom) {
897TEST(FlDartProjectTest, CustomNoDestroyNotify) {
905TEST(FlDartProjectTest, CustomObject) {
906 g_autoptr(GObject) v = G_OBJECT(g_object_new(G_TYPE_OBJECT,
nullptr));
913TEST(FlDartProjectTest, CustomObjectTake) {
915 128, G_OBJECT(g_object_new(G_TYPE_OBJECT,
nullptr)));
921TEST(FlValueTest, CustomEqual) {
927TEST(FlValueTest, CustomToString) {
930 EXPECT_STREQ(
text,
"(custom 128)");
933TEST(FlValueTest, EqualSameObject) {
938TEST(FlValueTest, NullIntNotEqual) {
944TEST(FlValueTest, NullBoolNotEqual) {
950TEST(FlValueTest, StringUint8ListNotEqual) {
951 uint8_t
data[] = {
'h',
'e',
'l',
'l',
'o'};
957TEST(FlValueTest, Uint8ListInt32ListNotEqual) {
958 uint8_t data8[] = {0, 1, 2, 3, 4};
959 int32_t data32[] = {0, 1, 2, 3, 4};
965TEST(FlValueTest, Int32ListInt64ListNotEqual) {
966 int32_t data32[] = {0, 1, 2, 3, 4};
967 int64_t data64[] = {0, 1, 2, 3, 4};
973TEST(FlValueTest, Int64ListFloatListNotEqual) {
974 int64_t data64[] = {0, 1, 2, 3, 4};
975 double dataf[] = {0.0, 1.0, 2.0, 3.0, 4.0};
981TEST(FlValueTest, ListMapNotEqual) {
G_MODULE_EXPORT void fl_value_set_string(FlValue *self, const gchar *key, FlValue *value)
G_MODULE_EXPORT FlValue * fl_value_new_map()
G_MODULE_EXPORT FlValue * fl_value_new_custom_object_take(int type, GObject *object)
G_MODULE_EXPORT const double * fl_value_get_float_list(FlValue *self)
G_MODULE_EXPORT void fl_value_set_string_take(FlValue *self, const gchar *key, FlValue *value)
G_MODULE_EXPORT FlValue * fl_value_lookup_string(FlValue *self, const gchar *key)
G_MODULE_EXPORT gchar * fl_value_to_string(FlValue *value)
G_MODULE_EXPORT int64_t fl_value_get_int(FlValue *self)
G_MODULE_EXPORT FlValue * fl_value_new_custom(int type, gconstpointer value, GDestroyNotify destroy_notify)
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
G_MODULE_EXPORT FlValue * fl_value_new_null()
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
G_MODULE_EXPORT FlValue * fl_value_new_int32_list(const int32_t *data, size_t data_length)
G_MODULE_EXPORT void fl_value_append(FlValue *self, FlValue *value)
G_MODULE_EXPORT FlValue * fl_value_new_custom_object(int type, GObject *object)
G_MODULE_EXPORT FlValue * fl_value_get_map_key(FlValue *self, size_t index)
G_MODULE_EXPORT FlValue * fl_value_new_bool(bool value)
G_MODULE_EXPORT void fl_value_set_take(FlValue *self, FlValue *key, FlValue *value)
G_MODULE_EXPORT const gchar * fl_value_get_string(FlValue *self)
G_MODULE_EXPORT int fl_value_get_custom_type(FlValue *self)
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
G_MODULE_EXPORT FlValue * fl_value_new_float(double value)
G_MODULE_EXPORT FlValue * fl_value_new_list_from_strv(const gchar *const *str_array)
G_MODULE_EXPORT const uint8_t * fl_value_get_uint8_list(FlValue *self)
G_MODULE_EXPORT FlValue * fl_value_lookup(FlValue *self, FlValue *key)
G_MODULE_EXPORT void fl_value_append_take(FlValue *self, FlValue *value)
G_MODULE_EXPORT gconstpointer fl_value_get_custom_value(FlValue *self)
G_MODULE_EXPORT FlValue * fl_value_get_list_value(FlValue *self, size_t index)
G_MODULE_EXPORT bool fl_value_get_bool(FlValue *self)
G_MODULE_EXPORT FlValue * fl_value_new_list()
G_MODULE_EXPORT FlValue * fl_value_new_uint8_list(const uint8_t *data, size_t data_length)
G_MODULE_EXPORT bool fl_value_equal(FlValue *a, FlValue *b)
G_MODULE_EXPORT FlValue * fl_value_new_float_list(const double *data, size_t data_length)
G_MODULE_EXPORT FlValue * fl_value_new_string_sized(const gchar *value, size_t value_length)
G_MODULE_EXPORT FlValue * fl_value_new_int64_list(const int64_t *data, size_t data_length)
G_MODULE_EXPORT FlValue * fl_value_get_map_value(FlValue *self, size_t index)
G_MODULE_EXPORT double fl_value_get_float(FlValue *self)
G_MODULE_EXPORT GObject * fl_value_get_custom_value_object(FlValue *self)
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
G_MODULE_EXPORT const int32_t * fl_value_get_int32_list(FlValue *self)
G_MODULE_EXPORT const int64_t * fl_value_get_int64_list(FlValue *self)
G_MODULE_EXPORT void fl_value_set(FlValue *self, FlValue *key, FlValue *value)
typedefG_BEGIN_DECLS struct _FlValue FlValue
@ FL_VALUE_TYPE_INT32_LIST
@ FL_VALUE_TYPE_UINT8_LIST
@ FL_VALUE_TYPE_INT64_LIST
@ FL_VALUE_TYPE_FLOAT_LIST
TEST(FlDartProjectTest, Null)
SK_API sk_sp< SkSurface > Null(int width, int height)
std::shared_ptr< const fml::Mapping > data
#define EXPECT_TRUE(handle)