diff options
| author | Akshay Nair <phenax5@gmail.com> | 2024-12-15 19:31:47 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2024-12-15 19:31:47 +0530 |
| commit | bee0febb5d98f0993a7a3bd175046f4fbf9c8eec (patch) | |
| tree | d40125ac28c8720a332ff585cbd733b3fceab3e3 /specs/Specs/KeySequenceSpec.hs | |
| parent | 60b4a0fafebfc0351b3d0a6be13474d0f76e284a (diff) | |
| download | chelleport-bee0febb5d98f0993a7a3bd175046f4fbf9c8eec.tar.gz chelleport-bee0febb5d98f0993a7a3bd175046f4fbf9c8eec.zip | |
Generate random key sequences with lcg
Diffstat (limited to '')
| -rw-r--r-- | specs/Specs/KeySequenceSpec.hs | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/specs/Specs/KeySequenceSpec.hs b/specs/Specs/KeySequenceSpec.hs index 707646d..2efbece 100644 --- a/specs/Specs/KeySequenceSpec.hs +++ b/specs/Specs/KeySequenceSpec.hs @@ -1,6 +1,7 @@ module Specs.KeySequenceSpec where -import Chelleport.KeySequence (findMatchPosition, generateKeyCells, nextChars) +import Chelleport.KeySequence (findMatchPosition, generateGrid, nextChars) +import qualified Debug.Trace as Debug import Test.Hspec test = do @@ -22,22 +23,15 @@ test = do nextChars "FOO" [["XYZ", "ABC"], ["AMK", "BBL", "ABD"]] `shouldBe` Nothing - describe "#generateKeyCells" $ do + describe "#generateGrid" $ 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"] - ] + generateGrid 0 (4, 4) "ABCDEF" + `shouldBe` Just [["AE", "BD", "CC", "BB"], ["AC", "FD", "EE", "EC"], ["FB", "EA", "DF", "DD"], ["CA", "DB", "CE", "BF"]] + 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"] - ] + generateGrid 0 (4, 4) "AB" + `shouldBe` Nothing describe "#findMatchPosition" $ do it "returns the position of the matching key sequence" $ do |
