Browse Source

Fix tests for id_parsing

 + Got exception due to negative argument passed to List.create.
 + One test had wrong assumption.
Leo 8 years ago
parent
commit
b7a0f67bbb
2 changed files with 2 additions and 2 deletions
  1. 1 1
      src/id_parsing.ml
  2. 1 1
      src/test/id_parsing_t.ml

+ 1 - 1
src/id_parsing.ml

@@ -75,7 +75,7 @@ let deinter = function
   | Unique a -> [Unique a]
   | Between (a,b) ->
     (* Note that (a-b+1) is the length of interval [a;b] *)
-    List.init (a-b+1) ~f:(fun i -> Unique (a + i))
+    List.init (abs(a-b)+1) ~f:(fun i -> Unique (a + i))
 ;;
 
 (* Transform string (separated) as follow:

+ 1 - 1
src/test/id_parsing_t.ml

@@ -50,7 +50,7 @@ let ll_data = [
   ( "1-3", [1;2;3], "Canonical case: between" );
   ( "1-3,5-8,10-12", [1;2;3;5;6;7;8;10;11;12], "Canonical case: list of interval" );
   ( "1,3,5", [1;3;5], "Canonical case: list of unique" );
-  ( "1-3,5,10-12,23", [1;2;3;10;11;12;23], "Canonical case: both" );
+  ( "1-3,5,10-12,23", [1;2;3;5;10;11;12;23], "Canonical case: both" );
   ( "0-30", [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 16; 17; 18;
   19; 20; 21; 22; 23; 24; 25; 26; 27; 28; 29; 30], "Long interval" );
   ( "1-3", [1;2;3], "With errors" );