mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Add extra tests for the code on this branch.
FossilOrigin-Name: b15bbb201a7727806b9fd6c02f2579b01e0e38155a8f9e24c5d6f487fe3e8b6c
This commit is contained in:
@ -37,6 +37,10 @@ proc test_literal {tn lit type val} {
|
||||
" [list $type $val]
|
||||
}
|
||||
|
||||
proc test_literal_error {tn lit unrec} {
|
||||
do_catchsql_test $tn "SELECT $lit" "1 {unrecognized token: \"$unrec\"}"
|
||||
}
|
||||
|
||||
|
||||
test_literal 1.0 45 integer 45
|
||||
test_literal 1.1 0xFF integer 255
|
||||
@ -62,9 +66,31 @@ test_literal 3.1 1_000 integer 1000
|
||||
test_literal 3.2 1.1_1 real 1.11
|
||||
test_literal 3.3 1_0.1_1 real 10.11
|
||||
test_literal 3.4 1e1_000 real Inf
|
||||
test_literal 3.5 123______456.7_8__9_ real 123456.789
|
||||
test_literal 3.5 12_3_456.7_8_9 real 123456.789
|
||||
test_literal 3.6 9_223_372_036_854_775_807 integer 9223372036854775807
|
||||
test_literal 3.7 9_223_372_036_854_775_808 real 9.22337203685478e+18
|
||||
test_literal 3.8 -9_223_372_036_854_775_808 integer -9223372036854775808
|
||||
|
||||
foreach {tn lit unrec} {
|
||||
0 123a456 123a456
|
||||
1 1_ 1_
|
||||
2 1_.4 1_
|
||||
3 1e_4 1e_4
|
||||
4 1_e4 1_e4
|
||||
5 1.4_e4 1.4_e4
|
||||
6 1.4e+_4 1.4e
|
||||
7 1.4e-_4 1.4e
|
||||
8 1.4e4_ 1.4e4_
|
||||
9 1.4_e4 1.4_e4
|
||||
10 1.4e_4 1.4e_4
|
||||
11 12__34 12__34
|
||||
12 1234_ 1234_
|
||||
13 12._34 12._34
|
||||
14 12_.34 12_
|
||||
15 12.34_ 12.34_
|
||||
16 1.0e1_______2 1.0e1_______2
|
||||
} {
|
||||
test_literal_error 4.$tn $lit $unrec
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
27
test/literal2.tcl
Normal file
27
test/literal2.tcl
Normal file
@ -0,0 +1,27 @@
|
||||
# 2018 May 19
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
source [file join [file dirname $argv0] pg_common.tcl]
|
||||
|
||||
#=========================================================================
|
||||
|
||||
|
||||
start_test literal2 "2024 Jan 23"
|
||||
|
||||
execsql_test 1.0 { SELECT 123_456 }
|
||||
errorsql_test 1.1 { SELECT 123__456 }
|
||||
|
||||
execsql_float_test 2.1 { SELECT 1.0e1_2 }
|
||||
|
||||
finish_test
|
||||
|
||||
|
48
test/literal2.test
Normal file
48
test/literal2.test
Normal file
@ -0,0 +1,48 @@
|
||||
# 2024 Jan 23
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
# This file implements regression tests for SQLite library.
|
||||
#
|
||||
|
||||
####################################################
|
||||
# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
|
||||
####################################################
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix literal2
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
SELECT 123_456
|
||||
} {123456}
|
||||
|
||||
# PG says ERROR: trailing junk after numeric literal at or near "123_"
|
||||
do_test 1.1 { catch { execsql {
|
||||
SELECT 123__456
|
||||
} } } 1
|
||||
|
||||
|
||||
do_test 2.1 {
|
||||
set myres {}
|
||||
foreach r [db eval {SELECT 1.0e1_2}] {
|
||||
lappend myres [format %.4f [set r]]
|
||||
}
|
||||
set res2 {1000000000000.0000}
|
||||
set i 0
|
||||
foreach r [set myres] r2 [set res2] {
|
||||
if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
|
||||
error "list element [set i] does not match: got=[set r] expected=[set r2]"
|
||||
}
|
||||
incr i
|
||||
}
|
||||
set {} {}
|
||||
} {}
|
||||
|
||||
finish_test
|
Reference in New Issue
Block a user