Skip to content
This repository was archived by the owner on Oct 19, 2024. It is now read-only.

Commit 9ab024b

Browse files
committed
Add equivalency tests
1 parent 876d162 commit 9ab024b

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

Tests/AnyCodableTests/AnyCodableTests.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22
import XCTest
33

44
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+
525
func testJSONDecoding() throws {
626
let json = """
727
{

Tests/AnyCodableTests/AnyDecodableTests.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22
import XCTest
33

44
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+
525
func testJSONDecoding() throws {
626
let json = """
727
{

Tests/AnyCodableTests/AnyEncodableTests.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22
import XCTest
33

44
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+
525
func testJSONEncoding() throws {
626
let dictionary: [String: AnyEncodable] = [
727
"boolean": true,

0 commit comments

Comments
 (0)