{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
module Main where
import Test.Tasty
import Test.Tasty.HUnit
import qualified Data.NonEmptyList as NonEmptyList
import Data.PrintableText
main :: IO ()
main = defaultMain printableTextTest
printableTextTest :: TestTree
printableTextTest = testGroup "fromText conversions"
[ testCase "Empty String" $
Nothing @=? fromText ""
, testCase "All whitespaces" $
Nothing @=? fromText " \t\r\n"
, testCase "Valid string" $
Just " this is valid" @=? unPrintableText <$> fromText " this is valid"
]
nonEmptyListTest :: TestTree
nonEmptyListTest = testGroup "fromList conversions"
[ testCase "Empty List" $
Nothing @=? NonEmptyList.fromList ([] @Int)
, testCase "Single item" $
Just (5, []) @=? NonEmptyList.uncons <$> NonEmptyList.fromList [5]
, testCase "Several items" $
Just (5, [4,3]) @=? NonEmptyList.uncons <$> NonEmptyList.fromList [5,4,3]
]