module Test.Week1 (week1) where

import Test.Tasty
import Test.Tasty.HUnit
import Week1

week1 :: TestTree
week1 = testGroup "Week 1 - Introduction to Haskell"
  [
    exercise1
  , exercise2
  , exercise3
  , exercise4
  ]

exercise1 =
  testGroup "Exercise 1 - toDigits" [
    testCase "Example 1" $
      toDigits 1234 @?= [1, 2, 3, 4]
  , testCase "Example 2" $
      toDigitsRev 1234 @?= [4, 3, 2, 1]
  , testCase "Example 3" $
      toDigits 0 @?= []
  , testCase "Example 4" $
       toDigits (-17) @?= []
  ]

exercise2 =
  testGroup "Exercise 2 - doubleEveryOther" [
    testCase "Example 1" $
      doubleEveryOther [8, 7, 6, 5] @?= [16, 7, 12, 5]
    , testCase "Example 2" $
      doubleEveryOther [1, 2, 3] @?= [1, 4, 3]
  ]

exercise3 =
  testGroup "Exercise 3 - sumDigits" [
    testCase "Example 1" $
      sumDigits [16, 7, 12, 5] @?= 22
  ]

exercise4 =
  testGroup "Exercise 4 - hanoi" [
    testCase "Example 1" $
      hanoi 2 "a" "b" "c" @?= [("a", "c"), ("a", "b"), ("c", "b")]
  ]

exercise5 =
  testGroup "Exercise 5 - hanoi4" [
    testCase "Example 1" $
      (length $ hanoi4 2 "a" "b" "c" "d") @?= 129
  ]
