Skip to content

Commit 2c9844f

Browse files
committed
[Test] Add StateTests & EventTests.
1 parent edc0f3e commit 2c9844f

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

SwiftState.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
1F24C72C19D068B900C2FDC7 /* SwiftState.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4872D5AC19B4211900F326B5 /* SwiftState.framework */; };
1414
1F27771E1BE68D1D00C57CC9 /* RouteMappingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F27771C1BE68C7F00C57CC9 /* RouteMappingTests.swift */; };
1515
1F27771F1BE68D1E00C57CC9 /* RouteMappingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F27771C1BE68C7F00C57CC9 /* RouteMappingTests.swift */; };
16+
1F4336AD1C17113F00E7C1AC /* StateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F4336AC1C17113F00E7C1AC /* StateTests.swift */; };
17+
1F4336AE1C17113F00E7C1AC /* StateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F4336AC1C17113F00E7C1AC /* StateTests.swift */; };
18+
1F4336B01C17115700E7C1AC /* EventTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F4336AF1C17115700E7C1AC /* EventTests.swift */; };
19+
1F4336B11C17115700E7C1AC /* EventTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F4336AF1C17115700E7C1AC /* EventTests.swift */; };
1620
1F532C541C12B5BC00D3813A /* Disposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F532C531C12B5BC00D3813A /* Disposable.swift */; };
1721
1F532C551C12B5BC00D3813A /* Disposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F532C531C12B5BC00D3813A /* Disposable.swift */; };
1822
1F532C571C12BBBB00D3813A /* _HandlerInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F532C561C12BBBB00D3813A /* _HandlerInfo.swift */; };
@@ -87,6 +91,8 @@
8791
1F198C5B19972320001C3700 /* QiitaTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QiitaTests.swift; sourceTree = "<group>"; };
8892
1F1F74C11C0A02E700675EAA /* HierarchicalMachineTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HierarchicalMachineTests.swift; sourceTree = "<group>"; };
8993
1F27771C1BE68C7F00C57CC9 /* RouteMappingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RouteMappingTests.swift; sourceTree = "<group>"; };
94+
1F4336AC1C17113F00E7C1AC /* StateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StateTests.swift; sourceTree = "<group>"; };
95+
1F4336AF1C17115700E7C1AC /* EventTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EventTests.swift; sourceTree = "<group>"; };
9096
1F532C531C12B5BC00D3813A /* Disposable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Disposable.swift; sourceTree = "<group>"; };
9197
1F532C561C12BBBB00D3813A /* _HandlerInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = _HandlerInfo.swift; sourceTree = "<group>"; };
9298
1F532C601C12D7BD00D3813A /* MiscTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MiscTests.swift; sourceTree = "<group>"; };
@@ -224,6 +230,8 @@
224230
4876510E1C0ECBEB005961AC /* MachineTests.swift */,
225231
1FA6202C199660CA00460108 /* StateMachineTests.swift */,
226232
1FA6202B199660CA00460108 /* StateMachineEventTests.swift */,
233+
1F4336AC1C17113F00E7C1AC /* StateTests.swift */,
234+
1F4336AF1C17115700E7C1AC /* EventTests.swift */,
227235
1FA6202F199660CA00460108 /* TransitionTests.swift */,
228236
1FA6202E199660CA00460108 /* TransitionChainTests.swift */,
229237
1FA6202D199660CA00460108 /* RouteTests.swift */,
@@ -461,13 +469,15 @@
461469
1FA62033199660CA00460108 /* RouteChainTests.swift in Sources */,
462470
1FA62030199660CA00460108 /* _TestCase.swift in Sources */,
463471
1F1F74C31C0A02EA00675EAA /* HierarchicalMachineTests.swift in Sources */,
472+
1F4336AD1C17113F00E7C1AC /* StateTests.swift in Sources */,
464473
1FA62036199660CA00460108 /* RouteTests.swift in Sources */,
465474
1F532C611C12D7BD00D3813A /* MiscTests.swift in Sources */,
466475
1FA62031199660CA00460108 /* BasicTests.swift in Sources */,
467476
1FA62034199660CA00460108 /* StateMachineEventTests.swift in Sources */,
468477
1FA62035199660CA00460108 /* StateMachineTests.swift in Sources */,
469478
1FA62037199660CA00460108 /* TransitionChainTests.swift in Sources */,
470479
1F27771E1BE68D1D00C57CC9 /* RouteMappingTests.swift in Sources */,
480+
1F4336B01C17115700E7C1AC /* EventTests.swift in Sources */,
471481
1FA62032199660CA00460108 /* MyState.swift in Sources */,
472482
);
473483
runOnlyForDeploymentPostprocessing = 0;
@@ -484,13 +494,15 @@
484494
4822F0A819D008E300F5F572 /* _TestCase.swift in Sources */,
485495
4822F0AA19D008E700F5F572 /* MyEvent.swift in Sources */,
486496
1F1F74C41C0A02EB00675EAA /* HierarchicalMachineTests.swift in Sources */,
497+
1F4336AE1C17113F00E7C1AC /* StateTests.swift in Sources */,
487498
4822F0AE19D008EB00F5F572 /* RouteChainTests.swift in Sources */,
488499
1F532C621C12D7BD00D3813A /* MiscTests.swift in Sources */,
489500
4822F0B019D008EB00F5F572 /* TransitionTests.swift in Sources */,
490501
4822F0A919D008E700F5F572 /* MyState.swift in Sources */,
491502
4822F0B219D008EB00F5F572 /* RouteTests.swift in Sources */,
492503
4822F0B119D008EB00F5F572 /* TransitionChainTests.swift in Sources */,
493504
1F27771F1BE68D1E00C57CC9 /* RouteMappingTests.swift in Sources */,
505+
1F4336B11C17115700E7C1AC /* EventTests.swift in Sources */,
494506
4822F0AD19D008EB00F5F572 /* StateMachineTests.swift in Sources */,
495507
);
496508
runOnlyForDeploymentPostprocessing = 0;

Tests/EventTests.swift

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//
2+
// EventTests.swift
3+
// SwiftState
4+
//
5+
// Created by Yasuhiro Inami on 2015-12-08.
6+
// Copyright © 2015 Yasuhiro Inami. All rights reserved.
7+
//
8+
9+
import SwiftState
10+
import XCTest
11+
12+
class EventTests: _TestCase
13+
{
14+
func testInit_event()
15+
{
16+
let event = Event<MyEvent>(rawValue: .Event0)
17+
XCTAssertTrue(event == .Event0)
18+
XCTAssertTrue(.Event0 == event)
19+
}
20+
21+
func testInit_nil()
22+
{
23+
let event = Event<MyEvent>(rawValue: nil)
24+
XCTAssertTrue(event == .Any)
25+
XCTAssertTrue(.Any == event)
26+
}
27+
28+
func testRawValue_event()
29+
{
30+
let event = Event<MyEvent>.Some(.Event0)
31+
XCTAssertTrue(event.rawValue == .Event0)
32+
}
33+
34+
func testRawValue_any()
35+
{
36+
let event = Event<MyEvent>.Any
37+
XCTAssertTrue(event.rawValue == nil)
38+
}
39+
}

Tests/StateTests.swift

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//
2+
// StateTests.swift
3+
// SwiftState
4+
//
5+
// Created by Yasuhiro Inami on 2015-12-08.
6+
// Copyright © 2015 Yasuhiro Inami. All rights reserved.
7+
//
8+
9+
import SwiftState
10+
import XCTest
11+
12+
class StateTests: _TestCase
13+
{
14+
func testInit_state()
15+
{
16+
let state = State<MyState>(rawValue: .State0)
17+
XCTAssertTrue(state == .State0)
18+
XCTAssertTrue(.State0 == state)
19+
}
20+
21+
func testInit_nil()
22+
{
23+
let state = State<MyState>(rawValue: nil)
24+
XCTAssertTrue(state == .Any)
25+
XCTAssertTrue(.Any == state)
26+
}
27+
28+
func testRawValue_state()
29+
{
30+
let state = State<MyState>.Some(.State0)
31+
XCTAssertTrue(state.rawValue == .State0)
32+
}
33+
34+
func testRawValue_any()
35+
{
36+
let state = State<MyState>.Any
37+
XCTAssertTrue(state.rawValue == nil)
38+
}
39+
}

0 commit comments

Comments
 (0)