Skip to content
This repository has been archived by the owner on Jul 8, 2019. It is now read-only.

Commit

Permalink
Initial tests for TTTArrayFormatter
Browse files Browse the repository at this point in the history
  • Loading branch information
yas375 committed May 15, 2016
1 parent 6233e7c commit 4bf02ad
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Example/FormatterKit Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

/* Begin PBXBuildFile section */
500C0A6D1C948B5500F643D3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 500C0A6C1C948B5500F643D3 /* Main.storyboard */; };
500C616B1CE79EE7002A1D96 /* ArrayFormatterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 500C616A1CE79EE7002A1D96 /* ArrayFormatterTests.swift */; };
502F03151CA8FDCC0026119C /* FormatterKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 502F03141CA8FDCC0026119C /* FormatterKit.framework */; };
5044222F1CE7A188005E5721 /* ArrayFormatterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5044222E1CE7A188005E5721 /* ArrayFormatterTests.swift */; };
505136C41CCE1EF600569478 /* TimeIntervalFormatterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505136C31CCE1EF600569478 /* TimeIntervalFormatterTests.swift */; };
50ACC1E31CD0B0DA004FB5F1 /* TimeIntervalFormatterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50ACC1E21CD0B0DA004FB5F1 /* TimeIntervalFormatterTests.swift */; };
50ACC1F11CD0B111004FB5F1 /* TimeIntervalFormatterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50ACC1F01CD0B111004FB5F1 /* TimeIntervalFormatterTests.swift */; };
Expand Down Expand Up @@ -314,8 +316,10 @@
500783121CAB9BAD0065B481 /* ro */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ro; path = ro.lproj/InfoPlist.strings; sourceTree = "<group>"; };
500783131CAB9BAE0065B481 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/InfoPlist.strings"; sourceTree = "<group>"; };
500C0A6C1C948B5500F643D3 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
500C616A1CE79EE7002A1D96 /* ArrayFormatterTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArrayFormatterTests.swift; sourceTree = "<group>"; };
502F03141CA8FDCC0026119C /* FormatterKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FormatterKit.framework; path = "../../../Library/Developer/Xcode/DerivedData/FormatterKit-evcpsmwiwrimnmfbebdofilhkvkp/Build/Products/Debug-iphonesimulator/FormatterKit.framework"; sourceTree = "<group>"; };
504295131C683A9C00143D6F /* FormatterKit Example-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FormatterKit Example-Bridging-Header.h"; sourceTree = "<group>"; };
5044222E1CE7A188005E5721 /* ArrayFormatterTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArrayFormatterTests.swift; sourceTree = "<group>"; };
505136C11CCE1EF600569478 /* Tests-Russian.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Tests-Russian.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
505136C31CCE1EF600569478 /* TimeIntervalFormatterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimeIntervalFormatterTests.swift; sourceTree = "<group>"; };
50ACC1E01CD0B0DA004FB5F1 /* Tests-Arabic.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Tests-Arabic.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -925,6 +929,7 @@
isa = PBXGroup;
children = (
50E332861CD0A4FE0016EEDF /* TimeIntervalFormatterTests.swift */,
5044222E1CE7A188005E5721 /* ArrayFormatterTests.swift */,
);
name = "Chinese-Simplified";
path = "Tests-Chinese-Simplified";
Expand Down Expand Up @@ -961,6 +966,7 @@
isa = PBXGroup;
children = (
50F3E8BD1CCE144D00BC8526 /* TimeIntervalFormatterTests.swift */,
500C616A1CE79EE7002A1D96 /* ArrayFormatterTests.swift */,
);
name = English;
path = "Tests-English";
Expand Down Expand Up @@ -2327,6 +2333,7 @@
buildActionMask = 2147483647;
files = (
50E332871CD0A4FE0016EEDF /* TimeIntervalFormatterTests.swift in Sources */,
5044222F1CE7A188005E5721 /* ArrayFormatterTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -2359,6 +2366,7 @@
buildActionMask = 2147483647;
files = (
50F3E8BE1CCE144D00BC8526 /* TimeIntervalFormatterTests.swift in Sources */,
500C616B1CE79EE7002A1D96 /* ArrayFormatterTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
44 changes: 44 additions & 0 deletions Example/Tests-Chinese-Simplified/ArrayFormatterTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// ArrayFormatterTests.swift
// FormatterKit Example
//
// Created by Victor Ilyukevich on 5/14/16.
// Copyright © 2016. All rights reserved.
//

import XCTest
import FormatterKit

class ArrayFormatterTests: XCTestCase {

var formatter: TTTArrayFormatter!

let dogCatParrot = ["", "", "鹦鹉"]

override func setUp() {
super.setUp()
formatter = TTTArrayFormatter()
}

// MARK: Tests

func testDefault() {
let result = formatter.stringFromArray(dogCatParrot)
let expected = "狗、猫、及鹦鹉"

XCTAssertEqual(result, expected)
// TODO
// XCTAssertEqual(formatter.arrayFromString(expected) as! [String], dogCatParrot)
}

func testAbbreviatedConjunction() {
formatter.usesAbbreviatedConjunction = true

let result = formatter.stringFromArray(dogCatParrot)
let expected = "狗、猫、和鹦鹉"

XCTAssertEqual(result, expected)
// TODO
// XCTAssertEqual(formatter.arrayFromString(expected) as! [String], dogCatParrot)
}
}
57 changes: 57 additions & 0 deletions Example/Tests-English/ArrayFormatterTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
// ArrayFormatterTests.swift
// FormatterKit Example
//
// Created by Victor Ilyukevich on 5/14/16.
// Copyright © 2016. All rights reserved.
//

import XCTest
import FormatterKit

class ArrayFormatterTests: XCTestCase {

var formatter: TTTArrayFormatter!

let dogCatParrot = ["Dog", "Cat", "Parrot"]

override func setUp() {
super.setUp()
formatter = TTTArrayFormatter()
}

// MARK: Tests

func testDefault() {
let result = formatter.stringFromArray(dogCatParrot)
let expected = "Dog, Cat, and Parrot"

XCTAssertEqual(result, expected)
// TODO
// XCTAssertEqual(formatter.arrayFromString(expected) as! [String], dogCatParrot)
}

func testAbbreviatedConjunction() {
formatter.usesAbbreviatedConjunction = true

let result = formatter.stringFromArray(dogCatParrot)
let expected = "Dog, Cat, & Parrot"

XCTAssertEqual(result, expected)
// TODO
// XCTAssertEqual(formatter.arrayFromString(expected) as! [String], dogCatParrot)

}

func testWithoutOxformComma() {
formatter.usesSerialDelimiter = false

let result = formatter.stringFromArray(dogCatParrot)
let expected = "Dog, Cat and Parrot"

XCTAssertEqual(result, expected)
// TODO
// XCTAssertEqual(formatter.arrayFromString(expected) as! [String], dogCatParrot)
}

}

0 comments on commit 4bf02ad

Please sign in to comment.