Fix a case where a corrupt stat4 record could go unrecognized due to integer overflow.
[sqlite.git] / test / literal2.test
blobed177ca261f9d93a783f1674c8cc31006b1a3d93
1 # 2024 Jan 23
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
6 #    May you do good and not evil.
7 #    May you find forgiveness for yourself and forgive others.
8 #    May you share freely, never taking more than you give.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.
14 ####################################################
15 # DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
16 ####################################################
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
20 set testprefix literal2
22 do_execsql_test 1.0 {
23   SELECT 123_456
24 } {123456}
26 # PG says ERROR:  trailing junk after numeric literal at or near "123_"
27 do_test 1.1 { catch { execsql {
28   SELECT 123__456
29 } } } 1
32 do_test 2.1 {
33   set myres {}
34   foreach r [db eval {SELECT 1.0e1_2}] {
35     lappend myres [format %.4f [set r]]
36   }
37   set res2 {1000000000000.0000}
38   set i 0
39   foreach r [set myres] r2 [set res2] {
40     if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
41       error "list element [set i] does not match: got=[set r] expected=[set r2]"
42     }
43     incr i
44   }
45   set {} {}
46 } {}
48 do_execsql_test 3.0.0 {
49   SELECT 0xFF_FF
50 } {65535}
52 do_execsql_test 3.0.1 {
53   SELECT 0xFF_EF
54 } {65519}
56 # PG says ERROR:  trailing junk after numeric literal at or near "0xFF_"
57 do_test 3.0.2 { catch { execsql {
58   SELECT 0xFF__EF
59 } } } 1
61 # PG says ERROR:  trailing junk after numeric literal at or near "0xFFEF_"
62 do_test 3.0.4 { catch { execsql {
63   SELECT 0xFFEF_
64 } } } 1
66 do_execsql_test 3.1.0 {
67   SELECT 0XFF_FF
68 } {65535}
70 do_execsql_test 3.1.1 {
71   SELECT 0XFF_EF
72 } {65519}
74 # PG says ERROR:  trailing junk after numeric literal at or near "0XFF_"
75 do_test 3.1.2 { catch { execsql {
76   SELECT 0XFF__EF
77 } } } 1
79 # PG says ERROR:  trailing junk after numeric literal at or near "0XFFEF_"
80 do_test 3.1.4 { catch { execsql {
81   SELECT 0XFFEF_
82 } } } 1
84 finish_test