Skip to content

Commit

Permalink
Add testSpacePreserve to SharedStrings tests (#57)
Browse files Browse the repository at this point in the history
* Add testSpacePreserve to SharedStrings tests
* Add file.parseSharedStrings call to testPublicAPI
* Disable Travis tests for iOS and tvOS simulators
  • Loading branch information
MaxDesiatov committed Apr 17, 2019
1 parent 1c8f3f5 commit 5d619af
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
13 changes: 6 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ language: swift
env:
global:
- FRAMEWORK_NAME=CoreXLSX
- SCHEME=CoreXLSX

jobs:
include:
Expand Down Expand Up @@ -36,13 +35,13 @@ jobs:
script:
- carthage bootstrap
- >
xcodebuild test -scheme $SCHEME
xcodebuild build -scheme CoreXLSXiOS \
-sdk iphonesimulator -destination "$IOS_DEVICE" | xcpretty
- >
xcodebuild test -scheme $SCHEME
xcodebuild build -scheme CoreXSLXtvOS
-sdk appletvsimulator -destination "$TVOS_DEVICE" | xcpretty
- >
xcodebuild test -enableCodeCoverage YES -scheme $SCHEME
xcodebuild test -enableCodeCoverage YES -scheme CoreXLSX
-sdk macosx | xcpretty
- <<: *test
osx_image: xcode10.1
Expand All @@ -59,13 +58,13 @@ jobs:
- TESTS_PATH=$PWD/Tests/CoreXLSXTests swift test
- carthage bootstrap
- >
xcodebuild test -scheme $SCHEME
xcodebuild build -scheme CoreXLSXiOS
-sdk iphonesimulator -destination "$IOS_DEVICE" | xcpretty
- >
xcodebuild test -scheme $SCHEME
xcodebuild build -scheme CoreXSLXtvOS
-sdk appletvsimulator -destination "$TVOS_DEVICE" | xcpretty
- >
xcodebuild test -enableCodeCoverage YES -scheme $SCHEME
xcodebuild test -enableCodeCoverage YES -scheme CoreXLSX
-sdk macosx | xcpretty
after_success:
- bash <(curl -s https://codecov.io/bash)
Expand Down
3 changes: 3 additions & 0 deletions Tests/CoreXLSXTests/CoreXLSX.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ final class CoreXLSXTests: XCTestCase {
let rowsRange: ClosedRange<UInt> = 3...10
let cellsInRange = ws.cells(atColumns: closedRange2, rows: rowsRange)
XCTAssertEqual(cellsInRange.count, closedRange2.count * rowsRange.count)

let strings = try file.parseSharedStrings()
XCTAssertEqual(strings.items.count, 18)
}

func testLegacyPublicAPI() throws {
Expand Down
22 changes: 22 additions & 0 deletions Tests/CoreXLSXTests/SharedStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ private let parsed = SharedStrings(uniqueCount: 18, items: [
private let columnC = ["Name", "Andy", "Andy", "Andy", "Andy", "Andy",
"Chloe", "Chloe", "Chloe", "Chloe", "Chloe"]

private let spacePreserveXML =
"""
<sst uniqueCount="1">
<si>
<r>
<rPr>
<sz val="10"/>
<color indexed="8"/>
<rFont val="Helvetica Neue"/>
</rPr>
<t xml:space="preserve"> the </t>
</r>
</si>
</sst>
""".data(using: .utf8)!

final class SharedStringsTests: XCTestCase {
func testSharedStrings() throws {
guard let file =
Expand Down Expand Up @@ -76,6 +92,12 @@ final class SharedStringsTests: XCTestCase {
XCTAssertEqual(columnC, columnCStrings)
}

func testSpacePreserve() throws {
let decoder = XMLDecoder()
let strings = try decoder.decode(SharedStrings.self, from: spacePreserveXML)
XCTAssertEqual(strings.items.count, 1)
}

static let allTests = [
("testSharedStrings", testSharedStrings),
("testSharedStringsOrder", testSharedStringsOrder),
Expand Down

0 comments on commit 5d619af

Please sign in to comment.