Files
advent-of-code-2023/AdventOfCode2023.FSharp/Test/TestDay13.fs
patrick dc0aa1ce30
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/all-checks-complete Pipeline was successful
Day 13 (#15)
Co-authored-by: Smaug123 <patrick+github@patrickstevens.co.uk>
Reviewed-on: #15
2023-12-13 12:59:57 +00:00

69 lines
1.6 KiB
Forth

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