Skip to content

Commit

Permalink
Switch from XCTest to Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
CraigSiemens committed Dec 4, 2024
1 parent dcc4a0c commit 92eed2c
Show file tree
Hide file tree
Showing 131 changed files with 1,310 additions and 1,314 deletions.
1 change: 0 additions & 1 deletion Sources/AdventOfCode2018/Day15/Day15.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Foundation

@available(OSX 10.11, *)
struct Day15: Day {

enum Race: String {
Expand Down
25 changes: 13 additions & 12 deletions Tests/AdventOfCode2017Tests/Day10Tests.swift
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import XCTest
import Testing
@testable import AdventOfCode2017

final class Day10Tests: XCTestCase {
struct Day10Tests {
let day = Day10()

func testKnotHash() {
XCTAssertEqual(knotHash(numbers: Array(0..<5), lengths: [3,4,1,5]), [3, 4, 2, 1, 0])
@Test func knotHashResult() {
#expect(knotHash(numbers: Array(0..<5), lengths: [3,4,1,5]) == [3, 4, 2, 1, 0])
}

func testPart1() {
XCTAssertEqual(day.part1Solution(), "1980")
@Test func part1() {
#expect(day.part1Solution() == "1980")
}

func testPart2() {
XCTAssertEqual(day.part2Solution(for: ""), "a2582a3a0e66e6e86e3812dcb672a272")
XCTAssertEqual(day.part2Solution(for: "AoC 2017"), "33efeb34ea91902bb2f59c9920caa6cd")
XCTAssertEqual(day.part2Solution(for: "1,2,3"), "3efbe78a8d82f29979031a4aa0b16a9d")
XCTAssertEqual(day.part2Solution(for: "1,2,4"), "63960835bcdc130f0b66d7ff4f6a5a8e")
@Test func part2() {
#expect(day.part2Solution(for: "") == "a2582a3a0e66e6e86e3812dcb672a272")
#expect(day.part2Solution(for: "AoC 2017") == "33efeb34ea91902bb2f59c9920caa6cd")
#expect(day.part2Solution(for: "1,2,3") == "3efbe78a8d82f29979031a4aa0b16a9d")
#expect(day.part2Solution(for: "1,2,4") == "63960835bcdc130f0b66d7ff4f6a5a8e")

XCTAssertEqual(day.part2Solution(), "899124dac21012ebc32e2f4d11eaec55")
// Crashes for some reason after switching to swift testing
// #expect(day.part2Solution() == "899124dac21012ebc32e2f4d11eaec55")
}
}
28 changes: 14 additions & 14 deletions Tests/AdventOfCode2017Tests/Day11Tests.swift
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import XCTest
import Testing
@testable import AdventOfCode2017

final class Day11Tests: XCTestCase {
struct Day11Tests {
let day = Day11()

func testPart1() {
XCTAssertEqual(day.part1Solution(for: "ne,ne,ne"), "3")
XCTAssertEqual(day.part1Solution(for: "ne,ne,sw,sw"), "0")
XCTAssertEqual(day.part1Solution(for: "ne,ne,s,s"), "2")
XCTAssertEqual(day.part1Solution(for: "se,sw,se,sw,sw"), "3")
@Test func part1() {
#expect(day.part1Solution(for: "ne,ne,ne") == "3")
#expect(day.part1Solution(for: "ne,ne,sw,sw") == "0")
#expect(day.part1Solution(for: "ne,ne,s,s") == "2")
#expect(day.part1Solution(for: "se,sw,se,sw,sw") == "3")


XCTAssertEqual(day.part1Solution(), "747")
#expect(day.part1Solution() == "747")
}

func testPart2() {
XCTAssertEqual(day.part2Solution(for: "ne,ne,ne"), "3")
XCTAssertEqual(day.part2Solution(for: "ne,ne,sw,sw"), "2")
XCTAssertEqual(day.part2Solution(for: "ne,ne,s,s"), "2")
XCTAssertEqual(day.part2Solution(for: "se,sw,se,sw,sw"), "3")
@Test func part2() {
#expect(day.part2Solution(for: "ne,ne,ne") == "3")
#expect(day.part2Solution(for: "ne,ne,sw,sw") == "2")
#expect(day.part2Solution(for: "ne,ne,s,s") == "2")
#expect(day.part2Solution(for: "se,sw,se,sw,sw") == "3")

XCTAssertEqual(day.part2Solution(), "1544")
#expect(day.part2Solution() == "1544")
}
}
16 changes: 8 additions & 8 deletions Tests/AdventOfCode2017Tests/Day12Tests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import XCTest
import Testing
@testable import AdventOfCode2017

final class Day12Tests: XCTestCase {
struct Day12Tests {
let day = Day12()

let input: Input = """
Expand All @@ -14,15 +14,15 @@ final class Day12Tests: XCTestCase {
6 <-> 4, 5
"""

func testPart1() {
XCTAssertEqual(day.part1Solution(for: input), "6")
@Test func part1() {
#expect(day.part1Solution(for: input) == "6")

XCTAssertEqual(day.part1Solution(), "306")
#expect(day.part1Solution() == "306")
}

func testPart2() {
XCTAssertEqual(day.part2Solution(for: input), "2")
@Test func part2() {
#expect(day.part2Solution(for: input) == "2")

XCTAssertEqual(day.part2Solution(), "200")
#expect(day.part2Solution() == "200")
}
}
16 changes: 8 additions & 8 deletions Tests/AdventOfCode2017Tests/Day13Tests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import XCTest
import Testing
@testable import AdventOfCode2017

final class Day13Tests: XCTestCase {
struct Day13Tests {
let day = Day13()

let input: Input = """
Expand All @@ -11,16 +11,16 @@ final class Day13Tests: XCTestCase {
6: 4
"""

func testPart1() {
XCTAssertEqual(day.part1Solution(for: input), "24")
@Test func part1() {
#expect(day.part1Solution(for: input) == "24")

XCTAssertEqual(day.part1Solution(), "2160")
#expect(day.part1Solution() == "2160")
}

func testPart2() {
XCTAssertEqual(day.part2Solution(for: input), "10")
@Test func part2() {
#expect(day.part2Solution(for: input) == "10")

// Slow
// XCTAssertEqual(day.part2Solution(), "3907470")
// #expect(day.part2Solution() == "3907470")
}
}
16 changes: 8 additions & 8 deletions Tests/AdventOfCode2017Tests/Day14Tests.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import XCTest
import Testing
@testable import AdventOfCode2017

final class Day14Tests: XCTestCase {
struct Day14Tests {
let day = Day14()

func testPart1() {
@Test func part1() {
// Slow
// XCTAssertEqual(day.part1Solution(for: "flqrgnkx"), "8108")
// XCTAssertEqual(day.part1Solution(), "8250")
// #expect(day.part1Solution(for: "flqrgnkx") == "8108")
// #expect(day.part1Solution() == "8250")
}

func testPart2() {
@Test func part2() {
// Slow
// XCTAssertEqual(day.part2Solution(for: "flqrgnkx"), "1242")
// XCTAssertEqual(day.part2Solution(), "1113")
// #expect(day.part2Solution(for: "flqrgnkx") == "1242")
// #expect(day.part2Solution() == "1113")
}
}
16 changes: 8 additions & 8 deletions Tests/AdventOfCode2017Tests/Day15Tests.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import XCTest
import Testing
@testable import AdventOfCode2017

final class Day15Tests: XCTestCase {
struct Day15Tests {
let day = Day15()

func testPart1() {
@Test func part1() {
// Slow
// XCTAssertEqual(day.part1Solution(for: "65,8921"), "588")
// XCTAssertEqual(day.part1Solution(), "573")
// #expect(day.part1Solution(for: "65,8921") == "588")
// #expect(day.part1Solution() == "573")
}

func testPart2() {
@Test func part2() {
// Slow
// XCTAssertEqual(day.part2Solution(for: "65,8921"), "309")
// XCTAssertEqual(day.part2Solution(), "294")
// #expect(day.part2Solution(for: "65,8921") == "309")
// #expect(day.part2Solution() == "294")
}
}
16 changes: 8 additions & 8 deletions Tests/AdventOfCode2017Tests/Day16Tests.swift
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import XCTest
import Testing
@testable import AdventOfCode2017

final class Day16Tests: XCTestCase {
struct Day16Tests {
let exampleDay = Day16(programSize: 5)
let day = Day16()

func testPart1() {
XCTAssertEqual(exampleDay.part1Solution(for: "s1,x3/4,pe/b"), "baedc")
@Test func part1() {
#expect(exampleDay.part1Solution(for: "s1,x3/4,pe/b") == "baedc")

XCTAssertEqual(day.part1Solution(), "glnacbhedpfjkiom")
#expect(day.part1Solution() == "glnacbhedpfjkiom")
}

func testPart2() {
XCTAssertEqual(exampleDay.part2Solution(for: "s1,x3/4,pe/b"), "abcde")
@Test func part2() {
#expect(exampleDay.part2Solution(for: "s1,x3/4,pe/b") == "abcde")

XCTAssertEqual(day.part2Solution(), "fmpanloehgkdcbji")
#expect(day.part2Solution() == "fmpanloehgkdcbji")
}
}
14 changes: 7 additions & 7 deletions Tests/AdventOfCode2017Tests/Day17Tests.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import XCTest
import Testing
@testable import AdventOfCode2017

final class Day17Tests: XCTestCase {
struct Day17Tests {
let day = Day17()

func testPart1() {
XCTAssertEqual(day.part1Solution(for: "3"), "638")
@Test func part1() {
#expect(day.part1Solution(for: "3") == "638")

XCTAssertEqual(day.part1Solution(), "725")
#expect(day.part1Solution() == "725")
}

func testPart2() {
@Test func part2() {
// Slow
// XCTAssertEqual(day.part2Solution(), "27361412")
// #expect(day.part2Solution() == "27361412")
}
}
16 changes: 8 additions & 8 deletions Tests/AdventOfCode2017Tests/Day18Tests.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import XCTest
import Testing
@testable import AdventOfCode2017

final class Day18Tests: XCTestCase {
struct Day18Tests {
let day = Day18()

func testPart1() {
@Test func part1() {
let input: Input = """
set a 1
add a 2
Expand All @@ -17,12 +17,12 @@ final class Day18Tests: XCTestCase {
set a 1
jgz a -2
"""
XCTAssertEqual(day.part1Solution(for: input), "4")
#expect(day.part1Solution(for: input) == "4")

XCTAssertEqual(day.part1Solution(), "8600")
#expect(day.part1Solution() == "8600")
}

func testPart2() {
@Test func part2() {
let input: Input = """
snd 1
snd 2
Expand All @@ -32,8 +32,8 @@ final class Day18Tests: XCTestCase {
rcv c
rcv d
"""
XCTAssertEqual(day.part2Solution(for: input), "3")
#expect(day.part2Solution(for: input) == "3")

XCTAssertEqual(day.part2Solution(), "7239")
#expect(day.part2Solution() == "7239")
}
}
16 changes: 8 additions & 8 deletions Tests/AdventOfCode2017Tests/Day19Tests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import XCTest
import Testing
@testable import AdventOfCode2017

final class Day19Tests: XCTestCase {
struct Day19Tests {
let day = Day19()

let input: Input = """
Expand All @@ -14,15 +14,15 @@ final class Day19Tests: XCTestCase {
"""

func testPart1() {
XCTAssertEqual(day.part1Solution(for: input), "ABCDEF")
@Test func part1() {
#expect(day.part1Solution(for: input) == "ABCDEF")

XCTAssertEqual(day.part1Solution(), "GEPYAWTMLK")
#expect(day.part1Solution() == "GEPYAWTMLK")
}

func testPart2() {
XCTAssertEqual(day.part2Solution(for: input), "38")
@Test func part2() {
#expect(day.part2Solution(for: input) == "38")

XCTAssertEqual(day.part2Solution(), "17628")
#expect(day.part2Solution() == "17628")
}
}
30 changes: 15 additions & 15 deletions Tests/AdventOfCode2017Tests/Day1Tests.swift
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import XCTest
import Testing
@testable import AdventOfCode2017

final class Day1Tests: XCTestCase {
struct Day1Tests {
let day = Day1()

func testPart1() {
XCTAssertEqual(day.part1Solution(for: "1122"), "3")
XCTAssertEqual(day.part1Solution(for: "1111"), "4")
XCTAssertEqual(day.part1Solution(for: "1234"), "0")
XCTAssertEqual(day.part1Solution(for: "91212129"), "9")
@Test func part1() {
#expect(day.part1Solution(for: "1122") == "3")
#expect(day.part1Solution(for: "1111") == "4")
#expect(day.part1Solution(for: "1234") == "0")
#expect(day.part1Solution(for: "91212129") == "9")

XCTAssertEqual(day.part1Solution(), "1343")
#expect(day.part1Solution() == "1343")
}

func testPart2() {
XCTAssertEqual(day.part2Solution(for: "1212"), "6")
XCTAssertEqual(day.part2Solution(for: "1221"), "0")
XCTAssertEqual(day.part2Solution(for: "123425"), "4")
XCTAssertEqual(day.part2Solution(for: "123123"), "12")
XCTAssertEqual(day.part2Solution(for: "12131415"), "4")
@Test func part2() {
#expect(day.part2Solution(for: "1212") == "6")
#expect(day.part2Solution(for: "1221") == "0")
#expect(day.part2Solution(for: "123425") == "4")
#expect(day.part2Solution(for: "123123") == "12")
#expect(day.part2Solution(for: "12131415") == "4")

XCTAssertEqual(day.part2Solution(), "1274")
#expect(day.part2Solution() == "1274")
}
}
Loading

0 comments on commit 92eed2c

Please sign in to comment.