| Flutter macOS Embedder |

Functions
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
FLUTTER_ASSERT_ARC | 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 | ( | FlutterJSONCodec | ,
|  | CanDecodeZeroLength |
| ) |  |

Definition at line 47 of file flutter_codecs_unittest.mm.

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

## ◆ TEST() [2/9]

TEST | ( | FlutterJSONCodec | ,
|  | CanEncodeAndDecodeArray |
| ) |  |

Definition at line 58 of file flutter_codecs_unittest.mm.

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

## ◆ TEST() [3/9]

TEST | ( | FlutterJSONCodec | ,
|  | CanEncodeAndDecodeDictionary |
| ) |  |

Definition at line 66 of file flutter_codecs_unittest.mm.

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

## ◆ TEST() [4/9]

TEST | ( | FlutterJSONCodec | ,
|  | CanEncodeAndDecodeNil |
| ) |  |

Definition at line 52 of file flutter_codecs_unittest.mm.

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

## ◆ TEST() [5/9]

TEST | ( | FlutterStringCodec | ,
|  | CanEncodeAndDecodeAsciiString |
| ) |  |

Definition at line 23 of file flutter_codecs_unittest.mm.

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

## ◆ TEST() [6/9]

TEST | ( | FlutterStringCodec | ,
|  | CanEncodeAndDecodeEmptyString |
| ) |  |

Definition at line 17 of file flutter_codecs_unittest.mm.

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

## ◆ TEST() [7/9]

FLUTTER_ASSERT_ARC TEST | ( | FlutterStringCodec | ,
|  | CanEncodeAndDecodeNil |
| ) |  |

Definition at line 11 of file flutter_codecs_unittest.mm.

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

## ◆ TEST() [8/9]

TEST | ( | FlutterStringCodec | ,
|  | CanEncodeAndDecodeNonAsciiString |
| ) |  |

Definition at line 31 of file flutter_codecs_unittest.mm.

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

## ◆ TEST() [9/9]

TEST | ( | FlutterStringCodec | ,
|  | CanEncodeAndDecodeNonBMPString |
| ) |  |

Definition at line 39 of file flutter_codecs_unittest.mm.

39 {
40 NSString* value = @"hello \U0001F602 world";
41 FlutterStringCodec* codec = [FlutterStringCodec sharedInstance];
42 NSData* encoded = [codec encode:value];
43 NSString* decoded = [codec decode:encoded];
44 ASSERT_TRUE([value isEqualTo:decoded]);
45 }
FlutterStringCodec
Definition: FlutterCodecs.h:63
FlutterJSONMessageCodec
Definition: FlutterCodecs.h:81