summaryrefslogtreecommitdiffstats
path: root/dependencies/pkg/mod/github.com/mattn/go-sqlite3@v1.14.16/sqlite3_opt_math_functions_test.go
blob: 6ff076b41b8bdc00919b462357539dc2b6db3427 (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
// +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)
		}
	}
}