aboutsummaryrefslogtreecommitdiff
path: root/tests/sql_int.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2024-03-14 08:26:58 +0100
committerSébastien Dailly <sebastien@dailly.me>2024-03-14 08:26:58 +0100
commit6b377719c10d5ab3343fd5221f99a4a21008e25a (patch)
treea7c1e9a820d339a2f161af3e09cf9e3161286796 /tests/sql_int.ml
Initial commitmain
Diffstat (limited to 'tests/sql_int.ml')
-rw-r--r--tests/sql_int.ml26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/sql_int.ml b/tests/sql_int.ml
new file mode 100644
index 0000000..87b1086
--- /dev/null
+++ b/tests/sql_int.ml
@@ -0,0 +1,26 @@
+open OUnit2
+
+let printer = function
+ | Sqlite3.Data.INT t -> Int64.to_string t
+ | Sqlite3.Data.NONE -> "None"
+ | Sqlite3.Data.NULL -> "Null"
+ | Sqlite3.Data.FLOAT f -> Float.to_string f
+ | Sqlite3.Data.TEXT t | Sqlite3.Data.BLOB t -> t
+
+let test_suit =
+ [
+ ( "Int_of_int" >:: fun _ ->
+ assert_equal (Sqlite3.Data.INT 37354L)
+ (ImportSQL.Math.int (Sqlite3.Data.INT 37354L)) );
+ ( "Int_of_string" >:: fun _ ->
+ assert_equal (Sqlite3.Data.INT 37354L)
+ (ImportSQL.Math.int (Sqlite3.Data.TEXT "37354")) );
+ ( "Int_of_string2" >:: fun _ ->
+ assert_equal ~printer (Sqlite3.Data.INT 37354L)
+ (ImportSQL.Math.int (Sqlite3.Data.TEXT "37354.0")) );
+ ( "Int_of_float" >:: fun _ ->
+ assert_equal (Sqlite3.Data.INT 37354L)
+ (ImportSQL.Math.int (Sqlite3.Data.FLOAT 37354.0)) );
+ ]
+
+let tests = "sql_int" >::: test_suit