emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/sqlite 1e4fe1c: Add some fixnum/bignum tests for sqlite.c


From: Lars Ingebrigtsen
Subject: scratch/sqlite 1e4fe1c: Add some fixnum/bignum tests for sqlite.c
Date: Mon, 6 Dec 2021 15:33:29 -0500 (EST)

branch: scratch/sqlite
commit 1e4fe1cec21d9e23625d857778930020eb762aaf
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Add some fixnum/bignum tests for sqlite.c
---
 src/sqlite.c             |  3 ++-
 test/src/sqlite-tests.el | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/sqlite.c b/src/sqlite.c
index 4719c04..8ab52c3 100644
--- a/src/sqlite.c
+++ b/src/sqlite.c
@@ -105,6 +105,7 @@ bind_values (sqlite3 *db, sqlite3_stmt *stmt, Lisp_Object 
values)
                                   NULL);
        }
       else if (EQ (type, Qinteger))
+       /* FIXME: Bignums? */
        ret = sqlite3_bind_int64 (stmt, i + 1, XFIXNUM (value));
       else if (EQ (type, Qfloat))
        ret = sqlite3_bind_double (stmt, i + 1, XFLOAT_DATA (value));
@@ -213,7 +214,7 @@ row_to_value (sqlite3_stmt *stmt)
       switch (sqlite3_column_type (stmt, i))
        {
        case SQLITE_INTEGER:
-         v = make_fixnum (sqlite3_column_int64 (stmt, i));
+         v = make_int (sqlite3_column_int64 (stmt, i));
          break;
 
        case SQLITE_FLOAT:
diff --git a/test/src/sqlite-tests.el b/test/src/sqlite-tests.el
index b6f2626..2a24625 100644
--- a/test/src/sqlite-tests.el
+++ b/test/src/sqlite-tests.el
@@ -105,4 +105,19 @@
      (equal (sqlite-select db "select * from test2")
             '(("col1" "col2") ("fóo" 3) ("fó‚o" 3) ("f‚o" 4))))))
 
+(ert-deftest sqlite-numbers ()
+  (skip-unless (sqlite-available-p))
+  (let (db)
+    (setq db (sqlite-open))
+    (sqlite-execute
+     db "create table if not exists test3 (col1 integer)")
+    (let ((big (expt 2 50))
+          (small (expt 2 10)))
+      (sqlite-execute db (format "insert into test3 values (%d)" small))
+      (sqlite-execute db (format "insert into test3 values (%d)" big))
+      (should
+       (equal
+        (cdr (sqlite-select db "select * from test3"))
+        (list (list small) (list big)))))))
+
 ;;; sqlite-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]