SHARE
TWEET

Untitled

a guest Sep 18th, 2019 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (** [make_rl_tests name wiring top_letter input_pos expected_output]
  2.     constructs an OUnit test named [name] that asserts the quality of
  3.     [expected_output] with [map_r_to_l wiring top_letter input_pos]. *)
  4. let make_rl_tests
  5.     (name: string)
  6.     (wiring: string)
  7.     (top_letter:char)
  8.     (input_pos:int)
  9.     (expected_output : int) : test =
  10.   name >:: (fun _ ->
  11.       (* the [printer] tells OUnit how to convert the output to a string *)
  12.       assert_equal expected_output (map_r_to_l wiring top_letter input_pos)
  13.         ~printer:string_of_int)
  14.  
  15. let map_rl_tests = [
  16.   make_rl_tests "rl_0" "BDFHJLCPRTXVZNYEIWGAKMUSQO" 'O' 14 17;
  17.   make_rl_tests "rl_1" "EKMFLGDQVZNTOWYHXUSPAIBRCJ" 'A' 0 4;
  18.   make_rl_tests "rl_2" "EKMFLGDQVZNTOWYHXUSPAIBRCJ" 'B' 0 9;
  19.   make_rl_tests "rl_3" "BACDEFGHIJKLMNOPQRSTUVWXYZ" 'A' 0 1;
  20.   make_rl_tests "rl_4" "BACDEFGHIJKLMNOPQRSTUVWXYZ" 'B' 0 25;
  21.   make_rl_tests "rl_5" "BACDEFGHIJKLMNOPQRSTUVWXYZ" 'C' 0 0;
  22.   make_rl_tests "rl_6" "BDFHJLCPRTXVZNYEIWGAKMUSQO" 'P' 20 4;
  23. ]
  24.  
  25. (** [make_lr_tests name wiring top_letter input_pos expected_output]
  26.     constructs an OUnit test named [name] that asserts the quality of
  27.     [expected_output] with [map_l_to_r wiring top_letter input_pos]. *)
  28. let make_lr_tests
  29.     (name: string)
  30.     (wiring: string)
  31.     (top_letter:char)
  32.     (input_pos:int)
  33.     (expected_output : int) : test =
  34.   name >:: (fun _ ->
  35.       (* the [printer] tells OUnit how to convert the output to a string *)
  36.       assert_equal expected_output (map_l_to_r wiring top_letter input_pos)
  37.         ~printer:string_of_int)
  38.  
  39. let map_lr_tests = [
  40.   make_lr_tests "lr_0" "EKMFLGDQVZNTOWYHXUSPAIBRCJ" 'F' 10 14;
  41.   make_lr_tests "lr_1" "LPGSZMHAEOQKVXRFYBUTNICJDW" 'Z' 0 5;
  42.   make_lr_tests "lr_2" "SLVGBTFXJQOHEWIRZYAMKPCNDU" 'A' 8 14;
  43.   make_lr_tests "lr_3" "EKMFLGDQVZNTOWYHXUSPAIBRCJ" 'L' 24 14;
  44.   make_lr_tests "lr_4" "CIAGSNDRBYTPZFULVHEKOQXWJM" 'M' 15 22;
  45. ]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top