forked from waynewbishop/bishop-algorithms-swift
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStructureTest.swift
More file actions
97 lines (60 loc) · 2.66 KB
/
StructureTest.swift
File metadata and controls
97 lines (60 loc) · 2.66 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//
// StructuresTest.swift
// SwiftStructures
//
// Created by Wayne Bishop on 9/17/14.
// Copyright (c) 2014 Arbutus Software Inc. All rights reserved.
//
import UIKit
import XCTest
class StructureTest: XCTestCase {
func testLLNode() {
var testNode: LLNode<Int> = LLNode<Int>()
XCTAssertNotNil(testNode, "instance not initialized..")
XCTAssertNil(testNode.key, "key not initialized..")
XCTAssertNil(testNode.next, "next node propety not initialized..")
XCTAssertNil(testNode.previous, "previous node propety not initialized..")
}
func testQNode() {
var testNode: QNode<Int> = QNode<Int>()
XCTAssertNotNil(testNode, "instance not initialized..")
XCTAssertNil(testNode.key, "key not initialized..")
XCTAssertNil(testNode.next, "next instance not initialized..")
}
func testVertex() {
var testVertex: Vertex = Vertex()
XCTAssertNotNil(testVertex, "instance not intialized..")
XCTAssertFalse(testVertex.visited, "visited property not intialized..")
//downcast to test for membership
var neigborList: AnyObject = testVertex.neighbors as AnyObject
if !(neigborList is Array<Edge>) {
XCTFail("neighborlist does not include array list of edges..")
}
}
func testEdge() {
var edgeTest: Edge = Edge()
XCTAssertNotNil(edgeTest, "instance not initialized..")
XCTAssertEqual(edgeTest.weight, 0, "edge weight not initialized..")
var testVertex: AnyObject = edgeTest.neighbor as AnyObject
if !(testVertex is Vertex) {
XCTFail("edge vertex not intialized..")
}
}
func testPath() {
var pathTest: Path = Path()
XCTAssertNotNil(pathTest, "instance not initialized..")
XCTAssertNil(pathTest.previous, "path previous property not initialized..")
XCTAssertNil(pathTest.total, "path total property not initialized..")
var testVertex: AnyObject = pathTest.destination as AnyObject
if !(testVertex is Vertex) {
XCTFail("destination vertex not intialized..")
}
}
func testAVLTree() {
var testTree: AVLTree<Int> = AVLTree<Int>()
XCTAssertNotNil(testTree, "instance not initialized..")
XCTAssertNil(testTree.key, "key property not initialized..")
XCTAssertNil(testTree.left, "left property not initialized..")
XCTAssertNil(testTree.right, "right property not initialized..")
}
}