aboutsummaryrefslogtreecommitdiff
path: root/tests/importCSV_test.ml
blob: c5d017a3b5fb63705d7d0c807231aaa039b219e8 (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
open Test_migration

let assert_equal = Alcotest.(check int "")

let float_repr =
  "float_repr" >:: fun () ->
  let () =
    Alcotest.(check string)
      "Float repr" "3873921.620000"
      ImportDataTypes.Value.(to_string "C" (Float 3873921.62))
  in
  ()

let significant_zero =
  "leading 0" >:: fun () ->
  Alcotest.(check string)
    "00123" "=\"00123\""
    ImportDataTypes.Value.(to_string "C" (Content "00123"));
  Alcotest.(check string)
    "0.0123" "0.0123"
    ImportDataTypes.Value.(to_string "C" (Content "0.0123"));
  Alcotest.(check string)
    "00123 A" "00123 A"
    ImportDataTypes.Value.(to_string "C" (Content "00123 A"))

let test_suit =
  [
    ( "Column A" >:: fun () ->
      assert_equal 1 (ImportDataTypes.Path.column_of_string "A") );
    ( "Column a" >:: fun () ->
      assert_equal 1 (ImportDataTypes.Path.column_of_string "a") );
    ( "Column name" >:: fun () ->
      let () =
        for i = 1 to 1_000 do
          let column_name = ImportDataTypes.Path.column_to_string i in
          let column_index =
            ImportDataTypes.Path.column_of_string column_name
          in

          assert_equal i column_index
        done
      in
      () );
    float_repr;
    significant_zero;
  ]

let tests = "importCSV_test" >::: test_suit