Flutter Linux Embedder
fl_json_message_codec_test.cc File Reference
#include "flutter/shell/platform/linux/public/flutter_linux/fl_json_message_codec.h"
#include "gtest/gtest.h"
#include <cmath>

Go to the source code of this file.

Functions

static gchar * encode_message (FlValue *value)
 
static void encode_error_message (FlValue *value, GQuark domain, gint code)
 
static FlValuedecode_message (const char *text)
 
static void decode_error_message (const char *text, GQuark domain, gint code)
 
 TEST (FlJsonMessageCodecTest, EncodeNullptr)
 
 TEST (FlJsonMessageCodecTest, EncodeNull)
 
 TEST (FlJsonMessageCodecTest, DecodeNull)
 
static gchar * encode_bool (gboolean value)
 
 TEST (FlJsonMessageCodecTest, EncodeBoolFalse)
 
 TEST (FlJsonMessageCodecTest, EncodeBoolTrue)
 
 TEST (FlJsonMessageCodecTest, DecodeBoolFalse)
 
 TEST (FlJsonMessageCodecTest, DecodeBoolTrue)
 
static gchar * encode_int (int64_t value)
 
 TEST (FlJsonMessageCodecTest, EncodeIntZero)
 
 TEST (FlJsonMessageCodecTest, EncodeIntOne)
 
 TEST (FlJsonMessageCodecTest, EncodeInt12345)
 
 TEST (FlJsonMessageCodecTest, EncodeIntMin)
 
 TEST (FlJsonMessageCodecTest, EncodeIntMax)
 
 TEST (FlJsonMessageCodecTest, DecodeIntZero)
 
 TEST (FlJsonMessageCodecTest, DecodeIntOne)
 
 TEST (FlJsonMessageCodecTest, DecodeInt12345)
 
 TEST (FlJsonMessageCodecTest, DecodeIntMin)
 
 TEST (FlJsonMessageCodecTest, DecodeIntMax)
 
 TEST (FlJsonMessageCodecTest, DecodeUintMax)
 
 TEST (FlJsonMessageCodecTest, DecodeHugeNumber)
 
 TEST (FlJsonMessageCodecTest, DecodeIntLeadingZero1)
 
 TEST (FlJsonMessageCodecTest, DecodeIntLeadingZero2)
 
 TEST (FlJsonMessageCodecTest, DecodeIntDoubleNegative)
 
 TEST (FlJsonMessageCodecTest, DecodeIntPositiveSign)
 
 TEST (FlJsonMessageCodecTest, DecodeIntHexChar)
 
static gchar * encode_float (double value)
 
 TEST (FlJsonMessageCodecTest, EncodeFloatZero)
 
 TEST (FlJsonMessageCodecTest, EncodeFloatOne)
 
 TEST (FlJsonMessageCodecTest, EncodeFloatMinusOne)
 
 TEST (FlJsonMessageCodecTest, EncodeFloatHalf)
 
 TEST (FlJsonMessageCodecTest, EncodeFloatPi)
 
 TEST (FlJsonMessageCodecTest, EncodeFloatMinusZero)
 
 TEST (FlJsonMessageCodecTest, DecodeFloatZero)
 
 TEST (FlJsonMessageCodecTest, DecodeFloatOne)
 
 TEST (FlJsonMessageCodecTest, DecodeFloatMinusOne)
 
 TEST (FlJsonMessageCodecTest, DecodeFloatHalf)
 
 TEST (FlJsonMessageCodecTest, DecodeFloatPi)
 
 TEST (FlJsonMessageCodecTest, DecodeFloatMinusZero)
 
 TEST (FlJsonMessageCodecTest, DecodeFloatMissingFraction)
 
 TEST (FlJsonMessageCodecTest, DecodeFloatInvalidFraction)
 
static gchar * encode_string (const gchar *value)
 
 TEST (FlJsonMessageCodecTest, EncodeStringEmpty)
 
 TEST (FlJsonMessageCodecTest, EncodeStringHello)
 
 TEST (FlJsonMessageCodecTest, EncodeStringEmptySized)
 
 TEST (FlJsonMessageCodecTest, EncodeStringHelloSized)
 
 TEST (FlJsonMessageCodecTest, EncodeStringEscapeQuote)
 
 TEST (FlJsonMessageCodecTest, EncodeStringEscapeBackslash)
 
 TEST (FlJsonMessageCodecTest, EncodeStringEscapeBackspace)
 
 TEST (FlJsonMessageCodecTest, EncodeStringEscapeFormFeed)
 
 TEST (FlJsonMessageCodecTest, EncodeStringEscapeNewline)
 
 TEST (FlJsonMessageCodecTest, EncodeStringEscapeCarriageReturn)
 
 TEST (FlJsonMessageCodecTest, EncodeStringEscapeTab)
 
 TEST (FlJsonMessageCodecTest, EncodeStringEscapeUnicode)
 
 TEST (FlJsonMessageCodecTest, EncodeStringEmoji)
 
 TEST (FlJsonMessageCodecTest, DecodeStringEmpty)
 
 TEST (FlJsonMessageCodecTest, DecodeStringHello)
 
 TEST (FlJsonMessageCodecTest, DecodeStringEscapeQuote)
 
 TEST (FlJsonMessageCodecTest, DecodeStringEscapeBackslash)
 
 TEST (FlJsonMessageCodecTest, DecodeStringEscapeSlash)
 
 TEST (FlJsonMessageCodecTest, DecodeStringEscapeBackspace)
 
 TEST (FlJsonMessageCodecTest, DecodeStringEscapeFormFeed)
 
 TEST (FlJsonMessageCodecTest, DecodeStringEscapeNewline)
 
 TEST (FlJsonMessageCodecTest, DecodeStringEscapeCarriageReturn)
 
 TEST (FlJsonMessageCodecTest, DecodeStringEscapeTab)
 
 TEST (FlJsonMessageCodecTest, DecodeStringEscapeUnicode)
 
 TEST (FlJsonMessageCodecTest, DecodeStringEmoji)
 
 TEST (FlJsonMessageCodecTest, DecodeInvalidUTF8)
 
 TEST (FlJsonMessageCodecTest, DecodeStringInvalidUTF8)
 
 TEST (FlJsonMessageCodecTest, DecodeStringBinary)
 
 TEST (FlJsonMessageCodecTest, DecodeStringNewline)
 
 TEST (FlJsonMessageCodecTest, DecodeStringCarriageReturn)
 
 TEST (FlJsonMessageCodecTest, DecodeStringTab)
 
 TEST (FlJsonMessageCodecTest, DecodeStringUnterminatedEmpty)
 
 TEST (FlJsonMessageCodecTest, DecodeStringExtraQuote)
 
 TEST (FlJsonMessageCodecTest, DecodeStringEscapedClosingQuote)
 
 TEST (FlJsonMessageCodecTest, DecodeStringUnknownEscape)
 
 TEST (FlJsonMessageCodecTest, DecodeStringInvalidEscapeUnicode)
 
 TEST (FlJsonMessageCodecTest, DecodeStringEscapeUnicodeNoData)
 
 TEST (FlJsonMessageCodecTest, DecodeStringEscapeUnicodeShortData)
 
 TEST (FlJsonMessageCodecTest, EncodeUint8ListEmpty)
 
 TEST (FlJsonMessageCodecTest, EncodeUint8List)
 
 TEST (FlJsonMessageCodecTest, EncodeInt32ListEmpty)
 
 TEST (FlJsonMessageCodecTest, EncodeInt32List)
 
 TEST (FlJsonMessageCodecTest, EncodeInt64ListEmpty)
 
 TEST (FlJsonMessageCodecTest, EncodeInt64List)
 
 TEST (FlJsonMessageCodecTest, EncodeFloatListEmpty)
 
 TEST (FlJsonMessageCodecTest, EncodeFloatList)
 
 TEST (FlJsonMessageCodecTest, EncodeListEmpty)
 
 TEST (FlJsonMessageCodecTest, EncodeListTypes)
 
 TEST (FlJsonMessageCodecTest, EncodeListNested)
 
 TEST (FlJsonMessageCodecTest, DecodeListEmpty)
 
 TEST (FlJsonMessageCodecTest, DecodeListNoComma)
 
 TEST (FlJsonMessageCodecTest, DecodeListUnterminatedEmpty)
 
 TEST (FlJsonMessageCodecTest, DecodeListStartUnterminate)
 
 TEST (FlJsonMessageCodecTest, DecodeListUnterminated)
 
 TEST (FlJsonMessageCodecTest, DecodeListDoubleTerminated)
 
 TEST (FlJsonMessageCodecTest, EncodeMapEmpty)
 
 TEST (FlJsonMessageCodecTest, EncodeMapNullKey)
 
 TEST (FlJsonMessageCodecTest, EncodeMapBoolKey)
 
 TEST (FlJsonMessageCodecTest, EncodeMapIntKey)
 
 TEST (FlJsonMessageCodecTest, EncodeMapFloatKey)
 
 TEST (FlJsonMessageCodecTest, EncodeMapUint8ListKey)
 
 TEST (FlJsonMessageCodecTest, EncodeMapInt32ListKey)
 
 TEST (FlJsonMessageCodecTest, EncodeMapInt64ListKey)
 
 TEST (FlJsonMessageCodecTest, EncodeMapFloatListKey)
 
 TEST (FlJsonMessageCodecTest, EncodeMapListKey)
 
 TEST (FlJsonMessageCodecTest, EncodeMapMapKey)
 
 TEST (FlJsonMessageCodecTest, EncodeMapValueTypes)
 
 TEST (FlJsonMessageCodecTest, EncodeMapNested)
 
 TEST (FlJsonMessageCodecTest, DecodeMapEmpty)
 
 TEST (FlJsonMessageCodecTest, DecodeMapUnterminatedEmpty)
 
 TEST (FlJsonMessageCodecTest, DecodeMapStartUnterminate)
 
 TEST (FlJsonMessageCodecTest, DecodeMapNoComma)
 
 TEST (FlJsonMessageCodecTest, DecodeMapNoColon)
 
 TEST (FlJsonMessageCodecTest, DecodeMapUnterminated)
 
 TEST (FlJsonMessageCodecTest, DecodeMapDoubleTerminated)
 
 TEST (FlJsonMessageCodecTest, DecodeUnknownWord)
 
 TEST (FlJsonMessageCodecTest, EncodeDecode)
 

Function Documentation

◆ decode_error_message()

static void decode_error_message ( const char *  text,
GQuark  domain,
gint  code 
)
static

Definition at line 41 of file fl_json_message_codec_test.cc.

41  {
42  g_autoptr(FlJsonMessageCodec) codec = fl_json_message_codec_new();
43  g_autoptr(GError) error = nullptr;
44  g_autoptr(FlValue) value = fl_json_message_codec_decode(codec, text, &error);
45  EXPECT_TRUE(g_error_matches(error, domain, code));
46  EXPECT_EQ(value, nullptr);
47 }

References error, fl_json_message_codec_decode(), fl_json_message_codec_new(), and value.

Referenced by TEST().

◆ decode_message()

static FlValue* decode_message ( const char *  text)
static

Definition at line 30 of file fl_json_message_codec_test.cc.

30  {
31  g_autoptr(FlJsonMessageCodec) codec = fl_json_message_codec_new();
32  g_autoptr(GError) error = nullptr;
33  g_autoptr(FlValue) value = fl_json_message_codec_decode(codec, text, &error);
34  EXPECT_EQ(error, nullptr);
35  EXPECT_NE(value, nullptr);
36  return fl_value_ref(value);
37 }

References error, fl_json_message_codec_decode(), fl_json_message_codec_new(), fl_value_ref(), and value.

Referenced by TEST().

◆ encode_bool()

static gchar* encode_bool ( gboolean  value)
static

Definition at line 65 of file fl_json_message_codec_test.cc.

65  {
66  g_autoptr(FlValue) v = fl_value_new_bool(value);
67  return encode_message(v);
68 }

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

Referenced by TEST().

◆ encode_error_message()

static void encode_error_message ( FlValue value,
GQuark  domain,
gint  code 
)
static

Definition at line 21 of file fl_json_message_codec_test.cc.

21  {
22  g_autoptr(FlJsonMessageCodec) codec = fl_json_message_codec_new();
23  g_autoptr(GError) error = nullptr;
24  g_autofree gchar* result = fl_json_message_codec_encode(codec, value, &error);
25  EXPECT_TRUE(g_error_matches(error, domain, code));
26  EXPECT_EQ(result, nullptr);
27 }

References error, fl_json_message_codec_encode(), fl_json_message_codec_new(), result, and value.

Referenced by TEST().

◆ encode_float()

static gchar* encode_float ( double  value)
static

Definition at line 193 of file fl_json_message_codec_test.cc.

193  {
194  g_autoptr(FlValue) v = fl_value_new_float(value);
195  return encode_message(v);
196 }

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 92 of file fl_json_message_codec_test.cc.

92  {
93  g_autoptr(FlValue) v = fl_value_new_int(value);
94  return encode_message(v);
95 }

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

Referenced by TEST().

◆ encode_message()

static gchar* encode_message ( FlValue value)
static

Definition at line 11 of file fl_json_message_codec_test.cc.

11  {
12  g_autoptr(FlJsonMessageCodec) codec = fl_json_message_codec_new();
13  g_autoptr(GError) error = nullptr;
14  g_autofree gchar* result = fl_json_message_codec_encode(codec, value, &error);
15  EXPECT_EQ(error, nullptr);
16  return static_cast<gchar*>(g_steal_pointer(&result));
17 }

References error, fl_json_message_codec_encode(), fl_json_message_codec_new(), result, and value.

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

◆ encode_string()

static gchar* encode_string ( const gchar *  value)
static

Definition at line 277 of file fl_json_message_codec_test.cc.

277  {
278  g_autoptr(FlValue) v = fl_value_new_string(value);
279  return encode_message(v);
280 }

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

Referenced by TEST().

◆ TEST() [1/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeBoolFalse   
)

Definition at line 80 of file fl_json_message_codec_test.cc.

80  {
81  g_autoptr(FlValue) value = decode_message("false");
83  EXPECT_FALSE(fl_value_get_bool(value));
84 }

References decode_message(), fl_value_get_bool(), fl_value_get_type(), FL_VALUE_TYPE_BOOL, and value.

◆ TEST() [2/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeBoolTrue   
)

Definition at line 86 of file fl_json_message_codec_test.cc.

86  {
87  g_autoptr(FlValue) value = decode_message("true");
89  EXPECT_TRUE(fl_value_get_bool(value));
90 }

References decode_message(), fl_value_get_bool(), fl_value_get_type(), FL_VALUE_TYPE_BOOL, and value.

◆ TEST() [3/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeFloatHalf   
)

Definition at line 249 of file fl_json_message_codec_test.cc.

249  {
250  g_autoptr(FlValue) value = decode_message("0.5");
252  EXPECT_EQ(fl_value_get_float(value), 0.5);
253 }

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

◆ TEST() [4/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeFloatInvalidFraction   
)

◆ TEST() [5/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeFloatMinusOne   
)

Definition at line 243 of file fl_json_message_codec_test.cc.

243  {
244  g_autoptr(FlValue) value = decode_message("-1.0");
246  EXPECT_EQ(fl_value_get_float(value), -1.0);
247 }

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

◆ TEST() [6/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeFloatMinusZero   
)

Definition at line 261 of file fl_json_message_codec_test.cc.

261  {
262  g_autoptr(FlValue) value = decode_message("-0.0");
264  EXPECT_EQ(fl_value_get_float(value), -0.0);
265 }

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

◆ TEST() [7/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeFloatMissingFraction   
)

◆ TEST() [8/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeFloatOne   
)

Definition at line 237 of file fl_json_message_codec_test.cc.

237  {
238  g_autoptr(FlValue) value = decode_message("1.0");
240  EXPECT_EQ(fl_value_get_float(value), 1.0);
241 }

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

◆ TEST() [9/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeFloatPi   
)

Definition at line 255 of file fl_json_message_codec_test.cc.

255  {
256  g_autoptr(FlValue) value = decode_message("3.1415926535897931");
258  EXPECT_EQ(fl_value_get_float(value), M_PI);
259 }

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

◆ TEST() [10/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeFloatZero   
)

Definition at line 231 of file fl_json_message_codec_test.cc.

231  {
232  g_autoptr(FlValue) value = decode_message("0.0");
234  EXPECT_EQ(fl_value_get_float(value), 0.0);
235 }

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

◆ TEST() [11/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeHugeNumber   
)

Definition at line 160 of file fl_json_message_codec_test.cc.

160  {
161  // This is bigger than an unsigned 64 bit integer, so we expect it to be
162  // represented as a double.
163  g_autoptr(FlValue) value = decode_message("184467440737095516150");
165  EXPECT_EQ(fl_value_get_float(value), 1.84467440737095516150e+20);
166 }

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

◆ TEST() [12/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeInt12345   
)

Definition at line 134 of file fl_json_message_codec_test.cc.

134  {
135  g_autoptr(FlValue) value = decode_message("12345");
137  EXPECT_EQ(fl_value_get_int(value), 12345);
138 }

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

◆ TEST() [13/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeIntDoubleNegative   
)

◆ TEST() [14/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeIntHexChar   
)

◆ TEST() [15/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeIntLeadingZero1   
)

◆ TEST() [16/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeIntLeadingZero2   
)

◆ TEST() [17/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeIntMax   
)

Definition at line 146 of file fl_json_message_codec_test.cc.

146  {
147  g_autoptr(FlValue) value = decode_message("9223372036854775807");
149  EXPECT_EQ(fl_value_get_int(value), G_MAXINT64);
150 }

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

◆ TEST() [18/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeIntMin   
)

Definition at line 140 of file fl_json_message_codec_test.cc.

140  {
141  g_autoptr(FlValue) value = decode_message("-9223372036854775808");
143  EXPECT_EQ(fl_value_get_int(value), G_MININT64);
144 }

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

◆ TEST() [19/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeIntOne   
)

Definition at line 128 of file fl_json_message_codec_test.cc.

128  {
129  g_autoptr(FlValue) value = decode_message("1");
131  EXPECT_EQ(fl_value_get_int(value), 1);
132 }

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

◆ TEST() [20/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeIntPositiveSign   
)

◆ TEST() [21/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeIntZero   
)

Definition at line 122 of file fl_json_message_codec_test.cc.

122  {
123  g_autoptr(FlValue) value = decode_message("0");
125  EXPECT_EQ(fl_value_get_int(value), 0);
126 }

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

◆ TEST() [22/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeInvalidUTF8   
)

◆ TEST() [23/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeListDoubleTerminated   
)

◆ TEST() [24/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeListEmpty   
)

Definition at line 574 of file fl_json_message_codec_test.cc.

574  {
575  g_autoptr(FlValue) value = decode_message("[]");
577  EXPECT_EQ(fl_value_get_length(value), static_cast<size_t>(0));
578 }

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

◆ TEST() [25/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeListNoComma   
)

◆ TEST() [26/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeListStartUnterminate   
)

◆ TEST() [27/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeListUnterminated   
)

◆ TEST() [28/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeListUnterminatedEmpty   
)

◆ TEST() [29/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeMapDoubleTerminated   
)

◆ TEST() [30/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeMapEmpty   
)

Definition at line 719 of file fl_json_message_codec_test.cc.

719  {
720  g_autoptr(FlValue) value = decode_message("{}");
722  EXPECT_EQ(fl_value_get_length(value), static_cast<size_t>(0));
723 }

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

◆ TEST() [31/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeMapNoColon   
)

◆ TEST() [32/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeMapNoComma   
)

◆ TEST() [33/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeMapStartUnterminate   
)

◆ TEST() [34/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeMapUnterminated   
)

◆ TEST() [35/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeMapUnterminatedEmpty   
)

◆ TEST() [36/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeNull   
)

Definition at line 60 of file fl_json_message_codec_test.cc.

60  {
61  g_autoptr(FlValue) value = decode_message("null");
63 }

References decode_message(), fl_value_get_type(), FL_VALUE_TYPE_NULL, and value.

◆ TEST() [37/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringBinary   
)

◆ TEST() [38/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringCarriageReturn   
)

◆ TEST() [39/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringEmoji   
)

Definition at line 415 of file fl_json_message_codec_test.cc.

415  {
416  g_autoptr(FlValue) value = decode_message("\"😀\"");
418  EXPECT_STREQ(fl_value_get_string(value), "😀");
419 }

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

◆ TEST() [40/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringEmpty   
)

Definition at line 349 of file fl_json_message_codec_test.cc.

349  {
350  g_autoptr(FlValue) value = decode_message("\"\"");
352  EXPECT_STREQ(fl_value_get_string(value), "");
353 }

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

◆ TEST() [41/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringEscapeBackslash   
)

Definition at line 367 of file fl_json_message_codec_test.cc.

367  {
368  g_autoptr(FlValue) value = decode_message("\"\\\\\"");
370  EXPECT_STREQ(fl_value_get_string(value), "\\");
371 }

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

◆ TEST() [42/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringEscapeBackspace   
)

Definition at line 379 of file fl_json_message_codec_test.cc.

379  {
380  g_autoptr(FlValue) value = decode_message("\"\\b\"");
382  EXPECT_STREQ(fl_value_get_string(value), "\b");
383 }

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

◆ TEST() [43/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringEscapeCarriageReturn   
)

Definition at line 397 of file fl_json_message_codec_test.cc.

397  {
398  g_autoptr(FlValue) value = decode_message("\"\\r\"");
400  EXPECT_STREQ(fl_value_get_string(value), "\r");
401 }

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

◆ TEST() [44/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringEscapedClosingQuote   
)

◆ TEST() [45/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringEscapeFormFeed   
)

Definition at line 385 of file fl_json_message_codec_test.cc.

385  {
386  g_autoptr(FlValue) value = decode_message("\"\\f\"");
388  EXPECT_STREQ(fl_value_get_string(value), "\f");
389 }

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

◆ TEST() [46/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringEscapeNewline   
)

Definition at line 391 of file fl_json_message_codec_test.cc.

391  {
392  g_autoptr(FlValue) value = decode_message("\"\\n\"");
394  EXPECT_STREQ(fl_value_get_string(value), "\n");
395 }

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

◆ TEST() [47/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringEscapeQuote   
)

Definition at line 361 of file fl_json_message_codec_test.cc.

361  {
362  g_autoptr(FlValue) value = decode_message("\"\\\"\"");
364  EXPECT_STREQ(fl_value_get_string(value), "\"");
365 }

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

◆ TEST() [48/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringEscapeSlash   
)

Definition at line 373 of file fl_json_message_codec_test.cc.

373  {
374  g_autoptr(FlValue) value = decode_message("\"\\/\"");
376  EXPECT_STREQ(fl_value_get_string(value), "/");
377 }

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

◆ TEST() [49/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringEscapeTab   
)

Definition at line 403 of file fl_json_message_codec_test.cc.

403  {
404  g_autoptr(FlValue) value = decode_message("\"\\t\"");
406  EXPECT_STREQ(fl_value_get_string(value), "\t");
407 }

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

◆ TEST() [50/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringEscapeUnicode   
)

Definition at line 409 of file fl_json_message_codec_test.cc.

409  {
410  g_autoptr(FlValue) value = decode_message("\"\\u0001\"");
412  EXPECT_STREQ(fl_value_get_string(value), "\u0001");
413 }

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

◆ TEST() [51/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringEscapeUnicodeNoData   
)

◆ TEST() [52/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringEscapeUnicodeShortData   
)

◆ TEST() [53/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringExtraQuote   
)

◆ TEST() [54/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringHello   
)

Definition at line 355 of file fl_json_message_codec_test.cc.

355  {
356  g_autoptr(FlValue) value = decode_message("\"hello\"");
358  EXPECT_STREQ(fl_value_get_string(value), "hello");
359 }

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

◆ TEST() [55/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringInvalidEscapeUnicode   
)

◆ TEST() [56/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringInvalidUTF8   
)

◆ TEST() [57/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringNewline   
)

◆ TEST() [58/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringTab   
)

◆ TEST() [59/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringUnknownEscape   
)

◆ TEST() [60/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeStringUnterminatedEmpty   
)

◆ TEST() [61/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeUintMax   
)

Definition at line 152 of file fl_json_message_codec_test.cc.

152  {
153  // This is bigger than an signed 64 bit integer, so we expect it to be
154  // represented as a double.
155  g_autoptr(FlValue) value = decode_message("18446744073709551615");
157  EXPECT_EQ(fl_value_get_float(value), 1.8446744073709551615e+19);
158 }

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

◆ TEST() [62/115]

TEST ( FlJsonMessageCodecTest  ,
DecodeUnknownWord   
)

◆ TEST() [63/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeBoolFalse   
)

Definition at line 70 of file fl_json_message_codec_test.cc.

70  {
71  g_autofree gchar* text = encode_bool(FALSE);
72  EXPECT_STREQ(text, "false");
73 }

References encode_bool().

◆ TEST() [64/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeBoolTrue   
)

Definition at line 75 of file fl_json_message_codec_test.cc.

75  {
76  g_autofree gchar* text = encode_bool(TRUE);
77  EXPECT_STREQ(text, "true");
78 }

References encode_bool(), and TRUE.

◆ TEST() [65/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeDecode   
)

Definition at line 760 of file fl_json_message_codec_test.cc.

760  {
761  g_autoptr(FlJsonMessageCodec) codec = fl_json_message_codec_new();
762 
763  g_autoptr(FlValue) input = fl_value_new_list();
768  fl_value_append_take(input, fl_value_new_string("hello"));
771 
772  g_autoptr(GError) error = nullptr;
773  g_autofree gchar* message =
774  fl_json_message_codec_encode(codec, input, &error);
775  ASSERT_NE(message, nullptr);
776  EXPECT_EQ(error, nullptr);
777 
778  g_autoptr(FlValue) output =
779  fl_json_message_codec_decode(codec, message, &error);
780  EXPECT_EQ(error, nullptr);
781  EXPECT_NE(output, nullptr);
782 
783  EXPECT_TRUE(fl_value_equal(input, output));
784 }

References error, fl_json_message_codec_decode(), fl_json_message_codec_encode(), fl_json_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() [66/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeFloatHalf   
)

Definition at line 213 of file fl_json_message_codec_test.cc.

213  {
214  g_autofree gchar* text = encode_float(0.5);
215  EXPECT_STREQ(text, "0.5");
216 }

References encode_float().

◆ TEST() [67/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeFloatList   
)

Definition at line 531 of file fl_json_message_codec_test.cc.

531  {
532  double data[] = {0, -0.5, 0.25, -0.125, 0.0625};
533  g_autoptr(FlValue) value = fl_value_new_float_list(data, 5);
534  g_autofree gchar* text = encode_message(value);
535  EXPECT_STREQ(text, "[0.0,-0.5,0.25,-0.125,0.0625]");
536 }

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

◆ TEST() [68/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeFloatListEmpty   
)

Definition at line 525 of file fl_json_message_codec_test.cc.

525  {
526  g_autoptr(FlValue) value = fl_value_new_float_list(nullptr, 0);
527  g_autofree gchar* text = encode_message(value);
528  EXPECT_STREQ(text, "[]");
529 }

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

◆ TEST() [69/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeFloatMinusOne   
)

Definition at line 208 of file fl_json_message_codec_test.cc.

208  {
209  g_autofree gchar* text = encode_float(-1);
210  EXPECT_STREQ(text, "-1.0");
211 }

References encode_float().

◆ TEST() [70/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeFloatMinusZero   
)

Definition at line 223 of file fl_json_message_codec_test.cc.

223  {
224  g_autofree gchar* text = encode_float(-0.0);
225  EXPECT_STREQ(text, "-0.0");
226 }

References encode_float().

◆ TEST() [71/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeFloatOne   
)

Definition at line 203 of file fl_json_message_codec_test.cc.

203  {
204  g_autofree gchar* text = encode_float(1);
205  EXPECT_STREQ(text, "1.0");
206 }

References encode_float().

◆ TEST() [72/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeFloatPi   
)

Definition at line 218 of file fl_json_message_codec_test.cc.

218  {
219  g_autofree gchar* text = encode_float(M_PI);
220  EXPECT_STREQ(text, "3.141592653589793");
221 }

References encode_float().

◆ TEST() [73/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeFloatZero   
)

Definition at line 198 of file fl_json_message_codec_test.cc.

198  {
199  g_autofree gchar* text = encode_float(0);
200  EXPECT_STREQ(text, "0.0");
201 }

References encode_float().

◆ TEST() [74/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeInt12345   
)

Definition at line 107 of file fl_json_message_codec_test.cc.

107  {
108  g_autofree gchar* text = encode_int(12345);
109  EXPECT_STREQ(text, "12345");
110 }

References encode_int().

◆ TEST() [75/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeInt32List   
)

Definition at line 505 of file fl_json_message_codec_test.cc.

505  {
506  int32_t data[] = {0, -1, 2, -3, 4};
507  g_autoptr(FlValue) value = fl_value_new_int32_list(data, 5);
508  g_autofree gchar* text = encode_message(value);
509  EXPECT_STREQ(text, "[0,-1,2,-3,4]");
510 }

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

◆ TEST() [76/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeInt32ListEmpty   
)

Definition at line 499 of file fl_json_message_codec_test.cc.

499  {
500  g_autoptr(FlValue) value = fl_value_new_int32_list(nullptr, 0);
501  g_autofree gchar* text = encode_message(value);
502  EXPECT_STREQ(text, "[]");
503 }

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

◆ TEST() [77/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeInt64List   
)

Definition at line 518 of file fl_json_message_codec_test.cc.

518  {
519  int64_t data[] = {0, -1, 2, -3, 4};
520  g_autoptr(FlValue) value = fl_value_new_int64_list(data, 5);
521  g_autofree gchar* text = encode_message(value);
522  EXPECT_STREQ(text, "[0,-1,2,-3,4]");
523 }

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

◆ TEST() [78/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeInt64ListEmpty   
)

Definition at line 512 of file fl_json_message_codec_test.cc.

512  {
513  g_autoptr(FlValue) value = fl_value_new_int64_list(nullptr, 0);
514  g_autofree gchar* text = encode_message(value);
515  EXPECT_STREQ(text, "[]");
516 }

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

◆ TEST() [79/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeIntMax   
)

Definition at line 117 of file fl_json_message_codec_test.cc.

117  {
118  g_autofree gchar* text = encode_int(G_MAXINT64);
119  EXPECT_STREQ(text, "9223372036854775807");
120 }

References encode_int().

◆ TEST() [80/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeIntMin   
)

Definition at line 112 of file fl_json_message_codec_test.cc.

112  {
113  g_autofree gchar* text = encode_int(G_MININT64);
114  EXPECT_STREQ(text, "-9223372036854775808");
115 }

References encode_int().

◆ TEST() [81/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeIntOne   
)

Definition at line 102 of file fl_json_message_codec_test.cc.

102  {
103  g_autofree gchar* text = encode_int(1);
104  EXPECT_STREQ(text, "1");
105 }

References encode_int().

◆ TEST() [82/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeIntZero   
)

Definition at line 97 of file fl_json_message_codec_test.cc.

97  {
98  g_autofree gchar* text = encode_int(0);
99  EXPECT_STREQ(text, "0");
100 }

References encode_int().

◆ TEST() [83/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeListEmpty   
)

Definition at line 538 of file fl_json_message_codec_test.cc.

538  {
539  g_autoptr(FlValue) value = fl_value_new_list();
540  g_autofree gchar* text = encode_message(value);
541  EXPECT_STREQ(text, "[]");
542 }

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

◆ TEST() [84/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeListNested   
)

Definition at line 557 of file fl_json_message_codec_test.cc.

557  {
558  g_autoptr(FlValue) even_numbers = fl_value_new_list();
559  g_autoptr(FlValue) odd_numbers = fl_value_new_list();
560  for (int i = 0; i < 10; i++) {
561  if (i % 2 == 0) {
562  fl_value_append_take(even_numbers, fl_value_new_int(i));
563  } else {
564  fl_value_append_take(odd_numbers, fl_value_new_int(i));
565  }
566  }
567  g_autoptr(FlValue) value = fl_value_new_list();
568  fl_value_append(value, even_numbers);
569  fl_value_append(value, odd_numbers);
570  g_autofree gchar* text = encode_message(value);
571  EXPECT_STREQ(text, "[[0,2,4,6,8],[1,3,5,7,9]]");
572 }

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

◆ TEST() [85/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeListTypes   
)

◆ TEST() [86/115]

◆ TEST() [87/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeMapEmpty   
)

Definition at line 605 of file fl_json_message_codec_test.cc.

605  {
606  g_autoptr(FlValue) value = fl_value_new_map();
607  g_autofree gchar* text = encode_message(value);
608  EXPECT_STREQ(text, "{}");
609 }

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

◆ TEST() [88/115]

◆ TEST() [89/115]

◆ TEST() [90/115]

◆ TEST() [91/115]

◆ TEST() [92/115]

◆ TEST() [93/115]

◆ TEST() [94/115]

◆ TEST() [95/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeMapNested   
)

Definition at line 705 of file fl_json_message_codec_test.cc.

705  {
706  g_autoptr(FlValue) str_to_int = fl_value_new_map();
707  const char* numbers[] = {"zero", "one", "two", "three", nullptr};
708  for (int i = 0; numbers[i] != nullptr; i++) {
709  fl_value_set_take(str_to_int, fl_value_new_string(numbers[i]),
711  }
712  g_autoptr(FlValue) value = fl_value_new_map();
713  fl_value_set_string(value, "str-to-int", str_to_int);
714  g_autofree gchar* text = encode_message(value);
715  EXPECT_STREQ(text,
716  "{\"str-to-int\":{\"zero\":0,\"one\":1,\"two\":2,\"three\":3}}");
717 }

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() [96/115]

◆ TEST() [97/115]

◆ TEST() [98/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeMapValueTypes   
)

Definition at line 687 of file fl_json_message_codec_test.cc.

687  {
688  g_autoptr(FlValue) value = fl_value_new_map();
694  fl_value_new_float(-1.5));
696  fl_value_new_string("hello"));
699  g_autofree gchar* text = encode_message(value);
700  EXPECT_STREQ(text,
701  "{\"null\":null,\"bool\":true,\"int\":42,\"float\":-"
702  "1.5,\"string\":\"hello\",\"list\":[],\"map\":{}}");
703 }

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() [99/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeNull   
)

Definition at line 54 of file fl_json_message_codec_test.cc.

54  {
55  g_autoptr(FlValue) value = fl_value_new_null();
56  g_autofree gchar* text = encode_message(value);
57  EXPECT_STREQ(text, "null");
58 }

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

◆ TEST() [100/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeNullptr   
)

Definition at line 49 of file fl_json_message_codec_test.cc.

49  {
50  g_autofree gchar* text = encode_message(nullptr);
51  EXPECT_STREQ(text, "null");
52 }

References encode_message().

◆ TEST() [101/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeStringEmoji   
)

Definition at line 344 of file fl_json_message_codec_test.cc.

344  {
345  g_autofree gchar* text = encode_string("😀");
346  EXPECT_STREQ(text, "\"😀\"");
347 }

References encode_string().

◆ TEST() [102/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeStringEmpty   
)

Definition at line 282 of file fl_json_message_codec_test.cc.

282  {
283  g_autofree gchar* text = encode_string("");
284  EXPECT_STREQ(text, "\"\"");
285 }

References encode_string().

◆ TEST() [103/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeStringEmptySized   
)

Definition at line 292 of file fl_json_message_codec_test.cc.

292  {
293  g_autoptr(FlValue) value = fl_value_new_string_sized(nullptr, 0);
294  g_autofree gchar* text = encode_message(value);
295  EXPECT_STREQ(text, "\"\"");
296 }

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

◆ TEST() [104/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeStringEscapeBackslash   
)

Definition at line 309 of file fl_json_message_codec_test.cc.

309  {
310  g_autofree gchar* text = encode_string("\\");
311  EXPECT_STREQ(text, "\"\\\\\"");
312 }

References encode_string().

◆ TEST() [105/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeStringEscapeBackspace   
)

Definition at line 314 of file fl_json_message_codec_test.cc.

314  {
315  g_autofree gchar* text = encode_string("\b");
316  EXPECT_STREQ(text, "\"\\b\"");
317 }

References encode_string().

◆ TEST() [106/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeStringEscapeCarriageReturn   
)

Definition at line 329 of file fl_json_message_codec_test.cc.

329  {
330  g_autofree gchar* text = encode_string("\r");
331  EXPECT_STREQ(text, "\"\\r\"");
332 }

References encode_string().

◆ TEST() [107/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeStringEscapeFormFeed   
)

Definition at line 319 of file fl_json_message_codec_test.cc.

319  {
320  g_autofree gchar* text = encode_string("\f");
321  EXPECT_STREQ(text, "\"\\f\"");
322 }

References encode_string().

◆ TEST() [108/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeStringEscapeNewline   
)

Definition at line 324 of file fl_json_message_codec_test.cc.

324  {
325  g_autofree gchar* text = encode_string("\n");
326  EXPECT_STREQ(text, "\"\\n\"");
327 }

References encode_string().

◆ TEST() [109/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeStringEscapeQuote   
)

Definition at line 304 of file fl_json_message_codec_test.cc.

304  {
305  g_autofree gchar* text = encode_string("\"");
306  EXPECT_STREQ(text, "\"\\\"\"");
307 }

References encode_string().

◆ TEST() [110/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeStringEscapeTab   
)

Definition at line 334 of file fl_json_message_codec_test.cc.

334  {
335  g_autofree gchar* text = encode_string("\t");
336  EXPECT_STREQ(text, "\"\\t\"");
337 }

References encode_string().

◆ TEST() [111/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeStringEscapeUnicode   
)

Definition at line 339 of file fl_json_message_codec_test.cc.

339  {
340  g_autofree gchar* text = encode_string("\u0001");
341  EXPECT_STREQ(text, "\"\\u0001\"");
342 }

References encode_string().

◆ TEST() [112/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeStringHello   
)

Definition at line 287 of file fl_json_message_codec_test.cc.

287  {
288  g_autofree gchar* text = encode_string("hello");
289  EXPECT_STREQ(text, "\"hello\"");
290 }

References encode_string().

◆ TEST() [113/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeStringHelloSized   
)

Definition at line 298 of file fl_json_message_codec_test.cc.

298  {
299  g_autoptr(FlValue) value = fl_value_new_string_sized("Hello World", 5);
300  g_autofree gchar* text = encode_message(value);
301  EXPECT_STREQ(text, "\"Hello\"");
302 }

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

◆ TEST() [114/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeUint8List   
)

Definition at line 492 of file fl_json_message_codec_test.cc.

492  {
493  uint8_t data[] = {0, 1, 2, 3, 4};
494  g_autoptr(FlValue) value = fl_value_new_uint8_list(data, 5);
495  g_autofree gchar* text = encode_message(value);
496  EXPECT_STREQ(text, "[0,1,2,3,4]");
497 }

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

◆ TEST() [115/115]

TEST ( FlJsonMessageCodecTest  ,
EncodeUint8ListEmpty   
)

Definition at line 486 of file fl_json_message_codec_test.cc.

486  {
487  g_autoptr(FlValue) value = fl_value_new_uint8_list(nullptr, 0);
488  g_autofree gchar* text = encode_message(value);
489  EXPECT_STREQ(text, "[]");
490 }

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

FL_JSON_MESSAGE_CODEC_ERROR_INVALID_UTF8
@ FL_JSON_MESSAGE_CODEC_ERROR_INVALID_UTF8
Definition: fl_json_message_codec.h:31
fl_value_new_string_sized
G_MODULE_EXPORT FlValue * fl_value_new_string_sized(const gchar *value, size_t value_length)
Definition: fl_value.cc:283
FL_VALUE_TYPE_MAP
@ FL_VALUE_TYPE_MAP
Definition: fl_value.h:75
encode_string
static gchar * encode_string(const gchar *value)
Definition: fl_json_message_codec_test.cc:277
FL_JSON_MESSAGE_CODEC_ERROR_INVALID_OBJECT_KEY_TYPE
@ FL_JSON_MESSAGE_CODEC_ERROR_INVALID_OBJECT_KEY_TYPE
Definition: fl_json_message_codec.h:33
fl_value_new_list
G_MODULE_EXPORT FlValue * fl_value_new_list()
Definition: fl_value.cc:349
encode_error_message
static void encode_error_message(FlValue *value, GQuark domain, gint code)
Definition: fl_json_message_codec_test.cc:21
i
int i
Definition: fl_socket_accessible.cc:18
fl_value_new_bool
G_MODULE_EXPORT FlValue * fl_value_new_bool(bool value)
Definition: fl_value.cc:255
FlValue
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42
fl_json_message_codec_new
G_MODULE_EXPORT FlJsonMessageCodec * fl_json_message_codec_new()
Definition: fl_json_message_codec.cc:306
encode_message
static gchar * encode_message(FlValue *value)
Definition: fl_json_message_codec_test.cc:11
fl_value_set_take
G_MODULE_EXPORT void fl_value_set_take(FlValue *self, FlValue *key, FlValue *value)
Definition: fl_value.cc:618
encode_bool
static gchar * encode_bool(gboolean value)
Definition: fl_json_message_codec_test.cc:65
fl_value_new_null
G_MODULE_EXPORT FlValue * fl_value_new_null()
Definition: fl_value.cc:251
FL_VALUE_TYPE_LIST
@ FL_VALUE_TYPE_LIST
Definition: fl_value.h:74
fl_value_get_bool
G_MODULE_EXPORT bool fl_value_get_bool(FlValue *self)
Definition: fl_value.cc:661
fl_value_new_int
G_MODULE_EXPORT FlValue * fl_value_new_int(int64_t value)
Definition: fl_value.cc:262
fl_value_get_string
const G_MODULE_EXPORT gchar * fl_value_get_string(FlValue *self)
Definition: fl_value.cc:682
encode_float
static gchar * encode_float(double value)
Definition: fl_json_message_codec_test.cc:193
FL_VALUE_TYPE_NULL
@ FL_VALUE_TYPE_NULL
Definition: fl_value.h:65
fl_value_get_int
G_MODULE_EXPORT int64_t fl_value_get_int(FlValue *self)
Definition: fl_value.cc:668
fl_value_ref
G_MODULE_EXPORT FlValue * fl_value_ref(FlValue *self)
Definition: fl_value.cc:394
fl_value_new_map
G_MODULE_EXPORT FlValue * fl_value_new_map()
Definition: fl_value.cc:366
fl_value_get_type
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
Definition: fl_value.cc:466
fl_json_message_codec_encode
G_MODULE_EXPORT gchar * fl_json_message_codec_encode(FlJsonMessageCodec *codec, FlValue *value, GError **error)
Definition: fl_json_message_codec.cc:311
FL_VALUE_TYPE_STRING
@ FL_VALUE_TYPE_STRING
Definition: fl_value.h:69
fl_value_new_float_list
G_MODULE_EXPORT FlValue * fl_value_new_float_list(const double *data, size_t data_length)
Definition: fl_value.cc:339
encode_int
static gchar * encode_int(int64_t value)
Definition: fl_json_message_codec_test.cc:92
decode_error_message
static void decode_error_message(const char *text, GQuark domain, gint code)
Definition: fl_json_message_codec_test.cc:41
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53
fl_value_new_int32_list
G_MODULE_EXPORT FlValue * fl_value_new_int32_list(const int32_t *data, size_t data_length)
Definition: fl_value.cc:309
fl_value_get_float
G_MODULE_EXPORT double fl_value_get_float(FlValue *self)
Definition: fl_value.cc:675
fl_value_append_take
G_MODULE_EXPORT void fl_value_append_take(FlValue *self, FlValue *value)
Definition: fl_value.cc:600
fl_value_get_length
G_MODULE_EXPORT size_t fl_value_get_length(FlValue *self)
Definition: fl_value.cc:724
fl_value_equal
G_MODULE_EXPORT bool fl_value_equal(FlValue *a, FlValue *b)
Definition: fl_value.cc:471
fl_value_set_string
G_MODULE_EXPORT void fl_value_set_string(FlValue *self, const gchar *key, FlValue *value)
Definition: fl_value.cc:639
FL_VALUE_TYPE_INT
@ FL_VALUE_TYPE_INT
Definition: fl_value.h:67
decode_message
static FlValue * decode_message(const char *text)
Definition: fl_json_message_codec_test.cc:30
result
GAsyncResult * result
Definition: fl_text_input_handler.cc:106
fl_value_new_int64_list
G_MODULE_EXPORT FlValue * fl_value_new_int64_list(const int64_t *data, size_t data_length)
Definition: fl_value.cc:319
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
FL_JSON_MESSAGE_CODEC_ERROR
#define FL_JSON_MESSAGE_CODEC_ERROR
Definition: fl_json_message_codec.h:27
fl_json_message_codec_decode
G_MODULE_EXPORT FlValue * fl_json_message_codec_decode(FlJsonMessageCodec *codec, const gchar *text, GError **error)
Definition: fl_json_message_codec.cc:326
fl_value_new_uint8_list
G_MODULE_EXPORT FlValue * fl_value_new_uint8_list(const uint8_t *data, size_t data_length)
Definition: fl_value.cc:292
fl_value_append
G_MODULE_EXPORT void fl_value_append(FlValue *self, FlValue *value)
Definition: fl_value.cc:592
FL_VALUE_TYPE_FLOAT
@ FL_VALUE_TYPE_FLOAT
Definition: fl_value.h:68
fl_value_new_float
G_MODULE_EXPORT FlValue * fl_value_new_float(double value)
Definition: fl_value.cc:269
FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON
@ FL_JSON_MESSAGE_CODEC_ERROR_INVALID_JSON
Definition: fl_json_message_codec.h:32
FL_VALUE_TYPE_BOOL
@ FL_VALUE_TYPE_BOOL
Definition: fl_value.h:66
value
uint8_t value
Definition: fl_standard_message_codec.cc:36
fl_value_new_string
G_MODULE_EXPORT FlValue * fl_value_new_string(const gchar *value)
Definition: fl_value.cc:276