about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2020-05-25T15·21-0400
committerGriffin Smith <root@gws.fyi>2020-05-25T15·21-0400
commitdb6ea025818b2212725442a733ad02d4b5188d2a (patch)
treef04282ce40f8ca5584b17dd3c2ba29a1979e49b0 /test
parent2c86856ca7784483a7cdd438763b2693a297908a (diff)
Begin a broken-out NestedMap type
Begin breaking out a NestedMap data structure, which existed in both the
variables for the new template system and the structure that stored
messages.
Diffstat (limited to 'test')
-rw-r--r--test/Spec.hs4
-rw-r--r--test/Xanthous/Data/NestedMapSpec.hs20
2 files changed, 23 insertions, 1 deletions
diff --git a/test/Spec.hs b/test/Spec.hs
index afe81d028c77..b7004b4f8948 100644
--- a/test/Spec.hs
+++ b/test/Spec.hs
@@ -6,6 +6,7 @@ import qualified Xanthous.Data.EntityMapSpec
 import qualified Xanthous.Data.EntityMap.GraphicsSpec
 import qualified Xanthous.Data.LevelsSpec
 import qualified Xanthous.Data.EntitiesSpec
+import qualified Xanthous.Data.NestedMapSpec
 import qualified Xanthous.DataSpec
 import qualified Xanthous.Entities.RawsSpec
 import qualified Xanthous.GameSpec
@@ -27,8 +28,9 @@ test = testGroup "Xanthous"
   [ Xanthous.Data.EntityCharSpec.test
   , Xanthous.Data.EntityMapSpec.test
   , Xanthous.Data.EntityMap.GraphicsSpec.test
-  , Xanthous.Data.LevelsSpec.test
   , Xanthous.Data.EntitiesSpec.test
+  , Xanthous.Data.LevelsSpec.test
+  , Xanthous.Data.NestedMapSpec.test
   , Xanthous.Entities.RawsSpec.test
   , Xanthous.GameSpec.test
   , Xanthous.Generators.UtilSpec.test
diff --git a/test/Xanthous/Data/NestedMapSpec.hs b/test/Xanthous/Data/NestedMapSpec.hs
new file mode 100644
index 000000000000..acf7a67268f4
--- /dev/null
+++ b/test/Xanthous/Data/NestedMapSpec.hs
@@ -0,0 +1,20 @@
+--------------------------------------------------------------------------------
+module Xanthous.Data.NestedMapSpec (main, test) where
+--------------------------------------------------------------------------------
+import           Test.Prelude
+--------------------------------------------------------------------------------
+import           Test.QuickCheck.Instances.Semigroup ()
+--------------------------------------------------------------------------------
+import qualified Xanthous.Data.NestedMap as NM
+--------------------------------------------------------------------------------
+
+main :: IO ()
+main = defaultMain test
+
+test :: TestTree
+test = testGroup "Xanthous.Data.NestedMap"
+  [ testProperty "insert/lookup" $ \nm ks v ->
+      let nm' = NM.insert ks v nm
+      in counterexample ("inserted: " <> show nm')
+         $ NM.lookup @Map @Int @Int ks nm' === Just (NM.Val v)
+  ]