Day 13 (#15)
Co-authored-by: Smaug123 <patrick+github@patrickstevens.co.uk> Reviewed-on: #15
This commit is contained in:
68
AdventOfCode2023.FSharp/Test/TestDay13.fs
Normal file
68
AdventOfCode2023.FSharp/Test/TestDay13.fs
Normal file
@@ -0,0 +1,68 @@
|
||||
namespace AdventOfCode2023.Test
|
||||
|
||||
open System
|
||||
|
||||
open AdventOfCode2023
|
||||
open NUnit.Framework
|
||||
open FsUnitTyped
|
||||
open System.IO
|
||||
|
||||
[<TestFixture>]
|
||||
module TestDay13 =
|
||||
|
||||
[<Test>]
|
||||
let ``rowToInt test`` () =
|
||||
Day13.rowToInt ("#.##..##.".AsSpan ()) |> shouldEqual 358ul
|
||||
|
||||
[<Test>]
|
||||
let ``colToInt test`` () =
|
||||
let s =
|
||||
"""#.##..##.
|
||||
..#.##.#.
|
||||
##......#
|
||||
##......#
|
||||
..#.##.#.
|
||||
..##..##.
|
||||
#.#.##.#.
|
||||
"""
|
||||
|
||||
Day13.colToInt (s.AsSpan ()) 9 0
|
||||
|> shouldEqual (List.sum [ 1 ; 8 ; 16 ; 64 ] |> uint32)
|
||||
|
||||
[<Test>]
|
||||
|
||||
let sample = Assembly.getEmbeddedResource typeof<Dummy>.Assembly "day13.txt"
|
||||
|
||||
[<Test>]
|
||||
let part1Sample () =
|
||||
sample |> Day13.part1 |> shouldEqual 405ul
|
||||
|
||||
[<Test>]
|
||||
let part2Sample () =
|
||||
sample |> Day13.part2 |> shouldEqual 400ul
|
||||
|
||||
[<Test>]
|
||||
let part1Actual () =
|
||||
let s =
|
||||
try
|
||||
File.ReadAllText (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day13.txt"))
|
||||
with
|
||||
| :? DirectoryNotFoundException
|
||||
| :? FileNotFoundException ->
|
||||
Assert.Inconclusive ()
|
||||
failwith "unreachable"
|
||||
|
||||
Day13.part1 s |> shouldEqual 30158ul
|
||||
|
||||
[<Test>]
|
||||
let part2Actual () =
|
||||
let s =
|
||||
try
|
||||
File.ReadAllText (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day13.txt"))
|
||||
with
|
||||
| :? DirectoryNotFoundException
|
||||
| :? FileNotFoundException ->
|
||||
Assert.Inconclusive ()
|
||||
failwith "unreachable"
|
||||
|
||||
Day13.part2 s |> shouldEqual 36474ul
|
Reference in New Issue
Block a user