From 932188944e54199fa4df9598b2028e3d90de4bef Mon Sep 17 00:00:00 2001 From: Kai Scheffer Date: Tue, 10 Aug 2021 23:14:09 +0200 Subject: [PATCH] 4.3 App Store --- Tests/ChartsTests/ChartDataTests.swift | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Tests/ChartsTests/ChartDataTests.swift b/Tests/ChartsTests/ChartDataTests.swift index a9c9e73758..bb33362829 100644 --- a/Tests/ChartsTests/ChartDataTests.swift +++ b/Tests/ChartsTests/ChartDataTests.swift @@ -89,7 +89,28 @@ class ChartDataTests: XCTestCase { let res = set.entriesForXValue(Double(1621860300)) let res2 = set.entriesForXValue(Double(1621860310)) - XCTAssertTrue(res?.advanced(by: 1) == res2) + XCTAssertTrue(res.first == set[slowMatch!]) + XCTAssertTrue(res2.first == nil) + + let up = set.entryIndex(x: set.last!.x + 1, closestToY: .nan, rounding: .up) + + XCTAssertTrue(up == -1) + + let upClosest = set.entryIndex(x: set.last!.x + 1 , closestToY: .nan, rounding: .closest) + + XCTAssertTrue(upClosest == set.endIndex - 1) + + let down = set.entryIndex(x: set.last!.x + 1, closestToY: .nan, rounding: .down) + + XCTAssertTrue(down == set.endIndex - 1) + + let minDown = set.entryIndex(x: set.first!.x - 1, closestToY: .nan, rounding: .down) + + XCTAssertTrue(minDown == -1) + + let minUp = set.entryIndex(x: set.first!.x - 1, closestToY: .nan, rounding: .up) + + XCTAssertTrue(minUp == 0) let closestIdx = set.entryIndex(x: Double(1621860310), closestToY: .nan, rounding: .closest)