Sha256: 2ae08b3261d59fc479524c2ceefc247c33655d28de282ccee04f945089420e57

Contents?: true

Size: 1.68 KB

Versions: 325

Compression:

Stored size: 1.68 KB

Contents

import XCTest
@testable import LinkedList

class LinkedListTests: XCTestCase {

    func testPushPop() {
        let deque = Deque<Int>()
        deque.push(10)
        deque.push(20)
        XCTAssertEqual(20, deque.pop() ?? 0 )
        XCTAssertEqual(10, deque.pop() ?? 0 )
    }

    func testPushShift() {
        let deque = Deque<Int>()
        deque.push(10)
        deque.push(20)
        XCTAssertEqual(10, deque.shift() ?? 0 )
        XCTAssertEqual(20, deque.shift() ?? 0 )
    }

    func testUnshiftShift() {
        let deque = Deque<Int>()
        deque.unshift(10)
        deque.unshift(20)
        XCTAssertEqual(20, deque.shift() ?? 0 )
        XCTAssertEqual(10, deque.shift() ?? 0 )
    }

    func testUnshiftPop() {
        let deque = Deque<Int>()
        deque.unshift(10)
        deque.unshift(20)
        XCTAssertEqual(10, deque.pop() ?? 0 )
        XCTAssertEqual(20, deque.pop() ?? 0 )
    }

    func testExampleMethodLength() {
        let deque = Deque<Int>()
        deque.push(10)
        deque.push(20)
        XCTAssertEqual(20, deque.pop() ?? 0 )
        deque.push(30)
        XCTAssertEqual(10, deque.shift() ?? 0 )
        deque.unshift(40)
        deque.push(50)
        XCTAssertEqual(40, deque.shift() ?? 0 )
        XCTAssertEqual(50, deque.pop() ?? 0 )
        XCTAssertEqual(30, deque.shift() ?? 0 )
    }

    static var allTests: [(String, (LinkedListTests) -> () throws -> Void)] {
        return [
            ("testPushPop", testPushPop),
            ("testPushShift", testPushShift),
            ("testUnshiftShift", testUnshiftShift),
            ("testUnshiftPop", testUnshiftPop),
            ("testExampleMethodLength", testExampleMethodLength),
        ]
    }
}

Version data entries

325 entries across 325 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift
trackler-2.2.1.179 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift
trackler-2.2.1.178 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift
trackler-2.2.1.177 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift
trackler-2.2.1.176 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift
trackler-2.2.1.175 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift
trackler-2.2.1.174 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift
trackler-2.2.1.173 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift
trackler-2.2.1.172 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift
trackler-2.2.1.171 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift
trackler-2.2.1.170 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift
trackler-2.2.1.169 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift
trackler-2.2.1.167 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift
trackler-2.2.1.166 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift
trackler-2.2.1.165 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift
trackler-2.2.1.164 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift
trackler-2.2.1.163 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift
trackler-2.2.1.162 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift
trackler-2.2.1.161 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift
trackler-2.2.1.160 tracks/swift/exercises/linked-list/Tests/LinkedListTests/LinkedListTests.swift