Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (** [make_rl_tests name wiring top_letter input_pos expected_output]
- constructs an OUnit test named [name] that asserts the quality of
- [expected_output] with [map_r_to_l wiring top_letter input_pos]. *)
- let make_rl_tests
- (name: string)
- (wiring: string)
- (top_letter:char)
- (input_pos:int)
- (expected_output : int) : test =
- name >:: (fun _ ->
- (* the [printer] tells OUnit how to convert the output to a string *)
- assert_equal expected_output (map_r_to_l wiring top_letter input_pos)
- ~printer:string_of_int)
- let map_rl_tests = [
- make_rl_tests "rl_0" "BDFHJLCPRTXVZNYEIWGAKMUSQO" 'O' 14 17;
- make_rl_tests "rl_1" "EKMFLGDQVZNTOWYHXUSPAIBRCJ" 'A' 0 4;
- make_rl_tests "rl_2" "EKMFLGDQVZNTOWYHXUSPAIBRCJ" 'B' 0 9;
- make_rl_tests "rl_3" "BACDEFGHIJKLMNOPQRSTUVWXYZ" 'A' 0 1;
- make_rl_tests "rl_4" "BACDEFGHIJKLMNOPQRSTUVWXYZ" 'B' 0 25;
- make_rl_tests "rl_5" "BACDEFGHIJKLMNOPQRSTUVWXYZ" 'C' 0 0;
- make_rl_tests "rl_6" "BDFHJLCPRTXVZNYEIWGAKMUSQO" 'P' 20 4;
- ]
- (** [make_lr_tests name wiring top_letter input_pos expected_output]
- constructs an OUnit test named [name] that asserts the quality of
- [expected_output] with [map_l_to_r wiring top_letter input_pos]. *)
- let make_lr_tests
- (name: string)
- (wiring: string)
- (top_letter:char)
- (input_pos:int)
- (expected_output : int) : test =
- name >:: (fun _ ->
- (* the [printer] tells OUnit how to convert the output to a string *)
- assert_equal expected_output (map_l_to_r wiring top_letter input_pos)
- ~printer:string_of_int)
- let map_lr_tests = [
- make_lr_tests "lr_0" "EKMFLGDQVZNTOWYHXUSPAIBRCJ" 'F' 10 14;
- make_lr_tests "lr_1" "LPGSZMHAEOQKVXRFYBUTNICJDW" 'Z' 0 5;
- make_lr_tests "lr_2" "SLVGBTFXJQOHEWIRZYAMKPCNDU" 'A' 8 14;
- make_lr_tests "lr_3" "EKMFLGDQVZNTOWYHXUSPAIBRCJ" 'L' 24 14;
- make_lr_tests "lr_4" "CIAGSNDRBYTPZFULVHEKOQXWJM" 'M' 15 22;
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement