Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
fl_standard_message_codec_test.cc File Reference
#include "flutter/shell/platform/linux/public/flutter_linux/fl_standard_message_codec.h"
#include "flutter/shell/platform/linux/testing/fl_test.h"
#include "gtest/gtest.h"

Go to the source code of this file.

Functions

static gchar * encode_message_with_codec (FlValue *value, FlMessageCodec *codec)
 
static gchar * encode_message (FlValue *value)
 
static FlValuedecode_message_with_codec (const char *hex_string, FlMessageCodec *codec)
 
static FlValuedecode_message (const char *hex_string)
 
static void decode_error_value (const char *hex_string, GQuark domain, gint code)
 
 TEST (FlStandardMessageCodecTest, EncodeNullptr)
 
 TEST (FlStandardMessageCodecTest, EncodeNull)
 
 TEST (FlStandardMessageCodecTest, DecodeNull)
 
static gchar * encode_bool (gboolean value)
 
 TEST (FlStandardMessageCodecTest, EncodeBoolFalse)
 
 TEST (FlStandardMessageCodecTest, EncodeBoolTrue)
 
static gchar * encode_int (int64_t value)
 
 TEST (FlStandardMessageCodecTest, EncodeIntZero)
 
 TEST (FlStandardMessageCodecTest, EncodeIntOne)
 
 TEST (FlStandardMessageCodecTest, EncodeInt32)
 
 TEST (FlStandardMessageCodecTest, EncodeInt32Min)
 
 TEST (FlStandardMessageCodecTest, EncodeInt32Max)
 
 TEST (FlStandardMessageCodecTest, EncodeInt64)
 
 TEST (FlStandardMessageCodecTest, EncodeInt64Min)
 
 TEST (FlStandardMessageCodecTest, EncodeInt64Max)
 
 TEST (FlStandardMessageCodecTest, DecodeIntZero)
 
 TEST (FlStandardMessageCodecTest, DecodeIntOne)
 
 TEST (FlStandardMessageCodecTest, DecodeInt32)
 
 TEST (FlStandardMessageCodecTest, DecodeInt32Min)
 
 TEST (FlStandardMessageCodecTest, DecodeInt32Max)
 
 TEST (FlStandardMessageCodecTest, DecodeInt64)
 
 TEST (FlStandardMessageCodecTest, DecodeInt64Min)
 
 TEST (FlStandardMessageCodecTest, DecodeInt64Max)
 
 TEST (FlStandardMessageCodecTest, DecodeInt32NoData)
 
 TEST (FlStandardMessageCodecTest, DecodeIntShortData1)
 
 TEST (FlStandardMessageCodecTest, DecodeIntShortData2)
 
 TEST (FlStandardMessageCodecTest, DecodeInt64NoData)
 
 TEST (FlStandardMessageCodecTest, DecodeInt64ShortData1)
 
 TEST (FlStandardMessageCodecTest, DecodeInt64ShortData2)
 
static gchar * encode_float (double value)
 
 TEST (FlStandardMessageCodecTest, EncodeFloatZero)
 
 TEST (FlStandardMessageCodecTest, EncodeFloatOne)
 
 TEST (FlStandardMessageCodecTest, EncodeFloatMinusOne)
 
 TEST (FlStandardMessageCodecTest, EncodeFloatHalf)
 
 TEST (FlStandardMessageCodecTest, EncodeFloatFraction)
 
 TEST (FlStandardMessageCodecTest, EncodeFloatMinusZero)
 
 TEST (FlStandardMessageCodecTest, EncodeFloatNaN)
 
 TEST (FlStandardMessageCodecTest, EncodeFloatInfinity)
 
 TEST (FlStandardMessageCodecTest, DecodeFloatZero)
 
 TEST (FlStandardMessageCodecTest, DecodeFloatOne)
 
 TEST (FlStandardMessageCodecTest, DecodeFloatMinusOne)
 
 TEST (FlStandardMessageCodecTest, DecodeFloatHalf)
 
 TEST (FlStandardMessageCodecTest, DecodeFloatPi)
 
 TEST (FlStandardMessageCodecTest, DecodeFloatMinusZero)
 
 TEST (FlStandardMessageCodecTest, DecodeFloatNaN)
 
 TEST (FlStandardMessageCodecTest, DecodeFloatInfinity)
 
 TEST (FlStandardMessageCodecTest, DecodeFloatNoData)
 
 TEST (FlStandardMessageCodecTest, DecodeFloatShortData1)
 
 TEST (FlStandardMessageCodecTest, DecodeFloatShortData2)
 
static gchar * encode_string (const gchar *value)
 
 TEST (FlStandardMessageCodecTest, EncodeStringEmpty)
 
 TEST (FlStandardMessageCodecTest, EncodeStringHello)
 
 TEST (FlStandardMessageCodecTest, EncodeStringEmptySized)
 
 TEST (FlStandardMessageCodecTest, EncodeStringHelloSized)
 
 TEST (FlStandardMessageCodecTest, DecodeStringEmpty)
 
 TEST (FlStandardMessageCodecTest, DecodeStringHello)
 
 TEST (FlStandardMessageCodecTest, DecodeStringNoData)
 
 TEST (FlStandardMessageCodecTest, DecodeStringLengthNoData)
 
 TEST (FlStandardMessageCodecTest, DecodeStringShortData1)
 
 TEST (FlStandardMessageCodecTest, DecodeStringShortData2)
 
 TEST (FlStandardMessageCodecTest, EncodeUint8ListEmpty)
 
 TEST (FlStandardMessageCodecTest, EncodeUint8List)
 
 TEST (FlStandardMessageCodecTest, DecodeUint8ListEmpty)
 
 TEST (FlStandardMessageCodecTest, DecodeUint8List)
 
 TEST (FlStandardMessageCodecTest, DecodeUint8ListNoData)
 
 TEST (FlStandardMessageCodecTest, DecodeUint8ListLengthNoData)
 
 TEST (FlStandardMessageCodecTest, DecodeUint8ListShortData1)
 
 TEST (FlStandardMessageCodecTest, DecodeUint8ListShortData2)
 
 TEST (FlStandardMessageCodecTest, EncodeInt32ListEmpty)
 
 TEST (FlStandardMessageCodecTest, EncodeInt32List)
 
 TEST (FlStandardMessageCodecTest, DecodeInt32ListEmpty)
 
 TEST (FlStandardMessageCodecTest, DecodeInt32List)
 
 TEST (FlStandardMessageCodecTest, DecodeInt32ListNoData)
 
 TEST (FlStandardMessageCodecTest, DecodeInt32ListLengthNoData)
 
 TEST (FlStandardMessageCodecTest, DecodeInt32ListShortData1)
 
 TEST (FlStandardMessageCodecTest, DecodeInt32ListShortData2)
 
 TEST (FlStandardMessageCodecTest, EncodeInt64ListEmpty)
 
 TEST (FlStandardMessageCodecTest, EncodeInt64List)
 
 TEST (FlStandardMessageCodecTest, DecodeInt64ListEmpty)
 
 TEST (FlStandardMessageCodecTest, DecodeInt64List)
 
 TEST (FlStandardMessageCodecTest, DecodeInt64ListNoData)
 
 TEST (FlStandardMessageCodecTest, DecodeInt64ListLengthNoData)
 
 TEST (FlStandardMessageCodecTest, DecodeInt64ListShortData1)
 
 TEST (FlStandardMessageCodecTest, DecodeInt64ListShortData2)
 
 TEST (FlStandardMessageCodecTest, EncodeFloat32ListEmpty)
 
 TEST (FlStandardMessageCodecTest, EncodeFloat32List)
 
 TEST (FlStandardMessageCodecTest, DecodeFloat32ListEmpty)
 
 TEST (FlStandardMessageCodecTest, DecodeFloat32List)
 
 TEST (FlStandardMessageCodecTest, DecodeFloat32ListNoData)
 
 TEST (FlStandardMessageCodecTest, DecodeFloat32ListLengthNoData)
 
 TEST (FlStandardMessageCodecTest, DecodeFloat32ListShortData1)
 
 TEST (FlStandardMessageCodecTest, DecodeFloat32ListShortData2)
 
 TEST (FlStandardMessageCodecTest, EncodeFloatListEmpty)
 
 TEST (FlStandardMessageCodecTest, EncodeFloatList)
 
 TEST (FlStandardMessageCodecTest, DecodeFloatListEmpty)
 
 TEST (FlStandardMessageCodecTest, DecodeFloatList)
 
 TEST (FlStandardMessageCodecTest, DecodeFloatListNoData)
 
 TEST (FlStandardMessageCodecTest, DecodeFloatListLengthNoData)
 
 TEST (FlStandardMessageCodecTest, DecodeFloatListShortData1)
 
 TEST (FlStandardMessageCodecTest, DecodeFloatListShortData2)
 
 TEST (FlStandardMessageCodecTest, EncodeListEmpty)
 
 TEST (FlStandardMessageCodecTest, EncodeListTypes)
 
 TEST (FlStandardMessageCodecTest, EncodeListNested)
 
 TEST (FlStandardMessageCodecTest, DecodeListEmpty)
 
 TEST (FlStandardMessageCodecTest, DecodeListTypes)
 
 TEST (FlStandardMessageCodecTest, DecodeListNested)
 
 TEST (FlStandardMessageCodecTest, DecodeListNoData)
 
 TEST (FlStandardMessageCodecTest, DecodeListLengthNoData)
 
 TEST (FlStandardMessageCodecTest, DecodeListShortData1)
 
 TEST (FlStandardMessageCodecTest, DecodeListShortData2)
 
 TEST (FlStandardMessageCodecTest, EncodeDecodeLargeList)
 
 TEST (FlStandardMessageCodecTest, EncodeMapEmpty)
 
 TEST (FlStandardMessageCodecTest, EncodeMapKeyTypes)
 
 TEST (FlStandardMessageCodecTest, EncodeMapValueTypes)
 
 TEST (FlStandardMessageCodecTest, EncodeMapNested)
 
 TEST (FlStandardMessageCodecTest, DecodeMapEmpty)
 
 TEST (FlStandardMessageCodecTest, DecodeMapKeyTypes)
 
 TEST (FlStandardMessageCodecTest, DecodeMapValueTypes)
 
 TEST (FlStandardMessageCodecTest, DecodeMapNested)
 
 TEST (FlStandardMessageCodecTest, DecodeMapNoData)
 
 TEST (FlStandardMessageCodecTest, DecodeMapLengthNoData)
 
 TEST (FlStandardMessageCodecTest, DecodeMapShortData1)
 
 TEST (FlStandardMessageCodecTest, DecodeMapShortData2)
 
 TEST (FlStandardMessageCodecTest, EncodeDecodeLargeMap)
 
 TEST (FlStandardMessageCodecTest, DecodeUnknownType)
 
 G_DECLARE_FINAL_TYPE (FlTestStandardMessageCodec, fl_test_standard_message_codec, FL, TEST_STANDARD_MESSAGE_CODEC, FlStandardMessageCodec) struct _FlTestStandardMessageCodec
 
 G_DEFINE_TYPE (FlTestStandardMessageCodec, fl_test_standard_message_codec, fl_standard_message_codec_get_type()) static gboolean write_custom_value1(FlStandardMessageCodec *codec
 
 g_byte_array_append (buffer, &type, sizeof(uint8_t))
 
 fl_standard_message_codec_write_size (codec, buffer, length)
 
 g_byte_array_append (buffer, reinterpret_cast< const uint8_t * >(text), length)
 
static gboolean write_custom_value2 (FlStandardMessageCodec *codec, GByteArray *buffer, FlValue *value, GError **error)
 
static gboolean fl_test_standard_message_codec_write_value (FlStandardMessageCodec *codec, GByteArray *buffer, FlValue *value, GError **error)
 
static FlValueread_custom_value1 (FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, GError **error)
 
static FlValueread_custom_value2 (FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, GError **error)
 
static FlValuefl_test_standard_message_codec_read_value_of_type (FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, int type, GError **error)
 
static void fl_test_standard_message_codec_class_init (FlTestStandardMessageCodecClass *klass)
 
static void fl_test_standard_message_codec_init (FlTestStandardMessageCodec *self)
 
static FlTestStandardMessageCodec * fl_test_standard_message_codec_new ()
 
 TEST (FlStandardMessageCodecTest, DecodeCustomType)
 
 TEST (FlStandardMessageCodecTest, DecodeCustomTypes)
 
 TEST (FlStandardMessageCodecTest, EncodeCustomType)
 
 TEST (FlStandardMessageCodecTest, EncodeCustomTypes)
 
 TEST (FlStandardMessageCodecTest, EncodeDecode)
 

Variables

GByteArray * buffer
 
GByteArray FlValuevalue
 
GByteArray FlValue GError ** error
 
size_t length = strlen(text)
 
uint8_t type = 128
 
return TRUE
 

Function Documentation

◆ decode_error_value()

static void decode_error_value ( const char *  hex_string,
GQuark  domain,
gint  code 
)
static

Definition at line 53 of file fl_standard_message_codec_test.cc.

55 {
56 g_autoptr(FlStandardMessageCodec) codec = fl_standard_message_codec_new();
57 g_autoptr(GBytes) data = hex_string_to_bytes(hex_string);
58 g_autoptr(GError) error = nullptr;
59 g_autoptr(FlValue) value =
60 fl_message_codec_decode_message(FL_MESSAGE_CODEC(codec), data, &error);
61 EXPECT_TRUE(value == nullptr);
62 EXPECT_TRUE(g_error_matches(error, domain, code));
63}
G_MODULE_EXPORT FlValue * fl_message_codec_decode_message(FlMessageCodec *self, GBytes *message, GError **error)
G_MODULE_EXPORT FlStandardMessageCodec * fl_standard_message_codec_new()
GByteArray FlValue GError ** error
GByteArray FlValue * value
GBytes * hex_string_to_bytes(const gchar *hex_string)
Definition fl_test.cc:43
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition fl_value.h:42
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41
#define EXPECT_TRUE(handle)
Definition unit_test.h:685

◆ decode_message()

static FlValue * decode_message ( const char *  hex_string)
static

Definition at line 46 of file fl_standard_message_codec_test.cc.

46 {
47 g_autoptr(FlStandardMessageCodec) codec = fl_standard_message_codec_new();
48 return decode_message_with_codec(hex_string, FL_MESSAGE_CODEC(codec));
49}
static FlValue * decode_message_with_codec(const char *hex_string, FlMessageCodec *codec)

◆ decode_message_with_codec()

static FlValue * decode_message_with_codec ( const char *  hex_string,
FlMessageCodec *  codec 
)
static

Definition at line 33 of file fl_standard_message_codec_test.cc.

34 {
35 g_autoptr(GBytes) data = hex_string_to_bytes(hex_string);
36 g_autoptr(GError) error = nullptr;
37 g_autoptr(FlValue) value =
39 EXPECT_EQ(error, nullptr);
40 EXPECT_NE(value, nullptr);
41 return fl_value_ref(value);
42}
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
Definition fl_value.cc:394

◆ encode_bool()

static gchar * encode_bool ( gboolean  value)
static

Definition at line 89 of file fl_standard_message_codec_test.cc.

89 {
90 g_autoptr(FlValue) v = fl_value_new_bool(value);
91 return encode_message(v);
92}
static gchar * encode_message(FlValue *value)
G_MODULE_EXPORT FlValue * fl_value_new_bool(bool value)
Definition fl_value.cc:255

◆ encode_float()

static gchar * encode_float ( double  value)
static

Definition at line 227 of file fl_standard_message_codec_test.cc.

227 {
228 g_autoptr(FlValue) v = fl_value_new_float(value);
229 return encode_message(v);
230}
G_MODULE_EXPORT FlValue * fl_value_new_float(double value)
Definition fl_value.cc:269

◆ encode_int()

static gchar * encode_int ( int64_t  value)
static

Definition at line 104 of file fl_standard_message_codec_test.cc.

104 {
105 g_autoptr(FlValue) v = fl_value_new_int(value);
106 return encode_message(v);
107}
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
Definition fl_value.cc:262

◆ encode_message()

static gchar * encode_message ( FlValue value)
static

Definition at line 26 of file fl_standard_message_codec_test.cc.

26 {
27 g_autoptr(FlStandardMessageCodec) codec = fl_standard_message_codec_new();
28 return encode_message_with_codec(value, FL_MESSAGE_CODEC(codec));
29}
static gchar * encode_message_with_codec(FlValue *value, FlMessageCodec *codec)

◆ encode_message_with_codec()

static gchar * encode_message_with_codec ( FlValue value,
FlMessageCodec *  codec 
)
static

Definition at line 14 of file fl_standard_message_codec_test.cc.

14 {
15 g_autoptr(GError) error = nullptr;
16 g_autoptr(GBytes) message =
18 EXPECT_NE(message, nullptr);
19 EXPECT_EQ(error, nullptr);
20
22}
G_MODULE_EXPORT GBytes * fl_message_codec_encode_message(FlMessageCodec *self, FlValue *message, GError **error)
gchar * bytes_to_hex_string(GBytes *bytes)
Definition fl_test.cc:52
Win32Message message

◆ encode_string()

static gchar * encode_string ( const gchar *  value)
static

Definition at line 335 of file fl_standard_message_codec_test.cc.

335 {
336 g_autoptr(FlValue) v = fl_value_new_string(value);
337 return encode_message(v);
338}
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition fl_value.cc:276

◆ fl_standard_message_codec_write_size()

fl_standard_message_codec_write_size ( codec  ,
buffer  ,
length   
)

◆ fl_test_standard_message_codec_class_init()

static void fl_test_standard_message_codec_class_init ( FlTestStandardMessageCodecClass *  klass)
static

Definition at line 1198 of file fl_standard_message_codec_test.cc.

1199 {
1200 FL_STANDARD_MESSAGE_CODEC_CLASS(klass)->write_value =
1202 FL_STANDARD_MESSAGE_CODEC_CLASS(klass)->read_value_of_type =
1204}
static FlValue * fl_test_standard_message_codec_read_value_of_type(FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, int type, GError **error)
static gboolean fl_test_standard_message_codec_write_value(FlStandardMessageCodec *codec, GByteArray *buffer, FlValue *value, GError **error)

◆ fl_test_standard_message_codec_init()

static void fl_test_standard_message_codec_init ( FlTestStandardMessageCodec *  self)
static

Definition at line 1206 of file fl_standard_message_codec_test.cc.

1207 {
1208 // The following line suppresses a warning for unused function
1209 FL_IS_TEST_STANDARD_MESSAGE_CODEC(self);
1210}

◆ fl_test_standard_message_codec_new()

static FlTestStandardMessageCodec * fl_test_standard_message_codec_new ( )
static

Definition at line 1212 of file fl_standard_message_codec_test.cc.

1212 {
1213 return FL_TEST_STANDARD_MESSAGE_CODEC(
1214 g_object_new(fl_test_standard_message_codec_get_type(), nullptr));
1215}

◆ fl_test_standard_message_codec_read_value_of_type()

static FlValue * fl_test_standard_message_codec_read_value_of_type ( FlStandardMessageCodec *  codec,
GBytes *  buffer,
size_t *  offset,
int  type,
GError **  error 
)
static

Definition at line 1181 of file fl_standard_message_codec_test.cc.

1186 {
1187 if (type == 128) {
1188 return read_custom_value1(codec, buffer, offset, error);
1189 } else if (type == 129) {
1190 return read_custom_value2(codec, buffer, offset, error);
1191 } else {
1192 return FL_STANDARD_MESSAGE_CODEC_CLASS(
1193 fl_test_standard_message_codec_parent_class)
1194 ->read_value_of_type(codec, buffer, offset, type, error);
1195 }
1196}
static FlValue * read_custom_value1(FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, GError **error)
GByteArray * buffer
static FlValue * read_custom_value2(FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, GError **error)
Point offset

◆ fl_test_standard_message_codec_write_value()

static gboolean fl_test_standard_message_codec_write_value ( FlStandardMessageCodec *  codec,
GByteArray *  buffer,
FlValue value,
GError **  error 
)
static

Definition at line 1131 of file fl_standard_message_codec_test.cc.

1135 {
1138 return write_custom_value1(codec, buffer, value, error);
1141 return write_custom_value2(codec, buffer, value, error);
1142 } else {
1143 return FL_STANDARD_MESSAGE_CODEC_CLASS(
1144 fl_test_standard_message_codec_parent_class)
1145 ->write_value(codec, buffer, value, error);
1146 }
1147}
static gboolean write_custom_value2(FlStandardMessageCodec *codec, GByteArray *buffer, FlValue *value, GError **error)
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
Definition fl_value.cc:466
G_MODULE_EXPORT int fl_value_get_custom_type(FlValue *self)
Definition fl_value.cc:822
@ FL_VALUE_TYPE_CUSTOM
Definition fl_value.h:77

◆ g_byte_array_append() [1/2]

g_byte_array_append ( buffer  ,
type,
sizeof(uint8_t)   
)

◆ g_byte_array_append() [2/2]

g_byte_array_append ( buffer  ,
reinterpret_cast< const uint8_t * >  text,
length   
)

◆ G_DECLARE_FINAL_TYPE()

G_DECLARE_FINAL_TYPE ( FlTestStandardMessageCodec  ,
fl_test_standard_message_codec  ,
FL  ,
TEST_STANDARD_MESSAGE_CODEC  ,
FlStandardMessageCodec   
)

Definition at line 1093 of file fl_standard_message_codec_test.cc.

1099 {
1100 FlStandardMessageCodec parent_instance;
1101};

◆ G_DEFINE_TYPE()

G_DEFINE_TYPE ( FlTestStandardMessageCodec  ,
fl_test_standard_message_codec  ,
fl_standard_message_codec_get_type()   
)

◆ read_custom_value1()

static FlValue * read_custom_value1 ( FlStandardMessageCodec *  codec,
GBytes *  buffer,
size_t *  offset,
GError **  error 
)
static

Definition at line 1149 of file fl_standard_message_codec_test.cc.

1152 {
1153 uint32_t length;
1155 error)) {
1156 return nullptr;
1157 }
1158 if (*offset + length > g_bytes_get_size(buffer)) {
1159 g_set_error(error, FL_MESSAGE_CODEC_ERROR,
1160 FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA, "Unexpected end of data");
1161 return nullptr;
1162 }
1164 128,
1165 g_strndup(static_cast<const gchar*>(g_bytes_get_data(buffer, nullptr)) +
1166 *offset,
1167 length),
1168 g_free);
1169 *offset += length;
1170
1171 return value;
1172}
@ FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA
#define FL_MESSAGE_CODEC_ERROR
G_MODULE_EXPORT gboolean fl_standard_message_codec_read_size(FlStandardMessageCodec *codec, GBytes *buffer, size_t *offset, uint32_t *value, GError **error)
G_MODULE_EXPORT FlValue * fl_value_new_custom(int type, gconstpointer value, GDestroyNotify destroy_notify)
Definition fl_value.cc:374

◆ read_custom_value2()

static FlValue * read_custom_value2 ( FlStandardMessageCodec *  codec,
GBytes *  buffer,
size_t *  offset,
GError **  error 
)
static

Definition at line 1174 of file fl_standard_message_codec_test.cc.

1177 {
1178 return fl_value_new_custom(129, nullptr, nullptr);
1179}

◆ TEST() [1/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeCustomType   
)

Definition at line 1217 of file fl_standard_message_codec_test.cc.

1217 {
1218 g_autoptr(FlTestStandardMessageCodec) codec =
1220 g_autoptr(FlValue) value =
1221 decode_message_with_codec("800568656c6c6f", FL_MESSAGE_CODEC(codec));
1223 ASSERT_EQ(fl_value_get_custom_type(value), 128);
1224 EXPECT_STREQ(static_cast<const gchar*>(fl_value_get_custom_value(value)),
1225 "hello");
1226}
static FlTestStandardMessageCodec * fl_test_standard_message_codec_new()
G_MODULE_EXPORT gconstpointer fl_value_get_custom_value(FlValue *self)
Definition fl_value.cc:830

◆ TEST() [2/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeCustomTypes   
)

Definition at line 1228 of file fl_standard_message_codec_test.cc.

1228 {
1229 g_autoptr(FlTestStandardMessageCodec) codec =
1231 g_autoptr(FlValue) value = decode_message_with_codec("0c02800568656c6c6f81",
1232 FL_MESSAGE_CODEC(codec));
1234 EXPECT_EQ(fl_value_get_length(value), static_cast<size_t>(2));
1236 ASSERT_EQ(fl_value_get_type(value1), FL_VALUE_TYPE_CUSTOM);
1237 ASSERT_EQ(fl_value_get_custom_type(value1), 128);
1238 EXPECT_STREQ(static_cast<const gchar*>(fl_value_get_custom_value(value1)),
1239 "hello");
1241 ASSERT_EQ(fl_value_get_type(value2), FL_VALUE_TYPE_CUSTOM);
1242 ASSERT_EQ(fl_value_get_custom_type(value2), 129);
1243}
G_MODULE_EXPORT FlValue * fl_value_get_list_value(FlValue *self, size_t index)
Definition fl_value.cc:776
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
Definition fl_value.cc:724
@ FL_VALUE_TYPE_LIST
Definition fl_value.h:74

◆ TEST() [3/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloat32List   
)

Definition at line 574 of file fl_standard_message_codec_test.cc.

574 {
575 g_autoptr(FlValue) value =
576 decode_message("0e05000000000000000000bf0000803e000000becdcccc3b");
578 const float* data = fl_value_get_float32_list(value);
579 EXPECT_FLOAT_EQ(data[0], 0.0f);
580 EXPECT_FLOAT_EQ(data[1], -0.5f);
581 EXPECT_FLOAT_EQ(data[2], 0.25f);
582 EXPECT_FLOAT_EQ(data[3], -0.125f);
583 EXPECT_FLOAT_EQ(data[4], 0.00625f);
584}
static FlValue * decode_message(const char *hex_string)
G_MODULE_EXPORT const float * fl_value_get_float32_list(FlValue *self)
Definition fl_value.cc:710
@ FL_VALUE_TYPE_FLOAT32_LIST
Definition fl_value.h:76

◆ TEST() [4/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloat32ListEmpty   
)

Definition at line 568 of file fl_standard_message_codec_test.cc.

568 {
569 g_autoptr(FlValue) value = decode_message("0e000000");
571 EXPECT_EQ(fl_value_get_length(value), static_cast<size_t>(0));
572}

◆ TEST() [5/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloat32ListLengthNoData   
)

Definition at line 591 of file fl_standard_message_codec_test.cc.

591 {
594}
static void decode_error_value(const char *hex_string, GQuark domain, gint code)

◆ TEST() [6/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloat32ListNoData   
)

◆ TEST() [7/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloat32ListShortData1   
)

◆ TEST() [8/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloat32ListShortData2   
)

Definition at line 601 of file fl_standard_message_codec_test.cc.

601 {
602 decode_error_value("0e05000000000000000000bf0000803e000000becdcccc",
605}

◆ TEST() [9/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatHalf   
)

Definition at line 290 of file fl_standard_message_codec_test.cc.

290 {
291 g_autoptr(FlValue) value = decode_message("0600000000000000000000000000e03f");
293 EXPECT_EQ(fl_value_get_float(value), 0.5);
294}
G_MODULE_EXPORT double fl_value_get_float(FlValue *self)
Definition fl_value.cc:675
@ FL_VALUE_TYPE_FLOAT
Definition fl_value.h:68

◆ TEST() [10/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatInfinity   
)

Definition at line 314 of file fl_standard_message_codec_test.cc.

314 {
315 g_autoptr(FlValue) value = decode_message("0600000000000000000000000000f07f");
318}

◆ TEST() [11/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatList   
)

Definition at line 629 of file fl_standard_message_codec_test.cc.

629 {
630 g_autoptr(FlValue) value = decode_message(
631 "0b050000000000000000000000000000000000000000e0bf000000000000d03f00000000"
632 "0000c0bf9a9999999999793f");
634 const double* data = fl_value_get_float_list(value);
635 EXPECT_FLOAT_EQ(data[0], 0.0);
636 EXPECT_FLOAT_EQ(data[1], -0.5);
637 EXPECT_FLOAT_EQ(data[2], 0.25);
638 EXPECT_FLOAT_EQ(data[3], -0.125);
639 EXPECT_FLOAT_EQ(data[4], 0.00625);
640}
G_MODULE_EXPORT const double * fl_value_get_float_list(FlValue *self)
Definition fl_value.cc:717
@ FL_VALUE_TYPE_FLOAT_LIST
Definition fl_value.h:73

◆ TEST() [12/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatListEmpty   
)

Definition at line 623 of file fl_standard_message_codec_test.cc.

623 {
624 g_autoptr(FlValue) value = decode_message("0b00000000000000");
626 EXPECT_EQ(fl_value_get_length(value), static_cast<size_t>(0));
627}

◆ TEST() [13/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatListLengthNoData   
)

Definition at line 647 of file fl_standard_message_codec_test.cc.

◆ TEST() [14/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatListNoData   
)

◆ TEST() [15/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatListShortData1   
)

Definition at line 652 of file fl_standard_message_codec_test.cc.

◆ TEST() [16/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatListShortData2   
)

Definition at line 657 of file fl_standard_message_codec_test.cc.

657 {
659 "0b050000000000000000000000000000000000000000e0bf000000000000d03f00000000"
660 "0000c0bf9a99"
661 "9999999979",
663}

◆ TEST() [17/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatMinusOne   
)

Definition at line 284 of file fl_standard_message_codec_test.cc.

284 {
285 g_autoptr(FlValue) value = decode_message("0600000000000000000000000000f0bf");
287 EXPECT_EQ(fl_value_get_float(value), -1.0);
288}

◆ TEST() [18/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatMinusZero   
)

Definition at line 302 of file fl_standard_message_codec_test.cc.

302 {
303 g_autoptr(FlValue) value = decode_message("06000000000000000000000000000080");
305 EXPECT_EQ(fl_value_get_float(value), -0.0);
306}

◆ TEST() [19/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatNaN   
)

Definition at line 308 of file fl_standard_message_codec_test.cc.

308 {
309 g_autoptr(FlValue) value = decode_message("0600000000000000000000000000f87f");
312}

◆ TEST() [20/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatNoData   
)

Definition at line 320 of file fl_standard_message_codec_test.cc.

◆ TEST() [21/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatOne   
)

Definition at line 278 of file fl_standard_message_codec_test.cc.

278 {
279 g_autoptr(FlValue) value = decode_message("0600000000000000000000000000f03f");
281 EXPECT_EQ(fl_value_get_float(value), 1.0);
282}

◆ TEST() [22/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatPi   
)

Definition at line 296 of file fl_standard_message_codec_test.cc.

296 {
297 g_autoptr(FlValue) value = decode_message("0600000000000000182d4454fb210940");
299 EXPECT_EQ(fl_value_get_float(value), M_PI);
300}
#define M_PI

◆ TEST() [23/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatShortData1   
)

Definition at line 325 of file fl_standard_message_codec_test.cc.

◆ TEST() [24/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatShortData2   
)

Definition at line 330 of file fl_standard_message_codec_test.cc.

330 {
331 decode_error_value("060000000000000000000000000000", FL_MESSAGE_CODEC_ERROR,
333}

◆ TEST() [25/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatZero   
)

Definition at line 272 of file fl_standard_message_codec_test.cc.

272 {
273 g_autoptr(FlValue) value = decode_message("06000000000000000000000000000000");
275 EXPECT_EQ(fl_value_get_float(value), 0.0);
276}

◆ TEST() [26/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt32   
)

Definition at line 161 of file fl_standard_message_codec_test.cc.

161 {
162 g_autoptr(FlValue) value = decode_message("0367452301");
164 EXPECT_EQ(fl_value_get_int(value), 0x01234567);
165}
G_MODULE_EXPORT int64_t fl_value_get_int(FlValue *self)
Definition fl_value.cc:668
@ FL_VALUE_TYPE_INT
Definition fl_value.h:67

◆ TEST() [27/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt32List   
)

Definition at line 464 of file fl_standard_message_codec_test.cc.

464 {
465 g_autoptr(FlValue) value =
466 decode_message("0905000000000000ffffffff02000000fdffffff04000000");
468 const int32_t* data = fl_value_get_int32_list(value);
469 EXPECT_EQ(data[0], 0);
470 EXPECT_EQ(data[1], -1);
471 EXPECT_EQ(data[2], 2);
472 EXPECT_EQ(data[3], -3);
473 EXPECT_EQ(data[4], 4);
474}
G_MODULE_EXPORT const int32_t * fl_value_get_int32_list(FlValue *self)
Definition fl_value.cc:696
@ FL_VALUE_TYPE_INT32_LIST
Definition fl_value.h:71

◆ TEST() [28/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt32ListEmpty   
)

Definition at line 458 of file fl_standard_message_codec_test.cc.

458 {
459 g_autoptr(FlValue) value = decode_message("09000000");
461 EXPECT_EQ(fl_value_get_length(value), static_cast<size_t>(0));
462}

◆ TEST() [29/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt32ListLengthNoData   
)

◆ TEST() [30/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt32ListNoData   
)

◆ TEST() [31/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt32ListShortData1   
)

◆ TEST() [32/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt32ListShortData2   
)

Definition at line 491 of file fl_standard_message_codec_test.cc.

491 {
492 decode_error_value("090500000000ffffffff02000000fdffffff040000",
495}

◆ TEST() [33/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt32Max   
)

Definition at line 173 of file fl_standard_message_codec_test.cc.

173 {
174 g_autoptr(FlValue) value = decode_message("03ffffff7f");
176 EXPECT_EQ(fl_value_get_int(value), G_MAXINT32);
177}

◆ TEST() [34/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt32Min   
)

Definition at line 167 of file fl_standard_message_codec_test.cc.

167 {
168 g_autoptr(FlValue) value = decode_message("0300000080");
170 EXPECT_EQ(fl_value_get_int(value), G_MININT32);
171}

◆ TEST() [35/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt32NoData   
)

◆ TEST() [36/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64   
)

Definition at line 179 of file fl_standard_message_codec_test.cc.

179 {
180 g_autoptr(FlValue) value = decode_message("04efcdab8967452301");
182 EXPECT_EQ(fl_value_get_int(value), 0x0123456789abcdef);
183}

◆ TEST() [37/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64List   
)

Definition at line 519 of file fl_standard_message_codec_test.cc.

519 {
520 g_autoptr(FlValue) value = decode_message(
521 "0a050000000000000000000000000000ffffffffffffffff0200000000000000fdffffff"
522 "ffffffff0400000000000000");
524 const int64_t* data = fl_value_get_int64_list(value);
525 EXPECT_EQ(data[0], 0);
526 EXPECT_EQ(data[1], -1);
527 EXPECT_EQ(data[2], 2);
528 EXPECT_EQ(data[3], -3);
529 EXPECT_EQ(data[4], 4);
530}
G_MODULE_EXPORT const int64_t * fl_value_get_int64_list(FlValue *self)
Definition fl_value.cc:703
@ FL_VALUE_TYPE_INT64_LIST
Definition fl_value.h:72

◆ TEST() [38/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64ListEmpty   
)

Definition at line 513 of file fl_standard_message_codec_test.cc.

513 {
514 g_autoptr(FlValue) value = decode_message("0a00000000000000");
516 EXPECT_EQ(fl_value_get_length(value), static_cast<size_t>(0));
517}

◆ TEST() [39/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64ListLengthNoData   
)

Definition at line 537 of file fl_standard_message_codec_test.cc.

◆ TEST() [40/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64ListNoData   
)

◆ TEST() [41/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64ListShortData1   
)

Definition at line 542 of file fl_standard_message_codec_test.cc.

◆ TEST() [42/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64ListShortData2   
)

Definition at line 547 of file fl_standard_message_codec_test.cc.

547 {
549 "0a050000000000000000000000000000ffffffffffffffff0200000000000000fdffffff"
550 "ffffffff0400"
551 "0000000000",
553}

◆ TEST() [43/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64Max   
)

Definition at line 191 of file fl_standard_message_codec_test.cc.

191 {
192 g_autoptr(FlValue) value = decode_message("04ffffffffffffff7f");
194 EXPECT_EQ(fl_value_get_int(value), G_MAXINT64);
195}

◆ TEST() [44/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64Min   
)

Definition at line 185 of file fl_standard_message_codec_test.cc.

185 {
186 g_autoptr(FlValue) value = decode_message("040000000000000080");
188 EXPECT_EQ(fl_value_get_int(value), G_MININT64);
189}

◆ TEST() [45/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64NoData   
)

◆ TEST() [46/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64ShortData1   
)

◆ TEST() [47/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64ShortData2   
)

Definition at line 222 of file fl_standard_message_codec_test.cc.

◆ TEST() [48/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeIntOne   
)

Definition at line 155 of file fl_standard_message_codec_test.cc.

155 {
156 g_autoptr(FlValue) value = decode_message("0301000000");
158 EXPECT_EQ(fl_value_get_int(value), 1);
159}

◆ TEST() [49/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeIntShortData1   
)

◆ TEST() [50/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeIntShortData2   
)

◆ TEST() [51/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeIntZero   
)

Definition at line 149 of file fl_standard_message_codec_test.cc.

149 {
150 g_autoptr(FlValue) value = decode_message("0300000000");
152 EXPECT_EQ(fl_value_get_int(value), 0);
153}

◆ TEST() [52/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeListEmpty   
)

Definition at line 705 of file fl_standard_message_codec_test.cc.

705 {
706 g_autoptr(FlValue) value = decode_message("0c00");
708 EXPECT_EQ(fl_value_get_length(value), static_cast<size_t>(0));
709}

◆ TEST() [53/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeListLengthNoData   
)

◆ TEST() [54/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeListNested   
)

Definition at line 740 of file fl_standard_message_codec_test.cc.

740 {
741 g_autoptr(FlValue) value = decode_message(
742 "0c020c05030000000003020000000304000000030600000003080000000c"
743 "0503010000000303000000030500000003070000000309000000");
745 ASSERT_EQ(fl_value_get_length(value), static_cast<size_t>(2));
746 FlValue* even_list = fl_value_get_list_value(value, 0);
747 ASSERT_EQ(fl_value_get_type(even_list), FL_VALUE_TYPE_LIST);
748 ASSERT_EQ(fl_value_get_length(even_list), static_cast<size_t>(5));
749 FlValue* odd_list = fl_value_get_list_value(value, 1);
750 ASSERT_EQ(fl_value_get_type(odd_list), FL_VALUE_TYPE_LIST);
751 ASSERT_EQ(fl_value_get_length(odd_list), static_cast<size_t>(5));
752 for (int i = 0; i < 5; i++) {
753 FlValue* v = fl_value_get_list_value(even_list, i);
755 EXPECT_EQ(fl_value_get_int(v), i * 2);
756
757 v = fl_value_get_list_value(odd_list, i);
759 EXPECT_EQ(fl_value_get_int(v), i * 2 + 1);
760 }
761}

◆ TEST() [55/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeListNoData   
)

◆ TEST() [56/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeListShortData1   
)

◆ TEST() [57/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeListShortData2   
)

Definition at line 778 of file fl_standard_message_codec_test.cc.

778 {
780 "0c070001032a00000006000000000000182d4454fb210940070568656c6c6f0c000d",
782}

◆ TEST() [58/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeListTypes   
)

Definition at line 711 of file fl_standard_message_codec_test.cc.

711 {
712 g_autoptr(FlValue) value = decode_message(
713 "0c070001032a00000006000000000000182d4454fb210940070568656c6c6f0c000d00");
715 ASSERT_EQ(fl_value_get_length(value), static_cast<size_t>(7));
729 EXPECT_STREQ(fl_value_get_string(fl_value_get_list_value(value, 4)), "hello");
733 static_cast<size_t>(0));
737 static_cast<size_t>(0));
738}
G_MODULE_EXPORT const gchar * fl_value_get_string(FlValue *self)
Definition fl_value.cc:682
G_MODULE_EXPORT bool fl_value_get_bool(FlValue *self)
Definition fl_value.cc:661
@ FL_VALUE_TYPE_STRING
Definition fl_value.h:69
@ FL_VALUE_TYPE_NULL
Definition fl_value.h:65
@ FL_VALUE_TYPE_BOOL
Definition fl_value.h:66
@ FL_VALUE_TYPE_MAP
Definition fl_value.h:75

◆ TEST() [59/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeMapEmpty   
)

Definition at line 871 of file fl_standard_message_codec_test.cc.

871 {
872 g_autoptr(FlValue) value = decode_message("0d00");
874 ASSERT_EQ(fl_value_get_length(value), static_cast<size_t>(0));
875}

◆ TEST() [60/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeMapKeyTypes   
)

Definition at line 877 of file fl_standard_message_codec_test.cc.

877 {
878 g_autoptr(FlValue) value = decode_message(
879 "0d070007046e756c6c010704626f6f6c032a0000000703696e74060000000000182d4454"
880 "fb2109400705666c6f6174070568656c6c6f0706737472696e670c0007046c6973740d00"
881 "07036d6170");
883 ASSERT_EQ(fl_value_get_length(value), static_cast<size_t>(7));
884
889 EXPECT_STREQ(fl_value_get_string(fl_value_get_map_value(value, 0)), "null");
890
896 EXPECT_STREQ(fl_value_get_string(fl_value_get_map_value(value, 1)), "bool");
897
900 EXPECT_EQ(fl_value_get_int(fl_value_get_map_key(value, 2)), 42);
903 EXPECT_STREQ(fl_value_get_string(fl_value_get_map_value(value, 2)), "int");
904
907 EXPECT_FLOAT_EQ(fl_value_get_float(fl_value_get_map_key(value, 3)), M_PI);
910 EXPECT_STREQ(fl_value_get_string(fl_value_get_map_value(value, 3)), "float");
911
914 EXPECT_STREQ(fl_value_get_string(fl_value_get_map_key(value, 4)), "hello");
917 EXPECT_STREQ(fl_value_get_string(fl_value_get_map_value(value, 4)), "string");
918
922 static_cast<size_t>(0));
925 EXPECT_STREQ(fl_value_get_string(fl_value_get_map_value(value, 5)), "list");
926
930 static_cast<size_t>(0));
933 EXPECT_STREQ(fl_value_get_string(fl_value_get_map_value(value, 6)), "map");
934}
G_MODULE_EXPORT FlValue * fl_value_get_map_key(FlValue *self, size_t index)
Definition fl_value.cc:784
G_MODULE_EXPORT FlValue * fl_value_get_map_value(FlValue *self, size_t index)
Definition fl_value.cc:792

◆ TEST() [61/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeMapLengthNoData   
)

◆ TEST() [62/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeMapNested   
)

Definition at line 995 of file fl_standard_message_codec_test.cc.

995 {
996 g_autoptr(FlValue) value = decode_message(
997 "0d02070a7374722d746f2d696e740d0407047a65726f030000000007036f6e6503010000"
998 "00070374776f0302000000070574687265650303000000070a696e742d746f2d7374720d"
999 "04030000000007047a65726f030100000007036f6e650302000000070374776f03030000"
1000 "0007057468726565");
1002 ASSERT_EQ(fl_value_get_length(value), static_cast<size_t>(2));
1003
1007 "str-to-int");
1008 FlValue* str_to_int = fl_value_get_map_value(value, 0);
1009 ASSERT_EQ(fl_value_get_type(str_to_int), FL_VALUE_TYPE_MAP);
1010 ASSERT_EQ(fl_value_get_length(str_to_int), static_cast<size_t>(4));
1011
1015 "int-to-str");
1016 FlValue* int_to_str = fl_value_get_map_value(value, 1);
1017 ASSERT_EQ(fl_value_get_type(int_to_str), FL_VALUE_TYPE_MAP);
1018 ASSERT_EQ(fl_value_get_length(int_to_str), static_cast<size_t>(4));
1019
1020 const char* numbers[] = {"zero", "one", "two", "three", nullptr};
1021 for (int i = 0; numbers[i] != nullptr; i++) {
1022 ASSERT_EQ(fl_value_get_type(fl_value_get_map_key(str_to_int, i)),
1024 EXPECT_STREQ(fl_value_get_string(fl_value_get_map_key(str_to_int, i)),
1025 numbers[i]);
1026
1027 ASSERT_EQ(fl_value_get_type(fl_value_get_map_value(str_to_int, i)),
1029 EXPECT_EQ(fl_value_get_int(fl_value_get_map_value(str_to_int, i)), i);
1030
1031 ASSERT_EQ(fl_value_get_type(fl_value_get_map_key(int_to_str, i)),
1033 EXPECT_EQ(fl_value_get_int(fl_value_get_map_key(int_to_str, i)), i);
1034
1035 ASSERT_EQ(fl_value_get_type(fl_value_get_map_value(int_to_str, i)),
1037 EXPECT_STREQ(fl_value_get_string(fl_value_get_map_value(int_to_str, i)),
1038 numbers[i]);
1039 }
1040}

◆ TEST() [63/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeMapNoData   
)

◆ TEST() [64/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeMapShortData1   
)

◆ TEST() [65/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeMapShortData2   
)

Definition at line 1057 of file fl_standard_message_codec_test.cc.

1057 {
1059 "0d0707046e756c6c000704626f6f6c010703696e74032a0000000705666c6f6174060000"
1060 "00000000182d4454fb2109400706737472696e67070568656c6c6f07046c6973740c0007"
1061 "036d61700d",
1063}

◆ TEST() [66/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeMapValueTypes   
)

Definition at line 936 of file fl_standard_message_codec_test.cc.

936 {
937 g_autoptr(FlValue) value = decode_message(
938 "0d0707046e756c6c000704626f6f6c010703696e74032a0000000705666c6f6174060000"
939 "00000000182d4454fb2109400706737472696e67070568656c6c6f07046c6973740c0007"
940 "036d61700d00");
942 ASSERT_EQ(fl_value_get_length(value), static_cast<size_t>(7));
943
946 EXPECT_STREQ(fl_value_get_string(fl_value_get_map_key(value, 0)), "null");
949
952 EXPECT_STREQ(fl_value_get_string(fl_value_get_map_key(value, 1)), "bool");
956
959 EXPECT_STREQ(fl_value_get_string(fl_value_get_map_key(value, 2)), "int");
963
966 EXPECT_STREQ(fl_value_get_string(fl_value_get_map_key(value, 3)), "float");
970
973 EXPECT_STREQ(fl_value_get_string(fl_value_get_map_key(value, 4)), "string");
976 EXPECT_STREQ(fl_value_get_string(fl_value_get_map_value(value, 4)), "hello");
977
980 EXPECT_STREQ(fl_value_get_string(fl_value_get_map_key(value, 5)), "list");
984 static_cast<size_t>(0));
985
988 EXPECT_STREQ(fl_value_get_string(fl_value_get_map_key(value, 6)), "map");
992 static_cast<size_t>(0));
993}

◆ TEST() [67/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeNull   
)

Definition at line 76 of file fl_standard_message_codec_test.cc.

76 {
77 // Regression test for https://github.com/flutter/flutter/issues/128704.
78
79 g_autoptr(FlStandardMessageCodec) codec = fl_standard_message_codec_new();
80 g_autoptr(GBytes) data = g_bytes_new(nullptr, 0);
81 g_autoptr(GError) error = nullptr;
82 g_autoptr(FlValue) value =
83 fl_message_codec_decode_message(FL_MESSAGE_CODEC(codec), data, &error);
84
85 EXPECT_FALSE(value == nullptr);
87}

◆ TEST() [68/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeStringEmpty   
)

Definition at line 362 of file fl_standard_message_codec_test.cc.

362 {
363 g_autoptr(FlValue) value = decode_message("0700");
365 EXPECT_STREQ(fl_value_get_string(value), "");
366}

◆ TEST() [69/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeStringHello   
)

Definition at line 368 of file fl_standard_message_codec_test.cc.

368 {
369 g_autoptr(FlValue) value = decode_message("070568656c6c6f");
371 EXPECT_STREQ(fl_value_get_string(value), "hello");
372}

◆ TEST() [70/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeStringLengthNoData   
)

◆ TEST() [71/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeStringNoData   
)

◆ TEST() [72/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeStringShortData1   
)

◆ TEST() [73/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeStringShortData2   
)

◆ TEST() [74/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeUint8List   
)

Definition at line 413 of file fl_standard_message_codec_test.cc.

413 {
414 g_autoptr(FlValue) value = decode_message("08050001020304");
416 EXPECT_EQ(fl_value_get_length(value), static_cast<size_t>(5));
417 const uint8_t* data = fl_value_get_uint8_list(value);
418 EXPECT_EQ(data[0], 0);
419 EXPECT_EQ(data[1], 1);
420 EXPECT_EQ(data[2], 2);
421 EXPECT_EQ(data[3], 3);
422 EXPECT_EQ(data[4], 4);
423}
G_MODULE_EXPORT const uint8_t * fl_value_get_uint8_list(FlValue *self)
Definition fl_value.cc:689
@ FL_VALUE_TYPE_UINT8_LIST
Definition fl_value.h:70

◆ TEST() [75/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeUint8ListEmpty   
)

Definition at line 407 of file fl_standard_message_codec_test.cc.

407 {
408 g_autoptr(FlValue) value = decode_message("0800");
410 EXPECT_EQ(fl_value_get_length(value), static_cast<size_t>(0));
411}

◆ TEST() [76/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeUint8ListLengthNoData   
)

◆ TEST() [77/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeUint8ListNoData   
)

◆ TEST() [78/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeUint8ListShortData1   
)

◆ TEST() [79/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeUint8ListShortData2   
)

◆ TEST() [80/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeUnknownType   
)

Definition at line 1088 of file fl_standard_message_codec_test.cc.

◆ TEST() [81/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeBoolFalse   
)

Definition at line 94 of file fl_standard_message_codec_test.cc.

94 {
95 g_autofree gchar* hex_string = encode_bool(FALSE);
96 EXPECT_STREQ(hex_string, "02");
97}
static gchar * encode_bool(gboolean value)
return FALSE

◆ TEST() [82/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeBoolTrue   
)

Definition at line 99 of file fl_standard_message_codec_test.cc.

99 {
100 g_autofree gchar* hex_string = encode_bool(TRUE);
101 EXPECT_STREQ(hex_string, "01");
102}

◆ TEST() [83/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeCustomType   
)

Definition at line 1245 of file fl_standard_message_codec_test.cc.

1245 {
1246 g_autoptr(FlValue) value = fl_value_new_custom(128, "hello", nullptr);
1247 g_autoptr(FlTestStandardMessageCodec) codec =
1249 g_autofree gchar* hex_string =
1250 encode_message_with_codec(value, FL_MESSAGE_CODEC(codec));
1251 EXPECT_STREQ(hex_string, "800568656c6c6f");
1252}

◆ TEST() [84/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeCustomTypes   
)

Definition at line 1254 of file fl_standard_message_codec_test.cc.

1254 {
1255 g_autoptr(FlValue) value = fl_value_new_list();
1256 fl_value_append_take(value, fl_value_new_custom(128, "hello", nullptr));
1257 fl_value_append_take(value, fl_value_new_custom(129, nullptr, nullptr));
1258 g_autoptr(FlTestStandardMessageCodec) codec =
1260 g_autofree gchar* hex_string =
1261 encode_message_with_codec(value, FL_MESSAGE_CODEC(codec));
1262 EXPECT_STREQ(hex_string, "0c02800568656c6c6f81");
1263}
G_MODULE_EXPORT void fl_value_append_take(FlValue *self, FlValue *value)
Definition fl_value.cc:600
G_MODULE_EXPORT FlValue * fl_value_new_list()
Definition fl_value.cc:349

◆ TEST() [85/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeDecode   
)

Definition at line 1265 of file fl_standard_message_codec_test.cc.

1265 {
1266 g_autoptr(FlStandardMessageCodec) codec = fl_standard_message_codec_new();
1267
1268 g_autoptr(FlValue) input = fl_value_new_list();
1276
1277 g_autoptr(GError) error = nullptr;
1278 g_autoptr(GBytes) message =
1279 fl_message_codec_encode_message(FL_MESSAGE_CODEC(codec), input, &error);
1280 EXPECT_NE(message, nullptr);
1281 EXPECT_EQ(error, nullptr);
1282
1283 g_autoptr(FlValue) output =
1284 fl_message_codec_decode_message(FL_MESSAGE_CODEC(codec), message, &error);
1285 EXPECT_EQ(error, nullptr);
1286 EXPECT_NE(output, nullptr);
1287
1288 ASSERT_TRUE(fl_value_equal(input, output));
1289}
G_MODULE_EXPORT FlValue * fl_value_new_map()
Definition fl_value.cc:366
G_MODULE_EXPORT FlValue * fl_value_new_null()
Definition fl_value.cc:251
G_MODULE_EXPORT bool fl_value_equal(FlValue *a, FlValue *b)
Definition fl_value.cc:471

◆ TEST() [86/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeDecodeLargeList   
)

Definition at line 784 of file fl_standard_message_codec_test.cc.

784 {
785 g_autoptr(FlStandardMessageCodec) codec = fl_standard_message_codec_new();
786
787 g_autoptr(FlValue) value = fl_value_new_list();
788 for (int i = 0; i < 65535; i++) {
790 }
791
792 g_autoptr(GError) error = nullptr;
793 g_autoptr(GBytes) message =
794 fl_message_codec_encode_message(FL_MESSAGE_CODEC(codec), value, &error);
795 EXPECT_NE(message, nullptr);
796 EXPECT_EQ(error, nullptr);
797
798 g_autoptr(FlValue) decoded_value =
799 fl_message_codec_decode_message(FL_MESSAGE_CODEC(codec), message, &error);
800 EXPECT_EQ(error, nullptr);
801 EXPECT_NE(value, nullptr);
802
803 ASSERT_TRUE(fl_value_equal(value, decoded_value));
804}

◆ TEST() [87/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeDecodeLargeMap   
)

Definition at line 1065 of file fl_standard_message_codec_test.cc.

1065 {
1066 g_autoptr(FlStandardMessageCodec) codec = fl_standard_message_codec_new();
1067
1068 g_autoptr(FlValue) value = fl_value_new_map();
1069 for (int i = 0; i < 512; i++) {
1070 g_autofree gchar* key = g_strdup_printf("key%d", i);
1072 }
1073
1074 g_autoptr(GError) error = nullptr;
1075 g_autoptr(GBytes) message =
1076 fl_message_codec_encode_message(FL_MESSAGE_CODEC(codec), value, &error);
1077 EXPECT_NE(message, nullptr);
1078 EXPECT_EQ(error, nullptr);
1079
1080 g_autoptr(FlValue) decoded_value =
1081 fl_message_codec_decode_message(FL_MESSAGE_CODEC(codec), message, &error);
1082 EXPECT_EQ(error, nullptr);
1083 EXPECT_NE(value, nullptr);
1084
1085 ASSERT_TRUE(fl_value_equal(value, decoded_value));
1086}
G_MODULE_EXPORT void fl_value_set_string_take(FlValue *self, const gchar *key, FlValue *value)
Definition fl_value.cc:650

◆ TEST() [88/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloat32List   
)

Definition at line 561 of file fl_standard_message_codec_test.cc.

561 {
562 float data[] = {0.0f, -0.5f, 0.25f, -0.125f, 0.00625f};
563 g_autoptr(FlValue) value = fl_value_new_float32_list(data, 5);
564 g_autofree gchar* hex_string = encode_message(value);
565 EXPECT_STREQ(hex_string, "0e05000000000000000000bf0000803e000000becdcccc3b");
566}
G_MODULE_EXPORT FlValue * fl_value_new_float32_list(const float *data, size_t data_length)
Definition fl_value.cc:329

◆ TEST() [89/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloat32ListEmpty   
)

Definition at line 555 of file fl_standard_message_codec_test.cc.

555 {
556 g_autoptr(FlValue) value = fl_value_new_float32_list(nullptr, 0);
557 g_autofree gchar* hex_string = encode_message(value);
558 EXPECT_STREQ(hex_string, "0e000000");
559}

◆ TEST() [90/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatFraction   
)

Definition at line 252 of file fl_standard_message_codec_test.cc.

252 {
253 g_autofree gchar* hex_string = encode_float(M_PI);
254 EXPECT_STREQ(hex_string, "0600000000000000182d4454fb210940");
255}
static gchar * encode_float(double value)

◆ TEST() [91/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatHalf   
)

Definition at line 247 of file fl_standard_message_codec_test.cc.

247 {
248 g_autofree gchar* hex_string = encode_float(0.5);
249 EXPECT_STREQ(hex_string, "0600000000000000000000000000e03f");
250}

◆ TEST() [92/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatInfinity   
)

Definition at line 267 of file fl_standard_message_codec_test.cc.

267 {
268 g_autofree gchar* hex_string = encode_float(INFINITY);
269 EXPECT_STREQ(hex_string, "0600000000000000000000000000f07f");
270}

◆ TEST() [93/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatList   
)

Definition at line 613 of file fl_standard_message_codec_test.cc.

613 {
614 double data[] = {0, -0.5, 0.25, -0.125, 0.00625};
615 g_autoptr(FlValue) value = fl_value_new_float_list(data, 5);
616 g_autofree gchar* hex_string = encode_message(value);
617 EXPECT_STREQ(
618 hex_string,
619 "0b050000000000000000000000000000000000000000e0bf000000000000d03f00000000"
620 "0000c0bf9a9999999999793f");
621}
G_MODULE_EXPORT FlValue * fl_value_new_float_list(const double *data, size_t data_length)
Definition fl_value.cc:339

◆ TEST() [94/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatListEmpty   
)

Definition at line 607 of file fl_standard_message_codec_test.cc.

607 {
608 g_autoptr(FlValue) value = fl_value_new_float_list(nullptr, 0);
609 g_autofree gchar* hex_string = encode_message(value);
610 EXPECT_STREQ(hex_string, "0b00000000000000");
611}

◆ TEST() [95/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatMinusOne   
)

Definition at line 242 of file fl_standard_message_codec_test.cc.

242 {
243 g_autofree gchar* hex_string = encode_float(-1);
244 EXPECT_STREQ(hex_string, "0600000000000000000000000000f0bf");
245}

◆ TEST() [96/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatMinusZero   
)

Definition at line 257 of file fl_standard_message_codec_test.cc.

257 {
258 g_autofree gchar* hex_string = encode_float(-0.0);
259 EXPECT_STREQ(hex_string, "06000000000000000000000000000080");
260}

◆ TEST() [97/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatNaN   
)

Definition at line 262 of file fl_standard_message_codec_test.cc.

262 {
263 g_autofree gchar* hex_string = encode_float(NAN);
264 EXPECT_STREQ(hex_string, "0600000000000000000000000000f87f");
265}

◆ TEST() [98/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatOne   
)

Definition at line 237 of file fl_standard_message_codec_test.cc.

237 {
238 g_autofree gchar* hex_string = encode_float(1);
239 EXPECT_STREQ(hex_string, "0600000000000000000000000000f03f");
240}

◆ TEST() [99/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatZero   
)

Definition at line 232 of file fl_standard_message_codec_test.cc.

232 {
233 g_autofree gchar* hex_string = encode_float(0);
234 EXPECT_STREQ(hex_string, "06000000000000000000000000000000");
235}

◆ TEST() [100/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt32   
)

Definition at line 119 of file fl_standard_message_codec_test.cc.

119 {
120 g_autofree gchar* hex_string = encode_int(0x01234567);
121 EXPECT_STREQ(hex_string, "0367452301");
122}
static gchar * encode_int(int64_t value)

◆ TEST() [101/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt32List   
)

Definition at line 451 of file fl_standard_message_codec_test.cc.

451 {
452 int32_t data[] = {0, -1, 2, -3, 4};
453 g_autoptr(FlValue) value = fl_value_new_int32_list(data, 5);
454 g_autofree gchar* hex_string = encode_message(value);
455 EXPECT_STREQ(hex_string, "0905000000000000ffffffff02000000fdffffff04000000");
456}
G_MODULE_EXPORT FlValue * fl_value_new_int32_list(const int32_t *data, size_t data_length)
Definition fl_value.cc:309

◆ TEST() [102/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt32ListEmpty   
)

Definition at line 445 of file fl_standard_message_codec_test.cc.

445 {
446 g_autoptr(FlValue) value = fl_value_new_int32_list(nullptr, 0);
447 g_autofree gchar* hex_string = encode_message(value);
448 EXPECT_STREQ(hex_string, "09000000");
449}

◆ TEST() [103/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt32Max   
)

Definition at line 129 of file fl_standard_message_codec_test.cc.

129 {
130 g_autofree gchar* hex_string = encode_int(G_MAXINT32);
131 EXPECT_STREQ(hex_string, "03ffffff7f");
132}

◆ TEST() [104/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt32Min   
)

Definition at line 124 of file fl_standard_message_codec_test.cc.

124 {
125 g_autofree gchar* hex_string = encode_int(G_MININT32);
126 EXPECT_STREQ(hex_string, "0300000080");
127}

◆ TEST() [105/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt64   
)

Definition at line 134 of file fl_standard_message_codec_test.cc.

134 {
135 g_autofree gchar* hex_string = encode_int(0x0123456789abcdef);
136 EXPECT_STREQ(hex_string, "04efcdab8967452301");
137}

◆ TEST() [106/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt64List   
)

Definition at line 503 of file fl_standard_message_codec_test.cc.

503 {
504 int64_t data[] = {0, -1, 2, -3, 4};
505 g_autoptr(FlValue) value = fl_value_new_int64_list(data, 5);
506 g_autofree gchar* hex_string = encode_message(value);
507 EXPECT_STREQ(
508 hex_string,
509 "0a050000000000000000000000000000ffffffffffffffff0200000000000000fdffffff"
510 "ffffffff0400000000000000");
511}
G_MODULE_EXPORT FlValue * fl_value_new_int64_list(const int64_t *data, size_t data_length)
Definition fl_value.cc:319

◆ TEST() [107/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt64ListEmpty   
)

Definition at line 497 of file fl_standard_message_codec_test.cc.

497 {
498 g_autoptr(FlValue) value = fl_value_new_int64_list(nullptr, 0);
499 g_autofree gchar* hex_string = encode_message(value);
500 EXPECT_STREQ(hex_string, "0a00000000000000");
501}

◆ TEST() [108/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt64Max   
)

Definition at line 144 of file fl_standard_message_codec_test.cc.

144 {
145 g_autofree gchar* hex_string = encode_int(G_MAXINT64);
146 EXPECT_STREQ(hex_string, "04ffffffffffffff7f");
147}

◆ TEST() [109/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt64Min   
)

Definition at line 139 of file fl_standard_message_codec_test.cc.

139 {
140 g_autofree gchar* hex_string = encode_int(G_MININT64);
141 EXPECT_STREQ(hex_string, "040000000000000080");
142}

◆ TEST() [110/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeIntOne   
)

Definition at line 114 of file fl_standard_message_codec_test.cc.

114 {
115 g_autofree gchar* hex_string = encode_int(1);
116 EXPECT_STREQ(hex_string, "0301000000");
117}

◆ TEST() [111/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeIntZero   
)

Definition at line 109 of file fl_standard_message_codec_test.cc.

109 {
110 g_autofree gchar* hex_string = encode_int(0);
111 EXPECT_STREQ(hex_string, "0300000000");
112}

◆ TEST() [112/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeListEmpty   
)

Definition at line 665 of file fl_standard_message_codec_test.cc.

665 {
666 g_autoptr(FlValue) value = fl_value_new_list();
667 g_autofree gchar* hex_string = encode_message(value);
668 EXPECT_STREQ(hex_string, "0c00");
669}

◆ TEST() [113/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeListNested   
)

Definition at line 686 of file fl_standard_message_codec_test.cc.

686 {
687 g_autoptr(FlValue) even_numbers = fl_value_new_list();
688 g_autoptr(FlValue) odd_numbers = fl_value_new_list();
689 for (int i = 0; i < 10; i++) {
690 if (i % 2 == 0) {
691 fl_value_append_take(even_numbers, fl_value_new_int(i));
692 } else {
693 fl_value_append_take(odd_numbers, fl_value_new_int(i));
694 }
695 }
696 g_autoptr(FlValue) value = fl_value_new_list();
697 fl_value_append(value, even_numbers);
698 fl_value_append(value, odd_numbers);
699 g_autofree gchar* hex_string = encode_message(value);
700 EXPECT_STREQ(hex_string,
701 "0c020c05030000000003020000000304000000030600000003080000000c"
702 "0503010000000303000000030500000003070000000309000000");
703}
G_MODULE_EXPORT void fl_value_append(FlValue *self, FlValue *value)
Definition fl_value.cc:592

◆ TEST() [114/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeListTypes   
)

Definition at line 671 of file fl_standard_message_codec_test.cc.

671 {
672 g_autoptr(FlValue) value = fl_value_new_list();
680 g_autofree gchar* hex_string = encode_message(value);
681 EXPECT_STREQ(
682 hex_string,
683 "0c070001032a00000006000000000000182d4454fb210940070568656c6c6f0c000d00");
684}

◆ TEST() [115/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeMapEmpty   
)

Definition at line 806 of file fl_standard_message_codec_test.cc.

806 {
807 g_autoptr(FlValue) value = fl_value_new_map();
808 g_autofree gchar* hex_string = encode_message(value);
809 EXPECT_STREQ(hex_string, "0d00");
810}

◆ TEST() [116/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeMapKeyTypes   
)

Definition at line 812 of file fl_standard_message_codec_test.cc.

812 {
813 g_autoptr(FlValue) value = fl_value_new_map();
816 fl_value_new_string("bool"));
819 fl_value_new_string("float"));
821 fl_value_new_string("string"));
824 g_autofree gchar* hex_string = encode_message(value);
825 EXPECT_STREQ(hex_string,
826 "0d070007046e756c6c010704626f6f6c032a0000000703696e7406000000000"
827 "0182d4454fb2109400705666c6f6174070568656c6c6f0706737472696e670c"
828 "0007046c6973740d0007036d6170");
829}
G_MODULE_EXPORT void fl_value_set_take(FlValue *self, FlValue *key, FlValue *value)
Definition fl_value.cc:618

◆ TEST() [117/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeMapNested   
)

Definition at line 850 of file fl_standard_message_codec_test.cc.

850 {
851 g_autoptr(FlValue) str_to_int = fl_value_new_map();
852 g_autoptr(FlValue) int_to_str = fl_value_new_map();
853 const char* numbers[] = {"zero", "one", "two", "three", nullptr};
854 for (int i = 0; numbers[i] != nullptr; i++) {
855 fl_value_set_take(str_to_int, fl_value_new_string(numbers[i]),
857 fl_value_set_take(int_to_str, fl_value_new_int(i),
858 fl_value_new_string(numbers[i]));
859 }
860 g_autoptr(FlValue) value = fl_value_new_map();
861 fl_value_set_string(value, "str-to-int", str_to_int);
862 fl_value_set_string(value, "int-to-str", int_to_str);
863 g_autofree gchar* hex_string = encode_message(value);
864 EXPECT_STREQ(hex_string,
865 "0d02070a7374722d746f2d696e740d0407047a65726f030000000007036f6e6"
866 "50301000000070374776f0302000000070574687265650303000000070a696e"
867 "742d746f2d7374720d04030000000007047a65726f030100000007036f6e650"
868 "302000000070374776f030300000007057468726565");
869}
G_MODULE_EXPORT void fl_value_set_string(FlValue *self, const gchar *key, FlValue *value)
Definition fl_value.cc:639

◆ TEST() [118/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeMapValueTypes   
)

Definition at line 831 of file fl_standard_message_codec_test.cc.

831 {
832 g_autoptr(FlValue) value = fl_value_new_map();
840 fl_value_new_string("hello"));
843 g_autofree gchar* hex_string = encode_message(value);
844 EXPECT_STREQ(hex_string,
845 "0d0707046e756c6c000704626f6f6c010703696e74032a0000000705666c6f6"
846 "17406000000000000182d4454fb2109400706737472696e67070568656c6c6f"
847 "07046c6973740c0007036d61700d00");
848}

◆ TEST() [119/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeNull   
)

Definition at line 70 of file fl_standard_message_codec_test.cc.

70 {
71 g_autoptr(FlValue) value = fl_value_new_null();
72 g_autofree gchar* hex_string = encode_message(value);
73 EXPECT_STREQ(hex_string, "00");
74}

◆ TEST() [120/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeNullptr   
)

Definition at line 65 of file fl_standard_message_codec_test.cc.

65 {
66 g_autofree gchar* hex_string = encode_message(nullptr);
67 EXPECT_STREQ(hex_string, "00");
68}

◆ TEST() [121/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeStringEmpty   
)

Definition at line 340 of file fl_standard_message_codec_test.cc.

340 {
341 g_autofree gchar* hex_string = encode_string("");
342 EXPECT_STREQ(hex_string, "0700");
343}
static gchar * encode_string(const gchar *value)

◆ TEST() [122/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeStringEmptySized   
)

Definition at line 350 of file fl_standard_message_codec_test.cc.

350 {
351 g_autoptr(FlValue) value = fl_value_new_string_sized(nullptr, 0);
352 g_autofree gchar* hex_string = encode_message(value);
353 EXPECT_STREQ(hex_string, "0700");
354}
G_MODULE_EXPORT FlValue * fl_value_new_string_sized(const gchar *value, size_t value_length)
Definition fl_value.cc:283

◆ TEST() [123/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeStringHello   
)

Definition at line 345 of file fl_standard_message_codec_test.cc.

345 {
346 g_autofree gchar* hex_string = encode_string("hello");
347 EXPECT_STREQ(hex_string, "070568656c6c6f");
348}

◆ TEST() [124/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeStringHelloSized   
)

Definition at line 356 of file fl_standard_message_codec_test.cc.

356 {
357 g_autoptr(FlValue) value = fl_value_new_string_sized("Hello World", 5);
358 g_autofree gchar* hex_string = encode_message(value);
359 EXPECT_STREQ(hex_string, "070548656c6c6f");
360}

◆ TEST() [125/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeUint8List   
)

Definition at line 400 of file fl_standard_message_codec_test.cc.

400 {
401 uint8_t data[] = {0, 1, 2, 3, 4};
402 g_autoptr(FlValue) value = fl_value_new_uint8_list(data, 5);
403 g_autofree gchar* hex_string = encode_message(value);
404 EXPECT_STREQ(hex_string, "08050001020304");
405}
G_MODULE_EXPORT FlValue * fl_value_new_uint8_list(const uint8_t *data, size_t data_length)
Definition fl_value.cc:292

◆ TEST() [126/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeUint8ListEmpty   
)

Definition at line 394 of file fl_standard_message_codec_test.cc.

394 {
395 g_autoptr(FlValue) value = fl_value_new_uint8_list(nullptr, 0);
396 g_autofree gchar* hex_string = encode_message(value);
397 EXPECT_STREQ(hex_string, "0800");
398}

◆ write_custom_value2()

static gboolean write_custom_value2 ( FlStandardMessageCodec *  codec,
GByteArray *  buffer,
FlValue value,
GError **  error 
)
static

Definition at line 1122 of file fl_standard_message_codec_test.cc.

1125 {
1126 uint8_t type = 129;
1127 g_byte_array_append(buffer, &type, sizeof(uint8_t));
1128 return TRUE;
1129}
g_byte_array_append(buffer, &type, sizeof(uint8_t))

Variable Documentation

◆ buffer

GByteArray* buffer

Definition at line 1108 of file fl_standard_message_codec_test.cc.

◆ error

GByteArray FlValue GError** error
Initial value:
{
const gchar* text =
static_cast<const gchar*>(fl_value_get_custom_value(value))
std::u16string text

Definition at line 1110 of file fl_standard_message_codec_test.cc.

◆ length

size_t length = strlen(text)

Definition at line 1113 of file fl_standard_message_codec_test.cc.

◆ TRUE

return TRUE

Definition at line 1119 of file fl_standard_message_codec_test.cc.

◆ type

uint8_t type = 128

Definition at line 1115 of file fl_standard_message_codec_test.cc.

◆ value

GByteArray FlValue* value

Definition at line 1109 of file fl_standard_message_codec_test.cc.