This repository was archived by the owner on Oct 19, 2024. It is now read-only.
File tree 3 files changed +60
-0
lines changed 3 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 2
2
import XCTest
3
3
4
4
class AnyCodableTests : XCTestCase {
5
+
6
+ func testEquivalency( ) {
7
+ let boolean = true
8
+ let integer = 42
9
+ let double = 3.141592653589793
10
+ let string = " string "
11
+ let array = [ 1 , 2 , 3 ]
12
+ let nested = [
13
+ " a " : " alpha " ,
14
+ " b " : " bravo " ,
15
+ " c " : " charlie " ,
16
+ ]
17
+ XCTAssertEqual ( AnyCodable ( boolean) , AnyCodable ( boolean) )
18
+ XCTAssertEqual ( AnyCodable ( integer) , AnyCodable ( integer) )
19
+ XCTAssertEqual ( AnyCodable ( double) , AnyCodable ( double) )
20
+ XCTAssertEqual ( AnyCodable ( string) , AnyCodable ( string) )
21
+ XCTAssertEqual ( AnyCodable ( array) , AnyCodable ( array) )
22
+ XCTAssertEqual ( AnyCodable ( nested) , AnyCodable ( nested) )
23
+ }
24
+
5
25
func testJSONDecoding( ) throws {
6
26
let json = """
7
27
{
Original file line number Diff line number Diff line change 2
2
import XCTest
3
3
4
4
class AnyDecodableTests : XCTestCase {
5
+
6
+ func testEquivalency( ) {
7
+ let boolean = true
8
+ let integer = 42
9
+ let double = 3.141592653589793
10
+ let string = " string "
11
+ let array = [ 1 , 2 , 3 ]
12
+ let nested = [
13
+ " a " : " alpha " ,
14
+ " b " : " bravo " ,
15
+ " c " : " charlie " ,
16
+ ]
17
+ XCTAssertEqual ( AnyDecodable ( boolean) , AnyDecodable ( boolean) )
18
+ XCTAssertEqual ( AnyDecodable ( integer) , AnyDecodable ( integer) )
19
+ XCTAssertEqual ( AnyDecodable ( double) , AnyDecodable ( double) )
20
+ XCTAssertEqual ( AnyDecodable ( string) , AnyDecodable ( string) )
21
+ XCTAssertEqual ( AnyDecodable ( array) , AnyDecodable ( array) )
22
+ XCTAssertEqual ( AnyDecodable ( nested) , AnyDecodable ( nested) )
23
+ }
24
+
5
25
func testJSONDecoding( ) throws {
6
26
let json = """
7
27
{
Original file line number Diff line number Diff line change 2
2
import XCTest
3
3
4
4
class AnyEncodableTests : XCTestCase {
5
+
6
+ func testEquivalency( ) {
7
+ let boolean = true
8
+ let integer = 42
9
+ let double = 3.141592653589793
10
+ let string = " string "
11
+ let array = [ 1 , 2 , 3 ]
12
+ let nested = [
13
+ " a " : " alpha " ,
14
+ " b " : " bravo " ,
15
+ " c " : " charlie " ,
16
+ ]
17
+ XCTAssertEqual ( AnyEncodable ( boolean) , AnyEncodable ( boolean) )
18
+ XCTAssertEqual ( AnyEncodable ( integer) , AnyEncodable ( integer) )
19
+ XCTAssertEqual ( AnyEncodable ( double) , AnyEncodable ( double) )
20
+ XCTAssertEqual ( AnyEncodable ( string) , AnyEncodable ( string) )
21
+ XCTAssertEqual ( AnyEncodable ( array) , AnyEncodable ( array) )
22
+ XCTAssertEqual ( AnyEncodable ( nested) , AnyEncodable ( nested) )
23
+ }
24
+
5
25
func testJSONEncoding( ) throws {
6
26
let dictionary : [ String : AnyEncodable ] = [
7
27
" boolean " : true ,
You can’t perform that action at this time.
0 commit comments