aboutsummaryrefslogtreecommitdiff
path: root/sqlite3_opt_math_functions_test.go
diff options
context:
space:
mode:
authorLevi Gruspe <mail.levig@gmail.com>2022-09-17 22:45:46 +0800
committerGitHub <noreply@github.com>2022-09-17 10:45:46 -0400
commit17f6553f94c44b68666ac44fb7c0713b707457cc (patch)
tree385a5c982183d641ca8060c85d000937d3153c8c /sqlite3_opt_math_functions_test.go
parentこんにちわ is wrong Japanse. The correct word is こんにちは (diff)
downloadgolite-17f6553f94c44b68666ac44fb7c0713b707457cc.tar.gz
golite-17f6553f94c44b68666ac44fb7c0713b707457cc.tar.xz
Add support for sqlite_math_functions tag (#1059)
Add support for SQLITE_ENABLE_MATH_FUNCTIONS compile-time option via the sqlite_math_functions build tag. Co-authored-by: Dominik Kraus <dominik.kraus@nktek.de>
Diffstat (limited to 'sqlite3_opt_math_functions_test.go')
-rw-r--r--sqlite3_opt_math_functions_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/sqlite3_opt_math_functions_test.go b/sqlite3_opt_math_functions_test.go
new file mode 100644
index 0000000..6ff076b
--- /dev/null
+++ b/sqlite3_opt_math_functions_test.go
@@ -0,0 +1,29 @@
+// +build sqlite_math_functions
+
+package sqlite3
+
+import (
+ "database/sql"
+ "testing"
+)
+
+func TestMathFunctions(t *testing.T) {
+ db, err := sql.Open("sqlite3", ":memory:")
+ if err != nil {
+ t.Fatal("Failed to open database:", err)
+ }
+ defer db.Close()
+
+ queries := []string{
+ `SELECT acos(1)`,
+ `SELECT log(10, 100)`,
+ `SELECT power(2, 2)`,
+ }
+
+ for _, query := range queries {
+ var result float64
+ if err := db.QueryRow(query).Scan(&result); err != nil {
+ t.Errorf("invoking math function query %q: %v", query, err)
+ }
+ }
+}