add yaml tests

This commit is contained in:
Yonas Kolb 2018-03-02 00:04:54 +11:00
parent 9b7f8606c2
commit 9e02dbd420
2 changed files with 48 additions and 0 deletions

19
Tests/Fixtures/yaml.yml Normal file
View File

@ -0,0 +1,19 @@
true: true
false: false
yes: YES
no: NO
yesQuote: "YES"
noQuote: "NO"
int: 1
intQuote: "1"
float: 3.2
string: hello
stringQuote: "hello"
space: " "
empty:
emptyQuote: ""
emptyDictionary: {}
arrayLiteral: [1,2]
arrayList:
- 1
- 2

View File

@ -3,6 +3,7 @@ import ProjectSpec
import Spectre
import XcodeGenKit
import xcproj
import Foundation
func specLoadingTests() {
@ -46,6 +47,34 @@ func specLoadingTests() {
Target(name: "NewTarget", type: .application, platform: .iOS),
]
}
$0.it("parses yaml types") {
let path = fixturePath + "yaml.yml"
let dictionary = try loadYamlDictionary(path: path)
let expectedDictionary: [String: Any] = [
"true": true,
"false": false,
"yes": true,
"no": false,
"yesQuote": true,
"noQuote": false,
"int": 1,
"intQuote": 1,
"float": 3.2,
"string": "hello",
"stringQuote": "hello",
"space": " ",
"empty": "",
"emptyQuote": "",
"emptyDictionary": [String: Any](),
"arrayLiteral": [1,2],
"arrayList": [1,2],
]
if !(dictionary as NSDictionary).isEqual(expectedDictionary) {
throw failure("parsed yaml types don't match")
}
}
}
describe("Spec Loader JSON") {