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, CanEncodeAndDecodeNil)
 
 TEST (FlutterJSONCodec, CanEncodeAndDecodeArray)
 
 TEST (FlutterJSONCodec, CanEncodeAndDecodeDictionary)
 

Function Documentation

◆ TEST() [1/8]

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/8]

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/8]

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/8]

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/8]

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/8]

TEST ( FlutterJSONCodec  ,
CanEncodeAndDecodeNil   
)

Definition at line 45 of file flutter_codecs_unittest.mm.

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

◆ TEST() [7/8]

TEST ( FlutterJSONCodec  ,
CanEncodeAndDecodeArray   
)

Definition at line 51 of file flutter_codecs_unittest.mm.

References value.

51  {
52  NSArray* value = @[ [NSNull null], @"hello", @3.14, @47, @{@"a" : @"nested"} ];
53  FlutterJSONMessageCodec* codec = [FlutterJSONMessageCodec sharedInstance];
54  NSData* encoded = [codec encode:value];
55  NSArray* decoded = [codec decode:encoded];
56  ASSERT_TRUE([value isEqualTo:decoded]);
57 }
uint8_t value

◆ TEST() [8/8]

TEST ( FlutterJSONCodec  ,
CanEncodeAndDecodeDictionary   
)

Definition at line 59 of file flutter_codecs_unittest.mm.

References value.

59  {
60  NSDictionary* value = @{@"a" : @3.14, @"b" : @47, @"c" : [NSNull null], @"d" : @[ @"nested" ]};
61  FlutterJSONMessageCodec* codec = [FlutterJSONMessageCodec sharedInstance];
62  NSData* encoded = [codec encode:value];
63  NSDictionary* decoded = [codec decode:encoded];
64  ASSERT_TRUE([value isEqualTo:decoded]);
65 }
uint8_t value