]> git.unchartedbackwaters.co.uk Git - francis/ofc.git/commitdiff
Initial work on supporting a test suite.
authorFrancis Russell <francis@unchartedbackwaters.co.uk>
Mon, 7 Jan 2013 16:32:31 +0000 (16:32 +0000)
committerFrancis Russell <francis@unchartedbackwaters.co.uk>
Mon, 7 Jan 2013 16:32:31 +0000 (16:32 +0000)
ofc.cabal
tests/Main.hs [new file with mode: 0644]
tests/Tests/Spectral.hs [new file with mode: 0644]

index 9e91d8048040df6e74a5324d6a28726ff196c6b9..23ca948490c77f5a7c79174b5b59f9b5bbe6612f 100644 (file)
--- a/ofc.cabal
+++ b/ofc.cabal
@@ -22,3 +22,10 @@ Executable ofc
   Hs-Source-Dirs:    src
   GHC-Options:       -Wall
   Build-Depends:     base, ofc 
+
+Test-Suite ofc-tests
+  Type:             exitcode-stdio-1.0
+  Hs-Source-Dirs:   tests
+  GHC-Options:      -Wall
+  Main-Is:          Main.hs
+  Build-Depends:    base, HUnit, ofc
diff --git a/tests/Main.hs b/tests/Main.hs
new file mode 100644 (file)
index 0000000..93aacfb
--- /dev/null
@@ -0,0 +1,18 @@
+module Main where
+
+import System.Exit (exitFailure, exitSuccess)
+import Test.HUnit
+
+import qualified Tests.Spectral (tests)
+
+main :: IO ()
+main = do
+  results <- runTestTT tests
+  if (errors results + failures results) > 0
+    then exitFailure
+    else exitSuccess
+
+tests :: Test
+tests = TestList 
+  [ TestLabel "Spectral" Tests.Spectral.tests
+  ]
diff --git a/tests/Tests/Spectral.hs b/tests/Tests/Spectral.hs
new file mode 100644 (file)
index 0000000..7d8c27c
--- /dev/null
@@ -0,0 +1,14 @@
+module Tests.Spectral (tests) where
+
+import Test.HUnit
+
+import OFC.Spectral
+
+tests :: Test
+tests = TestList 
+  [ TestCase negateNullBand
+  ]
+
+negateNullBand :: Assertion
+negateNullBand = (isNullBand $ negateBand nullBand) @? 
+  "Negating the null band produced a non-null band."