Permalink
Browse files

Add test for filling tiles

  • Loading branch information...
1 parent bc20582 commit 5886867218282f8f4f898e8d1a7191b202dd7179 @kfish committed Nov 22, 2011
Showing with 54 additions and 1 deletion.
  1. +40 −0 tests/Properties.hs
  2. +14 −1 texture-synthesis.cabal
View
@@ -0,0 +1,40 @@
+{-# OPTIONS -Wall #-}
+
+module Main (main) where
+
+import Test.Framework (Test, defaultMain, testGroup)
+import Test.Framework.Providers.QuickCheck2 (testProperty)
+
+import Graphics.TextureSynthesis
+
+----------------------------------------------------------------------
+
+-- | Check that a tile of depth n is fully filled.
+-- The size of tiles follows sequence A028400 (2^n + 1)^2
+fillTile :: Int -> Bool
+fillTile n = length (flattenTexture (n+1) (mkTexture n)) == square (2^n +1)
+ where
+ square x = x * x
+
+----------------------------------------------------------------------
+-- Test harness
+
+main :: IO ()
+main = defaultMain tests
+
+tests :: [Test]
+tests =
+ [ testGroup "fillTile"
+ [ testProperty "0" (fillTile 0)
+ , testProperty "1" (fillTile 1)
+ , testProperty "2" (fillTile 2)
+ , testProperty "3" (fillTile 3)
+ , testProperty "4" (fillTile 4)
+ , testProperty "5" (fillTile 5)
+ , testProperty "6" (fillTile 6)
+ , testProperty "7" (fillTile 7)
+ , testProperty "8" (fillTile 8)
+ , testProperty "9" (fillTile 9)
+ , testProperty "10" (fillTile 10)
+ ]
+ ]
View
@@ -55,4 +55,17 @@ Executable texture-synthesis
base < 3
Build-Depends:
- containers >= 0.2 && < 0.5
+ containers >= 0.2 && < 0.5,
+ parallel
+
+Test-suite tests
+ Type: exitcode-stdio-1.0
+ Hs-source-dirs: tests
+ Main-is: Properties.hs
+ Build-depends:
+ base >= 3 && < 6,
+ test-framework >= 0.3.3 && < 0.5,
+ test-framework-quickcheck2 >= 0.2.9 && < 0.3,
+ QuickCheck >= 2.4.0.1,
+ random == 1.0.*,
+ texture-synthesis

0 comments on commit 5886867

Please sign in to comment.