|
| 1 | +// Copyright 2019-2020 CoreOffice contributors |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | +// |
| 15 | +// Created by Max Desiatov on 12/06/2020. |
| 16 | +// |
| 17 | + |
| 18 | +@testable import CoreXLSX |
| 19 | +import XCTest |
| 20 | + |
| 21 | +final class CellQueriesTests: XCTestCase { |
| 22 | + // swiftlint:disable:next function_body_length |
| 23 | + func testDates() throws { |
| 24 | + let cells = [ |
| 25 | + Cell( |
| 26 | + reference: CellReference(ColumnReference("I")!, 2), |
| 27 | + type: nil, |
| 28 | + s: Optional("7"), |
| 29 | + inlineString: nil, |
| 30 | + formula: nil, |
| 31 | + value: "0.39583333333212067" |
| 32 | + ), |
| 33 | + Cell( |
| 34 | + reference: CellReference(ColumnReference("J")!, 2), |
| 35 | + type: nil, |
| 36 | + s: Optional("7"), |
| 37 | + inlineString: nil, |
| 38 | + formula: nil, |
| 39 | + value: "0.54166666666787933" |
| 40 | + ), |
| 41 | + Cell( |
| 42 | + reference: CellReference(ColumnReference("K")!, 2), |
| 43 | + type: nil, |
| 44 | + s: Optional("7"), |
| 45 | + inlineString: nil, |
| 46 | + formula: nil, |
| 47 | + value: "0.625" |
| 48 | + ), |
| 49 | + Cell( |
| 50 | + reference: CellReference(ColumnReference("L")!, 2), |
| 51 | + type: nil, |
| 52 | + s: Optional("7"), |
| 53 | + inlineString: nil, |
| 54 | + formula: nil, |
| 55 | + value: "0.8125" |
| 56 | + ), |
| 57 | + Cell( |
| 58 | + reference: CellReference(ColumnReference("O")!, 2), |
| 59 | + type: nil, |
| 60 | + s: Optional("7"), |
| 61 | + inlineString: nil, |
| 62 | + formula: nil, |
| 63 | + value: "0.625" |
| 64 | + ), |
| 65 | + Cell( |
| 66 | + reference: CellReference(ColumnReference("P")!, 2), |
| 67 | + type: nil, |
| 68 | + s: Optional("7"), |
| 69 | + inlineString: nil, |
| 70 | + formula: nil, |
| 71 | + value: "0.75" |
| 72 | + ), |
| 73 | + Cell( |
| 74 | + reference: CellReference(ColumnReference("U")!, 2), |
| 75 | + type: nil, |
| 76 | + s: Optional("7"), |
| 77 | + inlineString: nil, |
| 78 | + formula: nil, |
| 79 | + value: "0.33333333333212067" |
| 80 | + ), |
| 81 | + Cell( |
| 82 | + reference: CellReference(ColumnReference("V")!, 2), |
| 83 | + type: nil, |
| 84 | + s: Optional("7"), |
| 85 | + inlineString: nil, |
| 86 | + formula: nil, |
| 87 | + value: "0.45833333333212067" |
| 88 | + ), |
| 89 | + Cell( |
| 90 | + reference: CellReference(ColumnReference("Y")!, 2), |
| 91 | + type: nil, |
| 92 | + s: Optional("7"), |
| 93 | + inlineString: nil, |
| 94 | + formula: nil, |
| 95 | + value: "0.33333333333212067" |
| 96 | + ), |
| 97 | + Cell( |
| 98 | + reference: CellReference(ColumnReference("Z")!, 2), |
| 99 | + type: nil, |
| 100 | + s: Optional("7"), |
| 101 | + inlineString: nil, |
| 102 | + formula: nil, |
| 103 | + value: "0.45833333333212067" |
| 104 | + ), |
| 105 | + ] |
| 106 | + |
| 107 | + XCTAssertEqual( |
| 108 | + cells.compactMap { $0.dateValue?.timeIntervalSince1970 }, |
| 109 | + [-2_209_127_400.0, -2_209_114_800.0, -2_209_107_600.0, -2_209_091_400.0, -2_209_107_600.0, |
| 110 | + -2_209_096_800.0, -2_209_132_800.0, -2_209_122_000.0, -2_209_132_800.0, -2_209_122_000.0] |
| 111 | + ) |
| 112 | + } |
| 113 | +} |
0 commit comments