-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathUtilityTests.swift
More file actions
27 lines (25 loc) · 833 Bytes
/
UtilityTests.swift
File metadata and controls
27 lines (25 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//
// UtilityTests.swift
// JSONCodable
//
// Created by FoxRichard on 3/9/16.
//
//
import XCTest
@testable import JSONCodable
class UtilityTests: XCTestCase {
func testArrayIndexDecoding() {
let jsonObj = ["test":"test"]
let decoder = JSONDecoder(object: jsonObj)
XCTAssert(decoder.parseArrayIndex("[0]") == 0)
XCTAssert(decoder.parseArrayIndex("[1]") == 1)
XCTAssert(decoder.parseArrayIndex("[10]") == 10)
XCTAssert(decoder.parseArrayIndex("[202]") == 202)
XCTAssert(decoder.parseArrayIndex("[1111111]") == 1111111)
XCTAssert(decoder.parseArrayIndex("[zero]") == nil)
XCTAssert(decoder.parseArrayIndex("[1A]") == nil)
XCTAssert(decoder.parseArrayIndex("[^]") == nil)
XCTAssert(decoder.parseArrayIndex("HAHA") == nil)
XCTAssert(decoder.parseArrayIndex("[-1]") == -1)
}
}