Flutter Linux Embedder
fl_standard_message_codec_test.cc File Reference
#include "flutter/shell/platform/linux/public/flutter_linux/fl_standard_message_codec.h"
#include <cmath>
#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 55 of file fl_standard_message_codec_test.cc.

57  {
58  g_autoptr(FlStandardMessageCodec) codec = fl_standard_message_codec_new();
59  g_autoptr(GBytes) data = hex_string_to_bytes(hex_string);
60  g_autoptr(GError) error = nullptr;
61  g_autoptr(FlValue) value =
62  fl_message_codec_decode_message(FL_MESSAGE_CODEC(codec), data, &error);
63  EXPECT_TRUE(value == nullptr);
64  EXPECT_TRUE(g_error_matches(error, domain, code));
65 }
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
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42

References error, fl_message_codec_decode_message(), fl_standard_message_codec_new(), and value.

Referenced by TEST().

◆ decode_message()

static FlValue* decode_message ( const char *  hex_string)
static

Definition at line 48 of file fl_standard_message_codec_test.cc.

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

References decode_message_with_codec(), and fl_standard_message_codec_new().

Referenced by TEST().

◆ decode_message_with_codec()

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

Definition at line 35 of file fl_standard_message_codec_test.cc.

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

References error, fl_message_codec_decode_message(), fl_value_ref(), and value.

Referenced by decode_message(), and TEST().

◆ encode_bool()

static gchar* encode_bool ( gboolean  value)
static

Definition at line 91 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_bool(), and value.

Referenced by TEST().

◆ encode_float()

static gchar* encode_float ( double  value)
static

Definition at line 229 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_float(), and value.

Referenced by TEST().

◆ encode_int()

static gchar* encode_int ( int64_t  value)
static

Definition at line 106 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_int(), and value.

Referenced by TEST().

◆ encode_message()

static gchar* encode_message ( FlValue value)
static

Definition at line 28 of file fl_standard_message_codec_test.cc.

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

References encode_message_with_codec(), fl_standard_message_codec_new(), and value.

Referenced by encode_bool(), encode_float(), encode_int(), encode_string(), and TEST().

◆ encode_message_with_codec()

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

Definition at line 16 of file fl_standard_message_codec_test.cc.

16  {
17  g_autoptr(GError) error = nullptr;
18  g_autoptr(GBytes) message =
20  EXPECT_NE(message, nullptr);
21  EXPECT_EQ(error, nullptr);
22 
23  return bytes_to_hex_string(message);
24 }
G_MODULE_EXPORT GBytes * fl_message_codec_encode_message(FlMessageCodec *self, FlValue *message, GError **error)

References error, fl_message_codec_encode_message(), and value.

Referenced by encode_message(), and TEST().

◆ encode_string()

static gchar* encode_string ( const gchar *  value)
static

Definition at line 337 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_string(), and value.

Referenced by TEST().

◆ 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 1200 of file fl_standard_message_codec_test.cc.

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

References fl_test_standard_message_codec_read_value_of_type(), and fl_test_standard_message_codec_write_value().

◆ fl_test_standard_message_codec_init()

static void fl_test_standard_message_codec_init ( FlTestStandardMessageCodec *  self)
static

Definition at line 1208 of file fl_standard_message_codec_test.cc.

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

◆ fl_test_standard_message_codec_new()

static FlTestStandardMessageCodec* fl_test_standard_message_codec_new ( )
static

Definition at line 1214 of file fl_standard_message_codec_test.cc.

1214  {
1215  return FL_TEST_STANDARD_MESSAGE_CODEC(
1216  g_object_new(fl_test_standard_message_codec_get_type(), nullptr));
1217 }

Referenced by TEST().

◆ 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 1183 of file fl_standard_message_codec_test.cc.

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

References buffer, error, read_custom_value1(), read_custom_value2(), and type.

Referenced by fl_test_standard_message_codec_class_init().

◆ 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 1133 of file fl_standard_message_codec_test.cc.

1137  {
1139  fl_value_get_custom_type(value) == 128) {
1140  return write_custom_value1(codec, buffer, value, error);
1141  } else if (fl_value_get_type(value) == FL_VALUE_TYPE_CUSTOM &&
1142  fl_value_get_custom_type(value) == 129) {
1143  return write_custom_value2(codec, buffer, value, error);
1144  } else {
1145  return FL_STANDARD_MESSAGE_CODEC_CLASS(
1146  fl_test_standard_message_codec_parent_class)
1147  ->write_value(codec, buffer, value, error);
1148  }
1149 }
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:76

References buffer, error, fl_value_get_custom_type(), fl_value_get_type(), FL_VALUE_TYPE_CUSTOM, value, and write_custom_value2().

Referenced by fl_test_standard_message_codec_class_init().

◆ g_byte_array_append() [1/2]

◆ 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 1095 of file fl_standard_message_codec_test.cc.

1101  {
1102  FlStandardMessageCodec parent_instance;
1103 };

◆ 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 1151 of file fl_standard_message_codec_test.cc.

1154  {
1155  uint32_t length;
1156  if (!fl_standard_message_codec_read_size(codec, buffer, offset, &length,
1157  error)) {
1158  return nullptr;
1159  }
1160  if (*offset + length > g_bytes_get_size(buffer)) {
1161  g_set_error(error, FL_MESSAGE_CODEC_ERROR,
1162  FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA, "Unexpected end of data");
1163  return nullptr;
1164  }
1166  128,
1167  g_strndup(static_cast<const gchar*>(g_bytes_get_data(buffer, nullptr)) +
1168  *offset,
1169  length),
1170  g_free);
1171  *offset += length;
1172 
1173  return value;
1174 }
@ 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

References buffer, error, FL_MESSAGE_CODEC_ERROR, FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA, fl_standard_message_codec_read_size(), fl_value_new_custom(), length, and value.

Referenced by fl_test_standard_message_codec_read_value_of_type().

◆ read_custom_value2()

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

Definition at line 1176 of file fl_standard_message_codec_test.cc.

1179  {
1180  return fl_value_new_custom(129, nullptr, nullptr);
1181 }

References fl_value_new_custom().

Referenced by fl_test_standard_message_codec_read_value_of_type().

◆ TEST() [1/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeCustomType   
)

Definition at line 1219 of file fl_standard_message_codec_test.cc.

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

References decode_message_with_codec(), fl_test_standard_message_codec_new(), fl_value_get_custom_type(), fl_value_get_custom_value(), fl_value_get_type(), FL_VALUE_TYPE_CUSTOM, and value.

◆ TEST() [2/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeCustomTypes   
)

Definition at line 1230 of file fl_standard_message_codec_test.cc.

1230  {
1231  g_autoptr(FlTestStandardMessageCodec) codec =
1233  g_autoptr(FlValue) value = decode_message_with_codec("0c02800568656c6c6f81",
1234  FL_MESSAGE_CODEC(codec));
1236  EXPECT_EQ(fl_value_get_length(value), static_cast<size_t>(2));
1237  FlValue* value1 = fl_value_get_list_value(value, 0);
1238  ASSERT_EQ(fl_value_get_type(value1), FL_VALUE_TYPE_CUSTOM);
1239  ASSERT_EQ(fl_value_get_custom_type(value1), 128);
1240  EXPECT_STREQ(static_cast<const gchar*>(fl_value_get_custom_value(value1)),
1241  "hello");
1242  FlValue* value2 = fl_value_get_list_value(value, 1);
1243  ASSERT_EQ(fl_value_get_type(value2), FL_VALUE_TYPE_CUSTOM);
1244  ASSERT_EQ(fl_value_get_custom_type(value2), 129);
1245 }
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:73

References decode_message_with_codec(), fl_test_standard_message_codec_new(), fl_value_get_custom_type(), fl_value_get_custom_value(), fl_value_get_length(), fl_value_get_list_value(), fl_value_get_type(), FL_VALUE_TYPE_CUSTOM, FL_VALUE_TYPE_LIST, and value.

◆ TEST() [3/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloat32List   
)

Definition at line 576 of file fl_standard_message_codec_test.cc.

576  {
577  g_autoptr(FlValue) value =
578  decode_message("0e05000000000000000000bf0000803e000000becdcccc3b");
580  const float* data = fl_value_get_float32_list(value);
581  EXPECT_FLOAT_EQ(data[0], 0.0f);
582  EXPECT_FLOAT_EQ(data[1], -0.5f);
583  EXPECT_FLOAT_EQ(data[2], 0.25f);
584  EXPECT_FLOAT_EQ(data[3], -0.125f);
585  EXPECT_FLOAT_EQ(data[4], 0.00625f);
586 }
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:75

References decode_message(), fl_value_get_float32_list(), fl_value_get_type(), FL_VALUE_TYPE_FLOAT32_LIST, and value.

◆ TEST() [4/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloat32ListEmpty   
)

Definition at line 570 of file fl_standard_message_codec_test.cc.

570  {
571  g_autoptr(FlValue) value = decode_message("0e000000");
573  EXPECT_EQ(fl_value_get_length(value), static_cast<size_t>(0));
574 }

References decode_message(), fl_value_get_length(), fl_value_get_type(), FL_VALUE_TYPE_FLOAT32_LIST, and value.

◆ TEST() [5/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloat32ListLengthNoData   
)

Definition at line 593 of file fl_standard_message_codec_test.cc.

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

References decode_error_value(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA.

◆ TEST() [6/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloat32ListNoData   
)

◆ TEST() [7/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloat32ListShortData1   
)

◆ TEST() [8/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloat32ListShortData2   
)

Definition at line 603 of file fl_standard_message_codec_test.cc.

603  {
604  decode_error_value("0e05000000000000000000bf0000803e000000becdcccc",
607 }

References decode_error_value(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA.

◆ TEST() [9/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatHalf   
)

Definition at line 292 of file fl_standard_message_codec_test.cc.

292  {
293  g_autoptr(FlValue) value = decode_message("0600000000000000000000000000e03f");
295  EXPECT_EQ(fl_value_get_float(value), 0.5);
296 }
G_MODULE_EXPORT double fl_value_get_float(FlValue *self)
Definition: fl_value.cc:675
@ FL_VALUE_TYPE_FLOAT
Definition: fl_value.h:67

References decode_message(), fl_value_get_float(), fl_value_get_type(), FL_VALUE_TYPE_FLOAT, and value.

◆ TEST() [10/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatInfinity   
)

Definition at line 316 of file fl_standard_message_codec_test.cc.

316  {
317  g_autoptr(FlValue) value = decode_message("0600000000000000000000000000f07f");
319  EXPECT_TRUE(isinf(fl_value_get_float(value)));
320 }

References decode_message(), fl_value_get_float(), fl_value_get_type(), FL_VALUE_TYPE_FLOAT, and value.

◆ TEST() [11/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatList   
)

Definition at line 631 of file fl_standard_message_codec_test.cc.

631  {
632  g_autoptr(FlValue) value = decode_message(
633  "0b050000000000000000000000000000000000000000e0bf000000000000d03f00000000"
634  "0000c0bf9a9999999999793f");
636  const double* data = fl_value_get_float_list(value);
637  EXPECT_FLOAT_EQ(data[0], 0.0);
638  EXPECT_FLOAT_EQ(data[1], -0.5);
639  EXPECT_FLOAT_EQ(data[2], 0.25);
640  EXPECT_FLOAT_EQ(data[3], -0.125);
641  EXPECT_FLOAT_EQ(data[4], 0.00625);
642 }
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:72

References decode_message(), fl_value_get_float_list(), fl_value_get_type(), FL_VALUE_TYPE_FLOAT_LIST, and value.

◆ TEST() [12/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatListEmpty   
)

Definition at line 625 of file fl_standard_message_codec_test.cc.

625  {
626  g_autoptr(FlValue) value = decode_message("0b00000000000000");
628  EXPECT_EQ(fl_value_get_length(value), static_cast<size_t>(0));
629 }

References decode_message(), fl_value_get_length(), fl_value_get_type(), FL_VALUE_TYPE_FLOAT_LIST, and value.

◆ TEST() [13/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatListLengthNoData   
)

◆ TEST() [14/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatListNoData   
)

◆ TEST() [15/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatListShortData1   
)

◆ TEST() [16/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatListShortData2   
)

Definition at line 659 of file fl_standard_message_codec_test.cc.

659  {
661  "0b050000000000000000000000000000000000000000e0bf000000000000d03f00000000"
662  "0000c0bf9a99"
663  "9999999979",
665 }

References decode_error_value(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA.

◆ TEST() [17/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatMinusOne   
)

Definition at line 286 of file fl_standard_message_codec_test.cc.

286  {
287  g_autoptr(FlValue) value = decode_message("0600000000000000000000000000f0bf");
289  EXPECT_EQ(fl_value_get_float(value), -1.0);
290 }

References decode_message(), fl_value_get_float(), fl_value_get_type(), FL_VALUE_TYPE_FLOAT, and value.

◆ TEST() [18/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatMinusZero   
)

Definition at line 304 of file fl_standard_message_codec_test.cc.

304  {
305  g_autoptr(FlValue) value = decode_message("06000000000000000000000000000080");
307  EXPECT_EQ(fl_value_get_float(value), -0.0);
308 }

References decode_message(), fl_value_get_float(), fl_value_get_type(), FL_VALUE_TYPE_FLOAT, and value.

◆ TEST() [19/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatNaN   
)

Definition at line 310 of file fl_standard_message_codec_test.cc.

310  {
311  g_autoptr(FlValue) value = decode_message("0600000000000000000000000000f87f");
313  EXPECT_TRUE(isnan(fl_value_get_float(value)));
314 }

References decode_message(), fl_value_get_float(), fl_value_get_type(), FL_VALUE_TYPE_FLOAT, and value.

◆ TEST() [20/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatNoData   
)

◆ TEST() [21/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatOne   
)

Definition at line 280 of file fl_standard_message_codec_test.cc.

280  {
281  g_autoptr(FlValue) value = decode_message("0600000000000000000000000000f03f");
283  EXPECT_EQ(fl_value_get_float(value), 1.0);
284 }

References decode_message(), fl_value_get_float(), fl_value_get_type(), FL_VALUE_TYPE_FLOAT, and value.

◆ TEST() [22/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatPi   
)

Definition at line 298 of file fl_standard_message_codec_test.cc.

298  {
299  g_autoptr(FlValue) value = decode_message("0600000000000000182d4454fb210940");
301  EXPECT_EQ(fl_value_get_float(value), M_PI);
302 }

References decode_message(), fl_value_get_float(), fl_value_get_type(), FL_VALUE_TYPE_FLOAT, and value.

◆ TEST() [23/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatShortData1   
)

◆ TEST() [24/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatShortData2   
)

◆ TEST() [25/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeFloatZero   
)

Definition at line 274 of file fl_standard_message_codec_test.cc.

274  {
275  g_autoptr(FlValue) value = decode_message("06000000000000000000000000000000");
277  EXPECT_EQ(fl_value_get_float(value), 0.0);
278 }

References decode_message(), fl_value_get_float(), fl_value_get_type(), FL_VALUE_TYPE_FLOAT, and value.

◆ TEST() [26/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt32   
)

Definition at line 163 of file fl_standard_message_codec_test.cc.

163  {
164  g_autoptr(FlValue) value = decode_message("0367452301");
166  EXPECT_EQ(fl_value_get_int(value), 0x01234567);
167 }
G_MODULE_EXPORT int64_t fl_value_get_int(FlValue *self)
Definition: fl_value.cc:668
@ FL_VALUE_TYPE_INT
Definition: fl_value.h:66

References decode_message(), fl_value_get_int(), fl_value_get_type(), FL_VALUE_TYPE_INT, and value.

◆ TEST() [27/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt32List   
)

Definition at line 466 of file fl_standard_message_codec_test.cc.

466  {
467  g_autoptr(FlValue) value =
468  decode_message("0905000000000000ffffffff02000000fdffffff04000000");
470  const int32_t* data = fl_value_get_int32_list(value);
471  EXPECT_EQ(data[0], 0);
472  EXPECT_EQ(data[1], -1);
473  EXPECT_EQ(data[2], 2);
474  EXPECT_EQ(data[3], -3);
475  EXPECT_EQ(data[4], 4);
476 }
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:70

References decode_message(), fl_value_get_int32_list(), fl_value_get_type(), FL_VALUE_TYPE_INT32_LIST, and value.

◆ TEST() [28/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt32ListEmpty   
)

Definition at line 460 of file fl_standard_message_codec_test.cc.

460  {
461  g_autoptr(FlValue) value = decode_message("09000000");
463  EXPECT_EQ(fl_value_get_length(value), static_cast<size_t>(0));
464 }

References decode_message(), fl_value_get_length(), fl_value_get_type(), FL_VALUE_TYPE_INT32_LIST, and value.

◆ 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 493 of file fl_standard_message_codec_test.cc.

493  {
494  decode_error_value("090500000000ffffffff02000000fdffffff040000",
497 }

References decode_error_value(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA.

◆ TEST() [33/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt32Max   
)

Definition at line 175 of file fl_standard_message_codec_test.cc.

175  {
176  g_autoptr(FlValue) value = decode_message("03ffffff7f");
178  EXPECT_EQ(fl_value_get_int(value), G_MAXINT32);
179 }

References decode_message(), fl_value_get_int(), fl_value_get_type(), FL_VALUE_TYPE_INT, and value.

◆ TEST() [34/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt32Min   
)

Definition at line 169 of file fl_standard_message_codec_test.cc.

169  {
170  g_autoptr(FlValue) value = decode_message("0300000080");
172  EXPECT_EQ(fl_value_get_int(value), G_MININT32);
173 }

References decode_message(), fl_value_get_int(), fl_value_get_type(), FL_VALUE_TYPE_INT, and value.

◆ TEST() [35/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt32NoData   
)

◆ TEST() [36/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64   
)

Definition at line 181 of file fl_standard_message_codec_test.cc.

181  {
182  g_autoptr(FlValue) value = decode_message("04efcdab8967452301");
184  EXPECT_EQ(fl_value_get_int(value), 0x0123456789abcdef);
185 }

References decode_message(), fl_value_get_int(), fl_value_get_type(), FL_VALUE_TYPE_INT, and value.

◆ TEST() [37/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64List   
)

Definition at line 521 of file fl_standard_message_codec_test.cc.

521  {
522  g_autoptr(FlValue) value = decode_message(
523  "0a050000000000000000000000000000ffffffffffffffff0200000000000000fdffffff"
524  "ffffffff0400000000000000");
526  const int64_t* data = fl_value_get_int64_list(value);
527  EXPECT_EQ(data[0], 0);
528  EXPECT_EQ(data[1], -1);
529  EXPECT_EQ(data[2], 2);
530  EXPECT_EQ(data[3], -3);
531  EXPECT_EQ(data[4], 4);
532 }
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:71

References decode_message(), fl_value_get_int64_list(), fl_value_get_type(), FL_VALUE_TYPE_INT64_LIST, and value.

◆ TEST() [38/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64ListEmpty   
)

Definition at line 515 of file fl_standard_message_codec_test.cc.

515  {
516  g_autoptr(FlValue) value = decode_message("0a00000000000000");
518  EXPECT_EQ(fl_value_get_length(value), static_cast<size_t>(0));
519 }

References decode_message(), fl_value_get_length(), fl_value_get_type(), FL_VALUE_TYPE_INT64_LIST, and value.

◆ TEST() [39/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64ListLengthNoData   
)

◆ TEST() [40/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64ListNoData   
)

◆ TEST() [41/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64ListShortData1   
)

◆ TEST() [42/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64ListShortData2   
)

Definition at line 549 of file fl_standard_message_codec_test.cc.

549  {
551  "0a050000000000000000000000000000ffffffffffffffff0200000000000000fdffffff"
552  "ffffffff0400"
553  "0000000000",
555 }

References decode_error_value(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA.

◆ TEST() [43/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64Max   
)

Definition at line 193 of file fl_standard_message_codec_test.cc.

193  {
194  g_autoptr(FlValue) value = decode_message("04ffffffffffffff7f");
196  EXPECT_EQ(fl_value_get_int(value), G_MAXINT64);
197 }

References decode_message(), fl_value_get_int(), fl_value_get_type(), FL_VALUE_TYPE_INT, and value.

◆ TEST() [44/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64Min   
)

Definition at line 187 of file fl_standard_message_codec_test.cc.

187  {
188  g_autoptr(FlValue) value = decode_message("040000000000000080");
190  EXPECT_EQ(fl_value_get_int(value), G_MININT64);
191 }

References decode_message(), fl_value_get_int(), fl_value_get_type(), FL_VALUE_TYPE_INT, and value.

◆ TEST() [45/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64NoData   
)

◆ TEST() [46/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64ShortData1   
)

◆ TEST() [47/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeInt64ShortData2   
)

◆ TEST() [48/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeIntOne   
)

Definition at line 157 of file fl_standard_message_codec_test.cc.

157  {
158  g_autoptr(FlValue) value = decode_message("0301000000");
160  EXPECT_EQ(fl_value_get_int(value), 1);
161 }

References decode_message(), fl_value_get_int(), fl_value_get_type(), FL_VALUE_TYPE_INT, and value.

◆ TEST() [49/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeIntShortData1   
)

◆ TEST() [50/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeIntShortData2   
)

◆ TEST() [51/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeIntZero   
)

Definition at line 151 of file fl_standard_message_codec_test.cc.

151  {
152  g_autoptr(FlValue) value = decode_message("0300000000");
154  EXPECT_EQ(fl_value_get_int(value), 0);
155 }

References decode_message(), fl_value_get_int(), fl_value_get_type(), FL_VALUE_TYPE_INT, and value.

◆ TEST() [52/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeListEmpty   
)

Definition at line 707 of file fl_standard_message_codec_test.cc.

707  {
708  g_autoptr(FlValue) value = decode_message("0c00");
710  EXPECT_EQ(fl_value_get_length(value), static_cast<size_t>(0));
711 }

References decode_message(), fl_value_get_length(), fl_value_get_type(), FL_VALUE_TYPE_LIST, and value.

◆ TEST() [53/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeListLengthNoData   
)

◆ TEST() [54/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeListNested   
)

Definition at line 742 of file fl_standard_message_codec_test.cc.

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

References decode_message(), fl_value_get_int(), fl_value_get_length(), fl_value_get_list_value(), fl_value_get_type(), FL_VALUE_TYPE_INT, FL_VALUE_TYPE_LIST, i, and value.

◆ TEST() [55/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeListNoData   
)

◆ TEST() [56/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeListShortData1   
)

◆ TEST() [57/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeListShortData2   
)

Definition at line 780 of file fl_standard_message_codec_test.cc.

780  {
782  "0c070001032a00000006000000000000182d4454fb210940070568656c6c6f0c000d",
784 }

References decode_error_value(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA.

◆ TEST() [58/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeListTypes   
)

Definition at line 713 of file fl_standard_message_codec_test.cc.

713  {
714  g_autoptr(FlValue) value = decode_message(
715  "0c070001032a00000006000000000000182d4454fb210940070568656c6c6f0c000d00");
717  ASSERT_EQ(fl_value_get_length(value), static_cast<size_t>(7));
725  EXPECT_EQ(fl_value_get_int(fl_value_get_list_value(value, 2)), 42);
728  EXPECT_FLOAT_EQ(fl_value_get_float(fl_value_get_list_value(value, 3)), M_PI);
731  EXPECT_STREQ(fl_value_get_string(fl_value_get_list_value(value, 4)), "hello");
735  static_cast<size_t>(0));
739  static_cast<size_t>(0));
740 }
G_MODULE_EXPORT bool fl_value_get_bool(FlValue *self)
Definition: fl_value.cc:661
G_MODULE_EXPORT const gchar * fl_value_get_string(FlValue *self)
Definition: fl_value.cc:682
@ FL_VALUE_TYPE_STRING
Definition: fl_value.h:68
@ FL_VALUE_TYPE_NULL
Definition: fl_value.h:64
@ FL_VALUE_TYPE_BOOL
Definition: fl_value.h:65
@ FL_VALUE_TYPE_MAP
Definition: fl_value.h:74

References decode_message(), fl_value_get_bool(), fl_value_get_float(), fl_value_get_int(), fl_value_get_length(), fl_value_get_list_value(), fl_value_get_string(), fl_value_get_type(), FL_VALUE_TYPE_BOOL, FL_VALUE_TYPE_FLOAT, FL_VALUE_TYPE_INT, FL_VALUE_TYPE_LIST, FL_VALUE_TYPE_MAP, FL_VALUE_TYPE_NULL, FL_VALUE_TYPE_STRING, and value.

◆ TEST() [59/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeMapEmpty   
)

Definition at line 873 of file fl_standard_message_codec_test.cc.

873  {
874  g_autoptr(FlValue) value = decode_message("0d00");
876  ASSERT_EQ(fl_value_get_length(value), static_cast<size_t>(0));
877 }

References decode_message(), fl_value_get_length(), fl_value_get_type(), FL_VALUE_TYPE_MAP, and value.

◆ TEST() [60/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeMapKeyTypes   
)

Definition at line 879 of file fl_standard_message_codec_test.cc.

879  {
880  g_autoptr(FlValue) value = decode_message(
881  "0d070007046e756c6c010704626f6f6c032a0000000703696e74060000000000182d4454"
882  "fb2109400705666c6f6174070568656c6c6f0706737472696e670c0007046c6973740d00"
883  "07036d6170");
885  ASSERT_EQ(fl_value_get_length(value), static_cast<size_t>(7));
886 
891  EXPECT_STREQ(fl_value_get_string(fl_value_get_map_value(value, 0)), "null");
892 
895  EXPECT_TRUE(fl_value_get_bool(fl_value_get_map_key(value, 1)));
898  EXPECT_STREQ(fl_value_get_string(fl_value_get_map_value(value, 1)), "bool");
899 
902  EXPECT_EQ(fl_value_get_int(fl_value_get_map_key(value, 2)), 42);
905  EXPECT_STREQ(fl_value_get_string(fl_value_get_map_value(value, 2)), "int");
906 
909  EXPECT_FLOAT_EQ(fl_value_get_float(fl_value_get_map_key(value, 3)), M_PI);
912  EXPECT_STREQ(fl_value_get_string(fl_value_get_map_value(value, 3)), "float");
913 
916  EXPECT_STREQ(fl_value_get_string(fl_value_get_map_key(value, 4)), "hello");
919  EXPECT_STREQ(fl_value_get_string(fl_value_get_map_value(value, 4)), "string");
920 
924  static_cast<size_t>(0));
927  EXPECT_STREQ(fl_value_get_string(fl_value_get_map_value(value, 5)), "list");
928 
932  static_cast<size_t>(0));
935  EXPECT_STREQ(fl_value_get_string(fl_value_get_map_value(value, 6)), "map");
936 }
G_MODULE_EXPORT FlValue * fl_value_get_map_value(FlValue *self, size_t index)
Definition: fl_value.cc:792
G_MODULE_EXPORT FlValue * fl_value_get_map_key(FlValue *self, size_t index)
Definition: fl_value.cc:784

References decode_message(), fl_value_get_bool(), fl_value_get_float(), fl_value_get_int(), fl_value_get_length(), fl_value_get_map_key(), fl_value_get_map_value(), fl_value_get_string(), fl_value_get_type(), FL_VALUE_TYPE_BOOL, FL_VALUE_TYPE_FLOAT, FL_VALUE_TYPE_INT, FL_VALUE_TYPE_LIST, FL_VALUE_TYPE_MAP, FL_VALUE_TYPE_NULL, FL_VALUE_TYPE_STRING, and value.

◆ TEST() [61/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeMapLengthNoData   
)

◆ TEST() [62/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeMapNested   
)

Definition at line 997 of file fl_standard_message_codec_test.cc.

997  {
998  g_autoptr(FlValue) value = decode_message(
999  "0d02070a7374722d746f2d696e740d0407047a65726f030000000007036f6e6503010000"
1000  "00070374776f0302000000070574687265650303000000070a696e742d746f2d7374720d"
1001  "04030000000007047a65726f030100000007036f6e650302000000070374776f03030000"
1002  "0007057468726565");
1004  ASSERT_EQ(fl_value_get_length(value), static_cast<size_t>(2));
1005 
1009  "str-to-int");
1010  FlValue* str_to_int = fl_value_get_map_value(value, 0);
1011  ASSERT_EQ(fl_value_get_type(str_to_int), FL_VALUE_TYPE_MAP);
1012  ASSERT_EQ(fl_value_get_length(str_to_int), static_cast<size_t>(4));
1013 
1017  "int-to-str");
1018  FlValue* int_to_str = fl_value_get_map_value(value, 1);
1019  ASSERT_EQ(fl_value_get_type(int_to_str), FL_VALUE_TYPE_MAP);
1020  ASSERT_EQ(fl_value_get_length(int_to_str), static_cast<size_t>(4));
1021 
1022  const char* numbers[] = {"zero", "one", "two", "three", nullptr};
1023  for (int i = 0; numbers[i] != nullptr; i++) {
1024  ASSERT_EQ(fl_value_get_type(fl_value_get_map_key(str_to_int, i)),
1026  EXPECT_STREQ(fl_value_get_string(fl_value_get_map_key(str_to_int, i)),
1027  numbers[i]);
1028 
1029  ASSERT_EQ(fl_value_get_type(fl_value_get_map_value(str_to_int, i)),
1031  EXPECT_EQ(fl_value_get_int(fl_value_get_map_value(str_to_int, i)), i);
1032 
1033  ASSERT_EQ(fl_value_get_type(fl_value_get_map_key(int_to_str, i)),
1035  EXPECT_EQ(fl_value_get_int(fl_value_get_map_key(int_to_str, i)), i);
1036 
1037  ASSERT_EQ(fl_value_get_type(fl_value_get_map_value(int_to_str, i)),
1039  EXPECT_STREQ(fl_value_get_string(fl_value_get_map_value(int_to_str, i)),
1040  numbers[i]);
1041  }
1042 }

References decode_message(), fl_value_get_int(), fl_value_get_length(), fl_value_get_map_key(), fl_value_get_map_value(), fl_value_get_string(), fl_value_get_type(), FL_VALUE_TYPE_INT, FL_VALUE_TYPE_MAP, FL_VALUE_TYPE_STRING, i, and value.

◆ TEST() [63/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeMapNoData   
)

◆ TEST() [64/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeMapShortData1   
)

◆ TEST() [65/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeMapShortData2   
)

Definition at line 1059 of file fl_standard_message_codec_test.cc.

1059  {
1061  "0d0707046e756c6c000704626f6f6c010703696e74032a0000000705666c6f6174060000"
1062  "00000000182d4454fb2109400706737472696e67070568656c6c6f07046c6973740c0007"
1063  "036d61700d",
1065 }

References decode_error_value(), FL_MESSAGE_CODEC_ERROR, and FL_MESSAGE_CODEC_ERROR_OUT_OF_DATA.

◆ TEST() [66/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeMapValueTypes   
)

Definition at line 938 of file fl_standard_message_codec_test.cc.

938  {
939  g_autoptr(FlValue) value = decode_message(
940  "0d0707046e756c6c000704626f6f6c010703696e74032a0000000705666c6f6174060000"
941  "00000000182d4454fb2109400706737472696e67070568656c6c6f07046c6973740c0007"
942  "036d61700d00");
944  ASSERT_EQ(fl_value_get_length(value), static_cast<size_t>(7));
945 
948  EXPECT_STREQ(fl_value_get_string(fl_value_get_map_key(value, 0)), "null");
951 
954  EXPECT_STREQ(fl_value_get_string(fl_value_get_map_key(value, 1)), "bool");
958 
961  EXPECT_STREQ(fl_value_get_string(fl_value_get_map_key(value, 2)), "int");
964  EXPECT_EQ(fl_value_get_int(fl_value_get_map_value(value, 2)), 42);
965 
968  EXPECT_STREQ(fl_value_get_string(fl_value_get_map_key(value, 3)), "float");
971  EXPECT_FLOAT_EQ(fl_value_get_float(fl_value_get_map_value(value, 3)), M_PI);
972 
975  EXPECT_STREQ(fl_value_get_string(fl_value_get_map_key(value, 4)), "string");
978  EXPECT_STREQ(fl_value_get_string(fl_value_get_map_value(value, 4)), "hello");
979 
982  EXPECT_STREQ(fl_value_get_string(fl_value_get_map_key(value, 5)), "list");
986  static_cast<size_t>(0));
987 
990  EXPECT_STREQ(fl_value_get_string(fl_value_get_map_key(value, 6)), "map");
994  static_cast<size_t>(0));
995 }

References decode_message(), fl_value_get_bool(), fl_value_get_float(), fl_value_get_int(), fl_value_get_length(), fl_value_get_map_key(), fl_value_get_map_value(), fl_value_get_string(), fl_value_get_type(), FL_VALUE_TYPE_BOOL, FL_VALUE_TYPE_FLOAT, FL_VALUE_TYPE_INT, FL_VALUE_TYPE_LIST, FL_VALUE_TYPE_MAP, FL_VALUE_TYPE_NULL, FL_VALUE_TYPE_STRING, and value.

◆ TEST() [67/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeNull   
)

Definition at line 78 of file fl_standard_message_codec_test.cc.

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

References error, fl_message_codec_decode_message(), fl_standard_message_codec_new(), fl_value_get_type(), FL_VALUE_TYPE_NULL, and value.

◆ TEST() [68/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeStringEmpty   
)

Definition at line 364 of file fl_standard_message_codec_test.cc.

364  {
365  g_autoptr(FlValue) value = decode_message("0700");
367  EXPECT_STREQ(fl_value_get_string(value), "");
368 }

References decode_message(), fl_value_get_string(), fl_value_get_type(), FL_VALUE_TYPE_STRING, and value.

◆ TEST() [69/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeStringHello   
)

Definition at line 370 of file fl_standard_message_codec_test.cc.

370  {
371  g_autoptr(FlValue) value = decode_message("070568656c6c6f");
373  EXPECT_STREQ(fl_value_get_string(value), "hello");
374 }

References decode_message(), fl_value_get_string(), fl_value_get_type(), FL_VALUE_TYPE_STRING, and value.

◆ 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 415 of file fl_standard_message_codec_test.cc.

415  {
416  g_autoptr(FlValue) value = decode_message("08050001020304");
418  EXPECT_EQ(fl_value_get_length(value), static_cast<size_t>(5));
419  const uint8_t* data = fl_value_get_uint8_list(value);
420  EXPECT_EQ(data[0], 0);
421  EXPECT_EQ(data[1], 1);
422  EXPECT_EQ(data[2], 2);
423  EXPECT_EQ(data[3], 3);
424  EXPECT_EQ(data[4], 4);
425 }
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:69

References decode_message(), fl_value_get_length(), fl_value_get_type(), fl_value_get_uint8_list(), FL_VALUE_TYPE_UINT8_LIST, and value.

◆ TEST() [75/126]

TEST ( FlStandardMessageCodecTest  ,
DecodeUint8ListEmpty   
)

Definition at line 409 of file fl_standard_message_codec_test.cc.

409  {
410  g_autoptr(FlValue) value = decode_message("0800");
412  EXPECT_EQ(fl_value_get_length(value), static_cast<size_t>(0));
413 }

References decode_message(), fl_value_get_length(), fl_value_get_type(), FL_VALUE_TYPE_UINT8_LIST, and value.

◆ 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   
)

◆ TEST() [81/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeBoolFalse   
)

Definition at line 96 of file fl_standard_message_codec_test.cc.

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

References encode_bool().

◆ TEST() [82/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeBoolTrue   
)

Definition at line 101 of file fl_standard_message_codec_test.cc.

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

References encode_bool(), and TRUE.

◆ TEST() [83/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeCustomType   
)

Definition at line 1247 of file fl_standard_message_codec_test.cc.

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

References encode_message_with_codec(), fl_test_standard_message_codec_new(), fl_value_new_custom(), and value.

◆ TEST() [84/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeCustomTypes   
)

Definition at line 1256 of file fl_standard_message_codec_test.cc.

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

References encode_message_with_codec(), fl_test_standard_message_codec_new(), fl_value_append_take(), fl_value_new_custom(), fl_value_new_list(), and value.

◆ TEST() [85/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeDecode   
)

Definition at line 1267 of file fl_standard_message_codec_test.cc.

1267  {
1268  g_autoptr(FlStandardMessageCodec) codec = fl_standard_message_codec_new();
1269 
1270  g_autoptr(FlValue) input = fl_value_new_list();
1275  fl_value_append_take(input, fl_value_new_string("hello"));
1278 
1279  g_autoptr(GError) error = nullptr;
1280  g_autoptr(GBytes) message =
1281  fl_message_codec_encode_message(FL_MESSAGE_CODEC(codec), input, &error);
1282  EXPECT_NE(message, nullptr);
1283  EXPECT_EQ(error, nullptr);
1284 
1285  g_autoptr(FlValue) output =
1286  fl_message_codec_decode_message(FL_MESSAGE_CODEC(codec), message, &error);
1287  EXPECT_EQ(error, nullptr);
1288  EXPECT_NE(output, nullptr);
1289 
1290  ASSERT_TRUE(fl_value_equal(input, output));
1291 }
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
G_MODULE_EXPORT FlValue * fl_value_new_map()
Definition: fl_value.cc:366

References error, fl_message_codec_decode_message(), fl_message_codec_encode_message(), fl_standard_message_codec_new(), fl_value_append_take(), fl_value_equal(), fl_value_new_bool(), fl_value_new_float(), fl_value_new_int(), fl_value_new_list(), fl_value_new_map(), fl_value_new_null(), fl_value_new_string(), and TRUE.

◆ TEST() [86/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeDecodeLargeList   
)

Definition at line 786 of file fl_standard_message_codec_test.cc.

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

References error, fl_message_codec_decode_message(), fl_message_codec_encode_message(), fl_standard_message_codec_new(), fl_value_append_take(), fl_value_equal(), fl_value_new_int(), fl_value_new_list(), i, and value.

◆ TEST() [87/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeDecodeLargeMap   
)

Definition at line 1067 of file fl_standard_message_codec_test.cc.

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

References error, fl_message_codec_decode_message(), fl_message_codec_encode_message(), fl_standard_message_codec_new(), fl_value_equal(), fl_value_new_int(), fl_value_new_map(), fl_value_set_string_take(), i, and value.

◆ TEST() [88/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloat32List   
)

Definition at line 563 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_float32_list(), and value.

◆ TEST() [89/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloat32ListEmpty   
)

Definition at line 557 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_float32_list(), and value.

◆ TEST() [90/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatFraction   
)

Definition at line 254 of file fl_standard_message_codec_test.cc.

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

References encode_float().

◆ TEST() [91/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatHalf   
)

Definition at line 249 of file fl_standard_message_codec_test.cc.

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

References encode_float().

◆ TEST() [92/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatInfinity   
)

Definition at line 269 of file fl_standard_message_codec_test.cc.

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

References encode_float().

◆ TEST() [93/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatList   
)

Definition at line 615 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_float_list(), and value.

◆ TEST() [94/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatListEmpty   
)

Definition at line 609 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_float_list(), and value.

◆ TEST() [95/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatMinusOne   
)

Definition at line 244 of file fl_standard_message_codec_test.cc.

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

References encode_float().

◆ TEST() [96/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatMinusZero   
)

Definition at line 259 of file fl_standard_message_codec_test.cc.

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

References encode_float().

◆ TEST() [97/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatNaN   
)

Definition at line 264 of file fl_standard_message_codec_test.cc.

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

References encode_float().

◆ TEST() [98/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatOne   
)

Definition at line 239 of file fl_standard_message_codec_test.cc.

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

References encode_float().

◆ TEST() [99/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeFloatZero   
)

Definition at line 234 of file fl_standard_message_codec_test.cc.

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

References encode_float().

◆ TEST() [100/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt32   
)

Definition at line 121 of file fl_standard_message_codec_test.cc.

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

References encode_int().

◆ TEST() [101/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt32List   
)

Definition at line 453 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_int32_list(), and value.

◆ TEST() [102/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt32ListEmpty   
)

Definition at line 447 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_int32_list(), and value.

◆ TEST() [103/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt32Max   
)

Definition at line 131 of file fl_standard_message_codec_test.cc.

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

References encode_int().

◆ TEST() [104/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt32Min   
)

Definition at line 126 of file fl_standard_message_codec_test.cc.

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

References encode_int().

◆ TEST() [105/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt64   
)

Definition at line 136 of file fl_standard_message_codec_test.cc.

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

References encode_int().

◆ TEST() [106/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt64List   
)

Definition at line 505 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_int64_list(), and value.

◆ TEST() [107/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt64ListEmpty   
)

Definition at line 499 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_int64_list(), and value.

◆ TEST() [108/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt64Max   
)

Definition at line 146 of file fl_standard_message_codec_test.cc.

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

References encode_int().

◆ TEST() [109/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeInt64Min   
)

Definition at line 141 of file fl_standard_message_codec_test.cc.

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

References encode_int().

◆ TEST() [110/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeIntOne   
)

Definition at line 116 of file fl_standard_message_codec_test.cc.

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

References encode_int().

◆ TEST() [111/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeIntZero   
)

Definition at line 111 of file fl_standard_message_codec_test.cc.

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

References encode_int().

◆ TEST() [112/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeListEmpty   
)

Definition at line 667 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_list(), and value.

◆ TEST() [113/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeListNested   
)

Definition at line 688 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_append(), fl_value_append_take(), fl_value_new_int(), fl_value_new_list(), i, and value.

◆ TEST() [114/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeListTypes   
)

Definition at line 673 of file fl_standard_message_codec_test.cc.

673  {
674  g_autoptr(FlValue) value = fl_value_new_list();
682  g_autofree gchar* hex_string = encode_message(value);
683  EXPECT_STREQ(
684  hex_string,
685  "0c070001032a00000006000000000000182d4454fb210940070568656c6c6f0c000d00");
686 }

References encode_message(), fl_value_append_take(), fl_value_new_bool(), fl_value_new_float(), fl_value_new_int(), fl_value_new_list(), fl_value_new_map(), fl_value_new_null(), fl_value_new_string(), TRUE, and value.

◆ TEST() [115/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeMapEmpty   
)

Definition at line 808 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_map(), and value.

◆ TEST() [116/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeMapKeyTypes   
)

Definition at line 814 of file fl_standard_message_codec_test.cc.

814  {
815  g_autoptr(FlValue) value = fl_value_new_map();
818  fl_value_new_string("bool"));
821  fl_value_new_string("float"));
823  fl_value_new_string("string"));
826  g_autofree gchar* hex_string = encode_message(value);
827  EXPECT_STREQ(hex_string,
828  "0d070007046e756c6c010704626f6f6c032a0000000703696e7406000000000"
829  "0182d4454fb2109400705666c6f6174070568656c6c6f0706737472696e670c"
830  "0007046c6973740d0007036d6170");
831 }
G_MODULE_EXPORT void fl_value_set_take(FlValue *self, FlValue *key, FlValue *value)
Definition: fl_value.cc:618

References encode_message(), fl_value_new_bool(), fl_value_new_float(), fl_value_new_int(), fl_value_new_list(), fl_value_new_map(), fl_value_new_null(), fl_value_new_string(), fl_value_set_take(), TRUE, and value.

◆ TEST() [117/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeMapNested   
)

Definition at line 852 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_int(), fl_value_new_map(), fl_value_new_string(), fl_value_set_string(), fl_value_set_take(), i, and value.

◆ TEST() [118/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeMapValueTypes   
)

Definition at line 833 of file fl_standard_message_codec_test.cc.

833  {
834  g_autoptr(FlValue) value = fl_value_new_map();
840  fl_value_new_float(M_PI));
842  fl_value_new_string("hello"));
845  g_autofree gchar* hex_string = encode_message(value);
846  EXPECT_STREQ(hex_string,
847  "0d0707046e756c6c000704626f6f6c010703696e74032a0000000705666c6f6"
848  "17406000000000000182d4454fb2109400706737472696e67070568656c6c6f"
849  "07046c6973740c0007036d61700d00");
850 }

References encode_message(), fl_value_new_bool(), fl_value_new_float(), fl_value_new_int(), fl_value_new_list(), fl_value_new_map(), fl_value_new_null(), fl_value_new_string(), fl_value_set_take(), TRUE, and value.

◆ TEST() [119/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeNull   
)

Definition at line 72 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_null(), and value.

◆ TEST() [120/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeNullptr   
)

Definition at line 67 of file fl_standard_message_codec_test.cc.

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

References encode_message().

◆ TEST() [121/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeStringEmpty   
)

Definition at line 342 of file fl_standard_message_codec_test.cc.

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

References encode_string().

◆ TEST() [122/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeStringEmptySized   
)

Definition at line 352 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_string_sized(), and value.

◆ TEST() [123/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeStringHello   
)

Definition at line 347 of file fl_standard_message_codec_test.cc.

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

References encode_string().

◆ TEST() [124/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeStringHelloSized   
)

Definition at line 358 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_string_sized(), and value.

◆ TEST() [125/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeUint8List   
)

Definition at line 402 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_uint8_list(), and value.

◆ TEST() [126/126]

TEST ( FlStandardMessageCodecTest  ,
EncodeUint8ListEmpty   
)

Definition at line 396 of file fl_standard_message_codec_test.cc.

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

References encode_message(), fl_value_new_uint8_list(), and value.

◆ write_custom_value2()

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

Definition at line 1124 of file fl_standard_message_codec_test.cc.

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

References buffer, g_byte_array_append(), TRUE, and type.

Referenced by fl_test_standard_message_codec_write_value().

Variable Documentation

◆ buffer

◆ error

◆ length

◆ TRUE

return TRUE

Definition at line 1121 of file fl_standard_message_codec_test.cc.

Referenced by TEST(), and write_custom_value2().

◆ type

◆ value