Sha256: 2358ccd56799fb50a87166b98a9c2a16e46176fa8d5810bb406f07bb0eea6cee

Contents?: true

Size: 1.51 KB

Versions: 71

Compression:

Stored size: 1.51 KB

Contents

#if swift(>=3.0)
    import XCTest
#endif

class PalindromeProductsTest: XCTestCase {

    func testLargestPalindromeFromSingleDigitFactors() {
        let palindromes = PalindromeProducts(maxFactor: 9)
        let largest = palindromes.largest
        XCTAssertEqual(9, largest.value)
        XCTAssertTrue(Set([1, 9]) == Set(largest.factor) || Set([3, 3]) == Set(largest.factor) )
    }

    func testLargestPalindromeFromDoubleDigitFactors() {
        let palindromes = PalindromeProducts(maxFactor: 99, minFactor: 10)
        let largest = palindromes.largest
        XCTAssertEqual(9009, largest.value)
        XCTAssertEqual(Set([91, 99]), Set(largest.factor))
    }

    func testSmallestPalindromeFromDoubleDigitFactors() {
        let palindromes = PalindromeProducts(maxFactor: 99, minFactor: 10)
        let smallest = palindromes.smallest
        XCTAssertEqual(121, smallest.value)
        XCTAssertEqual(Set([11, 11]), Set(smallest.factor))
    }

    func testLargestPalindromeFromTripleDigitFactors() {
        let palindromes = PalindromeProducts(maxFactor: 999, minFactor: 100)
        let largest = palindromes.largest
        XCTAssertEqual(906_609, largest.value)
        XCTAssertEqual(Set([913, 993]), Set(largest.factor))
    }

    func testSmallestPalindromeFromTripleDigitFactors() {
        let palindromes = PalindromeProducts(maxFactor: 999, minFactor: 100)
        let smallest = palindromes.smallest
        XCTAssertEqual(10_201, smallest.value)
        XCTAssertEqual(Set([101, 101]), Set(smallest.factor))
    }

}

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
trackler-2.0.6.15 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift
trackler-2.0.6.14 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift
trackler-2.0.6.13 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift
trackler-2.0.6.12 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift
trackler-2.0.6.11 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift
trackler-2.0.6.10 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift
trackler-2.0.6.9 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift
trackler-2.0.6.8 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift
trackler-2.0.6.7 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift
trackler-2.0.6.6 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift
trackler-2.0.6.5 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift
trackler-2.0.6.4 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift
trackler-2.0.6.3 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift
trackler-2.0.6.2 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift
trackler-2.0.6.1 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift
trackler-2.0.6.0 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift
trackler-2.0.5.18 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift
trackler-2.0.5.17 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift
trackler-2.0.5.16 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift
trackler-2.0.5.15 tracks/swift/exercises/palindrome-products/PalindromeProductsTest.swift