mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
40 lines
1.1 KiB
Swift
40 lines
1.1 KiB
Swift
//
|
|
// YamlParserTests.swift
|
|
// SwiftLint
|
|
//
|
|
// Created by Scott Hoyt on 1/1/16.
|
|
// Copyright © 2016 Realm. All rights reserved.
|
|
//
|
|
|
|
@testable import SwiftLintFramework
|
|
import XCTest
|
|
|
|
class YamlParserTests: XCTestCase {
|
|
|
|
func testParseEmptyString() {
|
|
XCTAssertEqual((try YamlParser.parse("")).count, 0,
|
|
"Parsing empty YAML string should succeed")
|
|
}
|
|
|
|
func testParseValidString() {
|
|
XCTAssertEqual(try YamlParser.parse("a: 1\nb: 2").count, 2,
|
|
"Parsing valid YAML string should succeed")
|
|
}
|
|
|
|
func testParseInvalidStringThrows() {
|
|
checkError(YamlParserError.yamlParsing("expected end, near \"a\"")) {
|
|
_ = try YamlParser.parse("|\na")
|
|
}
|
|
}
|
|
}
|
|
|
|
extension YamlParserTests {
|
|
static var allTests: [(String, (YamlParserTests) -> () throws -> Void)] {
|
|
return [
|
|
("testParseEmptyString", testParseEmptyString),
|
|
("testParseValidString", testParseValidString),
|
|
("testParseInvalidStringThrows", testParseInvalidStringThrows)
|
|
]
|
|
}
|
|
}
|