Skip to content

Commit 1d7aaec

Browse files
committed
Add test cases
1 parent efc5acc commit 1d7aaec

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

LeanplumSDKApp/LeanplumSDKTests/Classes/ContentMergerTest.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,30 @@ class ContentMergerTest: XCTestCase {
3636
XCTAssertEqual(arrMixed, result)
3737
}
3838

39-
func testMergeArraysWithDict() {
39+
func testMergeArrayWithDict() {
4040
let arr: [AnyHashable] = [1, 2, 3, 4]
4141
let arrDiff: AnyDictionary = ["[0]": 5, "[3]": 6]
4242
let expected: [AnyHashable] = [5, 2, 3, 6]
4343
let result = ContentMerger.merge(vars: arr, diff: arrDiff) as! [AnyHashable]
4444
XCTAssertEqual(expected, result)
4545
}
4646

47+
func testMergeArrayWithDictAdditionalValue() {
48+
let arr: [AnyHashable] = [1, 2, 3, 4]
49+
let arrDiff: AnyDictionary = ["[4]": 5]
50+
let expected: [AnyHashable] = [1, 2, 3, 4, 5]
51+
let result = ContentMerger.merge(vars: arr, diff: arrDiff) as! [AnyHashable]
52+
XCTAssertEqual(expected, result)
53+
}
54+
55+
func testMergeEmptyArrayWithDict() {
56+
let arr: [AnyHashable] = []
57+
let arrDiff: AnyDictionary = ["[4]": 5]
58+
let expected: [AnyHashable] = [NSNull(), NSNull(), NSNull(), NSNull(), 5]
59+
let result = ContentMerger.merge(vars: arr, diff: arrDiff) as! [AnyHashable]
60+
XCTAssertEqual(expected, result)
61+
}
62+
4763
func testMergeArraysMixed() {
4864
let arr: [AnyHashable] = [1, 2, "value", 4, NSNull()]
4965
let arrDiff: AnyDictionary = ["[0]": 6, "[2]": "newValue", "[4]": "anotherValue"]

0 commit comments

Comments
 (0)