aboutsummaryrefslogtreecommitdiff
path: root/motus/test
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2022-02-26 13:42:32 +0100
committerSébastien Dailly <sebastien@dailly.me>2022-02-26 15:19:51 +0100
commit84b8439aa90f1465d05dcba936a25eaf96f914a0 (patch)
treeeb50a0a305d14d8591acb51e5ab745dcdd3e1f88 /motus/test
parent4eff667b92ff7ef4c3542650509c03fb0de5cbce (diff)
Use the whole dictionnary when searching for a word for a faster exploration
Diffstat (limited to 'motus/test')
-rw-r--r--motus/test/entropy_tests.ml40
-rw-r--r--motus/test/motus_test.ml23
2 files changed, 44 insertions, 19 deletions
diff --git a/motus/test/entropy_tests.ml b/motus/test/entropy_tests.ml
new file mode 100644
index 0000000..675d5b5
--- /dev/null
+++ b/motus/test/entropy_tests.ml
@@ -0,0 +1,40 @@
+open StdLabels
+open OUnit2
+open Motus_lib
+
+let format_validity = function
+ | Validity.Wellplaced -> 'W'
+ | Validity.Misplaced -> 'M'
+ | Validity.Missing -> '_'
+
+
+let printer : Validity.t array option -> string = function
+ | None -> ""
+ | Some v ->
+ String.init (Array.length v) ~f:(fun i ->
+ format_validity @@ Array.get v i )
+
+
+let tests =
+ "entropy test suite"
+ >::: [ ( "Compare words 1"
+ >:: fun _ ->
+ let w = "Test" in
+
+ let ref = (w, Entropy.CharSet.of_seq (String.to_seq w)) in
+
+ assert_equal
+ ~printer
+ (Some Validity.[| Wellplaced; Wellplaced; Wellplaced; Wellplaced |])
+ (Entropy.compare_words "Test" ~ref) )
+ ; ( "Compare words 2"
+ >:: fun _ ->
+ let w = "ABC" in
+ let ref = (w, Entropy.CharSet.of_seq (String.to_seq w)) in
+ let result = Entropy.compare_words "DAC" ~ref in
+
+ assert_equal
+ ~printer
+ (Some Validity.[| Missing; Misplaced; Wellplaced |])
+ result )
+ ]
diff --git a/motus/test/motus_test.ml b/motus/test/motus_test.ml
index 0586ffe..717db21 100644
--- a/motus/test/motus_test.ml
+++ b/motus/test/motus_test.ml
@@ -1,8 +1,8 @@
-module Validity = Motus_lib.Validity
open StdLabels
open OUnit2
+open Motus_lib
-let tests =
+let validiy_tests =
"validity test suite"
>::: [ ( "Sequence of elements"
>:: fun _ ->
@@ -35,23 +35,8 @@ let tests =
in
assert_equal 243 count )
- ; ( "Compare words 1"
- >:: fun _ ->
- let w = "Test" in
-
- let ref = (w, Validity.CharSet.of_seq (String.to_seq w)) in
-
- assert_equal
- (Some Validity.[| Wellplaced; Wellplaced; Wellplaced; Wellplaced |])
- (Validity.compare_words "Test" ~ref) )
- ; ( "Compare words 2"
- >:: fun _ ->
- let w = "ABC" in
- let ref = (w, Validity.CharSet.of_seq (String.to_seq w)) in
- assert_equal
- (Some Validity.[| Missing; Misplaced; Wellplaced |])
- (Validity.compare_words "DAC" ~ref) )
]
-let _ = run_test_tt_main tests
+let _ =
+ run_test_tt_main ("main tests" >::: [ validiy_tests; Entropy_tests.tests ])