Flutter Engine
flutter_codecs_unittest.mm File Reference
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterCodecs.h"
#include "gtest/gtest.h"

Go to the source code of this file.

Functions

 TEST (FlutterStringCodec, CanEncodeAndDecodeNil)
 
 TEST (FlutterStringCodec, CanEncodeAndDecodeEmptyString)
 
 TEST (FlutterStringCodec, CanEncodeAndDecodeAsciiString)
 
 TEST (FlutterStringCodec, CanEncodeAndDecodeNonAsciiString)
 
 TEST (FlutterStringCodec, CanEncodeAndDecodeNonBMPString)
 
 TEST (FlutterJSONCodec, CanDecodeZeroLength)
 
 TEST (FlutterJSONCodec, CanEncodeAndDecodeNil)
 
 TEST (FlutterJSONCodec, CanEncodeAndDecodeArray)
 
 TEST (FlutterJSONCodec, CanEncodeAndDecodeDictionary)
 

Function Documentation

◆ TEST() [1/9]

TEST ( FlutterStringCodec  ,
CanEncodeAndDecodeNil   
)

Definition at line 9 of file flutter_codecs_unittest.mm.

9  {
10  FlutterStringCodec* codec = [FlutterStringCodec sharedInstance];
11  ASSERT_TRUE([codec encode:nil] == nil);
12  ASSERT_TRUE([codec decode:nil] == nil);
13 }

◆ TEST() [2/9]

TEST ( FlutterStringCodec  ,
CanEncodeAndDecodeEmptyString   
)

Definition at line 15 of file flutter_codecs_unittest.mm.

15  {
16  FlutterStringCodec* codec = [FlutterStringCodec sharedInstance];
17  ASSERT_TRUE([[codec encode:@""] isEqualTo:[NSData data]]);
18  ASSERT_TRUE([[codec decode:[NSData data]] isEqualTo:@""]);
19 }

◆ TEST() [3/9]

TEST ( FlutterStringCodec  ,
CanEncodeAndDecodeAsciiString   
)

Definition at line 21 of file flutter_codecs_unittest.mm.

References value.

21  {
22  NSString* value = @"hello world";
23  FlutterStringCodec* codec = [FlutterStringCodec sharedInstance];
24  NSData* encoded = [codec encode:value];
25  NSString* decoded = [codec decode:encoded];
26  ASSERT_TRUE([value isEqualTo:decoded]);
27 }
uint8_t value

◆ TEST() [4/9]

TEST ( FlutterStringCodec  ,
CanEncodeAndDecodeNonAsciiString   
)

Definition at line 29 of file flutter_codecs_unittest.mm.

References value.

29  {
30  NSString* value = @"hello \u263A world";
31  FlutterStringCodec* codec = [FlutterStringCodec sharedInstance];
32  NSData* encoded = [codec encode:value];
33  NSString* decoded = [codec decode:encoded];
34  ASSERT_TRUE([value isEqualTo:decoded]);
35 }
uint8_t value

◆ TEST() [5/9]

TEST ( FlutterStringCodec  ,
CanEncodeAndDecodeNonBMPString   
)

Definition at line 37 of file flutter_codecs_unittest.mm.

References value.

37  {
38  NSString* value = @"hello \U0001F602 world";
39  FlutterStringCodec* codec = [FlutterStringCodec sharedInstance];
40  NSData* encoded = [codec encode:value];
41  NSString* decoded = [codec decode:encoded];
42  ASSERT_TRUE([value isEqualTo:decoded]);
43 }
uint8_t value

◆ TEST() [6/9]

TEST ( FlutterJSONCodec  ,
CanDecodeZeroLength   
)

Definition at line 45 of file flutter_codecs_unittest.mm.

45  {
46  FlutterJSONMessageCodec* codec = [FlutterJSONMessageCodec sharedInstance];
47  ASSERT_TRUE([codec decode:[NSData data]] == nil);
48 }

◆ TEST() [7/9]

TEST ( FlutterJSONCodec  ,
CanEncodeAndDecodeNil   
)

Definition at line 50 of file flutter_codecs_unittest.mm.

50  {
51  FlutterJSONMessageCodec* codec = [FlutterJSONMessageCodec sharedInstance];
52  ASSERT_TRUE([codec encode:nil] == nil);
53  ASSERT_TRUE([codec decode:nil] == nil);
54 }

◆ TEST() [8/9]

TEST ( FlutterJSONCodec  ,
CanEncodeAndDecodeArray   
)

Definition at line 56 of file flutter_codecs_unittest.mm.

References value.

56  {
57  NSArray* value = @[ [NSNull null], @"hello", @3.14, @47, @{@"a" : @"nested"} ];
58  FlutterJSONMessageCodec* codec = [FlutterJSONMessageCodec sharedInstance];
59  NSData* encoded = [codec encode:value];
60  NSArray* decoded = [codec decode:encoded];
61  ASSERT_TRUE([value isEqualTo:decoded]);
62 }
uint8_t value

◆ TEST() [9/9]

TEST ( FlutterJSONCodec  ,
CanEncodeAndDecodeDictionary   
)

Definition at line 64 of file flutter_codecs_unittest.mm.

References value.

64  {
65  NSDictionary* value = @{@"a" : @3.14, @"b" : @47, @"c" : [NSNull null], @"d" : @[ @"nested" ]};
66  FlutterJSONMessageCodec* codec = [FlutterJSONMessageCodec sharedInstance];
67  NSData* encoded = [codec encode:value];
68  NSDictionary* decoded = [codec decode:encoded];
69  ASSERT_TRUE([value isEqualTo:decoded]);
70 }
uint8_t value