]> gitweb @ CieloNegro.org - time-w3c.git/blobdiff - tests/FormatterTest.hs
more tests
[time-w3c.git] / tests / FormatterTest.hs
diff --git a/tests/FormatterTest.hs b/tests/FormatterTest.hs
new file mode 100644 (file)
index 0000000..fbe2fbc
--- /dev/null
@@ -0,0 +1,35 @@
+module FormatterTest
+    ( testData
+    )
+    where
+
+import Data.Time
+import Data.Time.W3C
+import Test.HUnit
+
+
+testData :: [Test]
+testData = [ format (W3CDateTime 2010 Nothing Nothing Nothing Nothing Nothing Nothing)
+             ~?=
+             "2010"
+
+           , format (W3CDateTime 2010 (Just 12) Nothing Nothing Nothing Nothing Nothing)
+             ~?=
+             "2010-12"
+
+           , format (W3CDateTime 2010 (Just 12) (Just 31) Nothing Nothing Nothing Nothing)
+             ~?=
+             "2010-12-31"
+
+           , format (W3CDateTime 2010 (Just 12) (Just 31) (Just 1) (Just 23) Nothing (Just utc))
+             ~?=
+             "2010-12-31T01:23Z"
+
+           , format (W3CDateTime 2010 (Just 12) (Just 31) (Just 1) (Just 23) (Just 45) (Just (hoursToTimeZone 9)))
+             ~?=
+             "2010-12-31T01:23:45+09:00"
+
+           , format (W3CDateTime 2010 (Just 12) (Just 31) (Just 1) (Just 23) (Just 45.666666) (Just (hoursToTimeZone 9)))
+             ~?=
+             "2010-12-31T01:23:45.666666+09:00"
+           ]