diff options
Diffstat (limited to 'tests')
| -rw-r--r--[-rwxr-xr-x] | tests/odf/odf_ExpressionParser_test.ml | 4 | ||||
| -rw-r--r-- | tests/selection_test.ml | 78 | ||||
| -rw-r--r--[-rwxr-xr-x] | tests/test.ml | 1 | 
3 files changed, 81 insertions, 2 deletions
| diff --git a/tests/odf/odf_ExpressionParser_test.ml b/tests/odf/odf_ExpressionParser_test.ml index 40dcbcd..d129e7b 100755..100644 --- a/tests/odf/odf_ExpressionParser_test.ml +++ b/tests/odf/odf_ExpressionParser_test.ml @@ -24,8 +24,8 @@ module Show = ScTypes.Expr.Eval(Show_expr.Show_Expr(Show_ref)(Show_type))  let _msg ~(expected:ScTypes.Expr.t) ~(result:ScTypes.Expr.t) =
      let b1 = UTF8.Buffer.create 16
      and b2 = UTF8.Buffer.create 16 in
 -    Show.eval expected () b1;
 -    Show.eval result () b2;
 +    Show.eval expected b1;
 +    Show.eval result b2;
      Printf.sprintf "Expected \n\t%s but got \n\t%s"
        (UTF8.raw_encode @@ UTF8.Buffer.contents b1)
 diff --git a/tests/selection_test.ml b/tests/selection_test.ml new file mode 100644 index 0000000..940abd7 --- /dev/null +++ b/tests/selection_test.ml @@ -0,0 +1,78 @@ +(*
 +This file is part of licht.
 +
 +licht is free software: you can redistribute it and/or modify
 +it under the terms of the GNU General Public License as published by
 +the Free Software Foundation, either version 3 of the License, or
 +(at your option) any later version.
 +
 +licht is distributed in the hope that it will be useful,
 +but WITHOUT ANY WARRANTY; without even the implied warranty of
 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +GNU General Public License for more details.
 +
 +You should have received a copy of the GNU General Public License
 +along with licht.  If not, see <http://www.gnu.org/licenses/>.
 +*)
 +
 +open OUnit2
 +module S = Selection
 +
 +(* Test if a single cell is selected with an axe *)
 +let test_selected_single axe1 axe2 env = begin
 +
 +  let selection = Selection.create (10, 10) in
 +
 +  assert_equal
 +    true
 +    (Selection.is_selected axe1 selection);
 +
 +  assert_equal
 +    false
 +    (Selection.is_selected axe2 selection);
 +end
 +
 +let test_selected_multiple axe1 axe2 env = begin
 +
 +  let selection = Selection.extends
 +    (Actions.Left 1)
 +    (Selection.create (10, 10)) in
 +
 +  assert_equal
 +    true
 +    (Selection.is_selected axe1 selection);
 +
 +  assert_equal
 +    false
 +    (Selection.is_selected axe2 selection);
 +end
 +
 +let test_extract_single env = begin
 +
 +  let selection = Selection.create (10, 10) in
 +
 +  assert_equal
 +    (10, 10)
 +    (Selection.extract selection);
 +end
 +let test_extract_multiple env = begin
 +
 +  let selection = Selection.extends
 +    (Actions.Left 1)
 +    (Selection.create (10, 10)) in
 +
 +  assert_equal
 +    (9, 10)
 +    (Selection.extract selection);
 +end
 +
 +let tests = "selection_test">::: [
 +  "test_selected1" >:: test_selected_single (S.Horizontal 10) (S.Horizontal 11);
 +  "test_selected2" >:: test_selected_single (S.Vertical 10)   (S.Vertical 11);
 +  "test_selected3" >:: test_selected_single (S.Cell (10, 10)) (S.Cell (11, 11));
 +  "test_selected4" >:: test_selected_multiple (S.Horizontal 10) (S.Horizontal 11);
 +  "test_selected5" >:: test_selected_multiple (S.Vertical 10)   (S.Vertical 11);
 +  "test_selected6" >:: test_selected_multiple (S.Cell (10, 10)) (S.Cell (11, 11));
 +  "test_extract1 " >:: test_extract_single;
 +  "test_extract2 " >:: test_extract_multiple;
 +]
 diff --git a/tests/test.ml b/tests/test.ml index a69c4a3..e0b006d 100755..100644 --- a/tests/test.ml +++ b/tests/test.ml @@ -26,6 +26,7 @@ let () =      Expression_test.tests;      Sheet_test.tests;      Odf_ExpressionParser_test.tests; +    Selection_test.tests;      Splay_test.tests;    ]    in OUnit2.run_test_tt_main tests | 
