From: dan Date: Mon, 22 Jan 2024 19:00:50 +0000 (+0000) Subject: Add extra tests for the code on this branch. X-Git-Tag: version-3.46.0~190^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fbb72fae8ff79bdc1308f70c64a8093c9d605ce8;p=thirdparty%2Fsqlite.git Add extra tests for the code on this branch. FossilOrigin-Name: b15bbb201a7727806b9fd6c02f2579b01e0e38155a8f9e24c5d6f487fe3e8b6c --- diff --git a/manifest b/manifest index b43db80a8c..c1b974d23a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sallow\sdigit\sseparators\sthat\sare\snot\ssurrounded\son\sboth\ssides\sby\sdigits. -D 2024-01-22T17:18:41.963 +C Add\sextra\stests\sfor\sthe\scode\son\sthis\sbranch. +D 2024-01-22T19:00:50.821 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -800,7 +800,7 @@ F src/test_windirent.h da2e5b73c32d09905fbdd00f27cd802212a32a58ead882736fe4f5eb7 F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394ba3f F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c -F src/tokenize.c 1664cd0d9224bf63e7471d892074f580933c0e85a3b77f98e016dce2d5fed4a5 +F src/tokenize.c f283d8017b57d8be74218f6a820fb72f72ee7e05267083b4ac3b1ed456e0a290 F src/treeview.c c6fc972683fd00f975d8b32a81c1f25d2fb7d4035366bf45c9f5622d3ccd70ee F src/trigger.c 0905b96b04bb6658509f711a8207287f1315cdbc3df1a1b13ba6483c8e341c81 F src/update.c 6904814dd62a7a93bbb86d9f1419c7f134a9119582645854ab02b36b676d9f92 @@ -1355,7 +1355,9 @@ F test/like2.test d3be15fefee3e02fc88942a9b98f26c5339bbdef7783c90023c092c4955fe3 F test/like3.test a76e5938fadbe6d32807284c796bafd869974a961057bc5fc5a28e06de98745c F test/limit.test 350f5d03c29e7dff9a2cde016f84f8d368d40bcd02fa2b2a52fa10c4bf3cbfaf F test/limit2.test 9409b033284642a859fafc95f29a5a6a557bd57c1f0d7c3f554bd64ed69df77e -F test/literal.test db71a7616dc027badf8d8f7ac6e23e8655915eb51b187c40a0a6e667aed495b7 +F test/literal.test e3d65d4091126cb008f31f57a324364511a83dd9461df31f60b5df6bd1f1f846 +F test/literal2.tcl 10713fed76885d43ada4161c0edf18fdc06e4405094e7baad888c6a1a29141b9 +F test/literal2.test 2e3ad4bc8cb019169d4f43400658fdc35acdcde7f79322c952b61ca07ac27ba6 F test/loadext.test faa4f6eed07a5aac35d57fdd7bc07f8fc82464cfd327567c10cf0ba3c86cde04 F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7 F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db @@ -2159,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b57327be4be9638f5ee834a6c9e06135aaef9e499516f8b53f927ffe81033f61 -R dc78fe3596a95d4e421310d3dc095c60 -U drh -Z 8ae254187429ecb3341b495c0d5f92df +P 5bbc378a3022e2013048c8e296d95de21d15a8d7c1b62e8ffb64782f952cfe12 +R 5ae47ec02f1c44e5b63d2c7bab26a43e +U dan +Z 067422c390415b433adad2a7d339896e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 40427080bf..0b49600412 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5bbc378a3022e2013048c8e296d95de21d15a8d7c1b62e8ffb64782f952cfe12 \ No newline at end of file +b15bbb201a7727806b9fd6c02f2579b01e0e38155a8f9e24c5d6f487fe3e8b6c \ No newline at end of file diff --git a/src/tokenize.c b/src/tokenize.c index 37254da70d..7a30512ec6 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -477,8 +477,14 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ if( *tokenType==TK_INTEGER ) *tokenType = TK_FLOAT; for(i+=2; 1; i++){ if( sqlite3Isdigit(z[i])==0 ){ - if( z[i]==SQLITE_DIGIT_SEPARATOR ){ *tokenType = TK_QNUMBER; } - else{ break; } + if( z[i]==SQLITE_DIGIT_SEPARATOR + && sqlite3Isdigit(z[i-1]) + && sqlite3Isdigit(z[i+1]) + ){ + *tokenType = TK_QNUMBER; + }else{ + break; + } } } } diff --git a/test/literal.test b/test/literal.test index 3140eedf2a..fe6b70acf7 100644 --- a/test/literal.test +++ b/test/literal.test @@ -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 diff --git a/test/literal2.tcl b/test/literal2.tcl new file mode 100644 index 0000000000..2c97150b0c --- /dev/null +++ b/test/literal2.tcl @@ -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 + + diff --git a/test/literal2.test b/test/literal2.test new file mode 100644 index 0000000000..743df44eb7 --- /dev/null +++ b/test/literal2.test @@ -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