aboutsummaryrefslogtreecommitdiff
path: root/specs/Specs/KeySequenceSpec.hs
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-12-14 11:46:48 +0530
committerAkshay Nair <phenax5@gmail.com>2024-12-14 11:54:06 +0530
commit7ab99bd80e30d0cc2cf21e4cda47870821b8fd47 (patch)
treec2fe30dcda461a34beaa740684d613083d144dd1 /specs/Specs/KeySequenceSpec.hs
parent80add34b15855932e9201d7426d9df01aa82c845 (diff)
downloadchelleport-7ab99bd80e30d0cc2cf21e4cda47870821b8fd47.tar.gz
chelleport-7ab99bd80e30d0cc2cf21e4cda47870821b8fd47.zip
Fix sequence generation for grid
Diffstat (limited to '')
-rw-r--r--specs/Specs/KeySequenceSpec.hs19
1 files changed, 18 insertions, 1 deletions
diff --git a/specs/Specs/KeySequenceSpec.hs b/specs/Specs/KeySequenceSpec.hs
index 8b820b4..570f1f9 100644
--- a/specs/Specs/KeySequenceSpec.hs
+++ b/specs/Specs/KeySequenceSpec.hs
@@ -1,6 +1,6 @@
module Specs.KeySequenceSpec where
-import Chelleport.KeySequence (nextChars)
+import Chelleport.KeySequence (generateKeyCells, nextChars)
import Test.Hspec
test = do
@@ -20,3 +20,20 @@ test = do
it "returns nothing" $ do
nextChars "FOO" [["XYZ", "ABC"], ["AMK", "BBL", "ABD"]]
`shouldBe` Nothing
+
+ describe "#generateKeyCells" $ do
+ it "generates grid of key sequences" $ do
+ generateKeyCells (4, 4) "ABCDEF"
+ `shouldBe` [ ["HKA", "HKB", "LKA", "LKB"],
+ ["HKC", "HKD", "LKC", "LKD"],
+ ["HJA", "HJB", "LJA", "LJB"],
+ ["HJC", "HJD", "LJC", "LJD"]
+ ]
+ context "when the the keys set is too short" $ do
+ it "cycles back to first character" $ do
+ generateKeyCells (4, 4) "AB"
+ `shouldBe` [ ["HKA", "HKB", "LKA", "LKB"],
+ ["HKA", "HKB", "LKA", "LKB"],
+ ["HJA", "HJB", "LJA", "LJB"],
+ ["HJA", "HJB", "LJA", "LJB"]
+ ]