on master help sign in
Clean up tests, add extra case
commit9f74dcd13639de2203834f1cc36c589b0ca0fd74 authorMatt Parsons <parsonsmatt@gmail.com> dateMon 12 Dec 2016, 14:30 (10 years ago) parentaebc5fa
1 file changed+6−18
tests/UnitTests.hs+6−18
tests/UnitTests.hs+6−18
@@ -99,10 +99,6 @@ tests = testGroup "unit" [
9999 testCase "good" $ utcTimeGood
100100 , testCase "bad" $ utcTimeBad
101101 ]
102− , testGroup "day" [
103− testCase "encode normal" $ dayEncodeCE
104− , testCase "encode BCE" $ dayEncodeBCE
105− ]
106102 , testGroup "formatError" [
107103 testCase "example 1" $ formatErrorExample
108104 ]
@@ -246,20 +242,6 @@ utcTimeBad = do
246242 let (dec :: Maybe UTCTime) = decode . LT.encodeUtf8 $ (LT.concat ["\"", s, "\""]) in
247243 assertEqual "verify failure" Nothing dec
248244
249−dayEncodeCE :: Assertion
250−dayEncodeCE = do
251− let ceDay = fromGregorian 1234 12 5
252− assertEqual "Encode a CE day works appropriately" (encode ceDay) "\"1234-12-05\""
253−
254−dayEncodeBCE :: Assertion
255−dayEncodeBCE = do
256− let zeroDay = fromGregorian 0 6 11
257− bceDay = fromGregorian (-100) 5 13
258− wayEarly = fromGregorian (-10000) 3 3
259− assertEqual "Encode a zero year day works appropriately" (encode zeroDay) "\"0000-06-11\""
260− assertEqual "Encode a BCE day works appropriately" (encode bceDay) "\"-0100-05-13\""
261− assertEqual "Encode a really early day works appropriately" (encode wayEarly) "\"-10000-03-03\""
262−
263245-- Non identifier keys should be escaped & enclosed in brackets
264246formatErrorExample :: Assertion
265247formatErrorExample =
@@ -410,6 +392,12 @@ jsonExamples =
410392 , Example "Maybe String" "\"foo\"" (pure "foo" :: Maybe String)
411393 , Example "Maybe [Identity Char]" "\"xy\"" (pure [pure 'x', pure 'y'] :: Maybe [Identity Char])
412394
395+ , Example "Day; year >= 1000" "\"1999-10-12\"" (fromGregorian 1999 10 12)
396+ , Example "Day; year > 0 && < 1000" "\"0500-03-04\"" (fromGregorian 500 3 4)
397+ , Example "Day; year == 0" "\"0000-02-20\"" (fromGregorian 0 2 20)
398+ , Example "Day; year < 0" "\"-0234-01-01\"" (fromGregorian (-234) 1 1)
399+ , Example "Day; year < -1000" "\"-1234-01-01\"" (fromGregorian (-1234) 1 1)
400+
413401 , Example "Product I Maybe Int" "[1,2]" (Pair (pure 1) (pure 2) :: Product I Maybe Int)
414402 , Example "Product I Maybe Int" "[1,null]" (Pair (pure 1) Nothing :: Product I Maybe Int)
415403 , Example "Product I [] Char" "[\"a\",\"foo\"]" (Pair (pure 'a') "foo" :: Product I [] Char)