|
| 1 | +/* |
| 2 | + This source file is part of the Swift.org open source project |
| 3 | + |
| 4 | + Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors |
| 5 | + Licensed under Apache License v2.0 with Runtime Library Exception |
| 6 | + |
| 7 | + See http://swift.org/LICENSE.txt for license information |
| 8 | + See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 9 | +*/ |
| 10 | + |
| 11 | +@testable import PlayingCard |
| 12 | +import XCTest |
| 13 | + |
| 14 | +class CardTests: XCTestCase { |
| 15 | + |
| 16 | + func testCardSingle() { |
| 17 | + let card1 = PlayingCard(rank: .queen, suit: .diamonds) |
| 18 | + let card2 = PlayingCard(rank: .king, suit: .diamonds) |
| 19 | + let card3 = PlayingCard(rank: .ace, suit: .clubs) |
| 20 | + let card4 = PlayingCard(rank: .queen, suit: .diamonds) |
| 21 | + let card5 = PlayingCard(rank: .queen, suit: .clubs) |
| 22 | + |
| 23 | + XCTAssertGreaterThan(card2, card1) |
| 24 | + XCTAssertGreaterThan(card3, card2) |
| 25 | + XCTAssertEqual(card1, card4) |
| 26 | + XCTAssertGreaterThan(card4, card5) |
| 27 | + } |
| 28 | + |
| 29 | + func testCardStringEquality() { |
| 30 | + let card1 = PlayingCard(rank: .jack, suit: .clubs) |
| 31 | + let card2 = PlayingCard(rank: .two, suit: .hearts) |
| 32 | + let card3 = PlayingCard(rank: .queen, suit: .diamonds) |
| 33 | + |
| 34 | + XCTAssertEqual(String(card1), "♣︎J") |
| 35 | + XCTAssertEqual(String(card2), "♡2") |
| 36 | + XCTAssertEqual(String(card3), "♢Q") |
| 37 | + } |
| 38 | + |
| 39 | +} |
0 commit comments