SQLite

Check-in [5e1e9fd5e4]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add test cases for tointeger() and toreal() functions. Fixes for several tests.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | toTypeFuncs
Files: files | file ages | folders
SHA1: 5e1e9fd5e4f189836442baa42244be00de13ff0f
User & Date: mistachkin 2013-08-20 09:26:38.953
Context
2013-08-28
18:56
Merge updates from trunk. (check-in: ffc6e68283 user: mistachkin tags: toTypeFuncs)
2013-08-20
09:26
Add test cases for tointeger() and toreal() functions. Fixes for several tests. (check-in: 5e1e9fd5e4 user: mistachkin tags: toTypeFuncs)
02:07
Fix compiler warnings and boundary cases for the tointeger() and toreal() functions. (check-in: 4438b98658 user: drh tags: toTypeFuncs)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/func.c.
1024
1025
1026
1027
1028
1029
1030



1031

1032
1033
1034
1035
1036
1037
1038
  UNUSED_PARAMETER(argc);
  switch( sqlite3_value_type(argv[0]) ){
    case SQLITE_FLOAT: {
      sqlite3_result_double(context, sqlite3_value_double(argv[0]));
      break;
    }
    case SQLITE_INTEGER: {



      sqlite3_result_double(context, (double)sqlite3_value_int64(argv[0]));

      break;
    }
    case SQLITE_BLOB:
    case SQLITE_TEXT: {
      const unsigned char *zStr = sqlite3_value_text(argv[0]);
      if( zStr ){
        int nStr = sqlite3_value_bytes(argv[0]);







>
>
>
|
>







1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
  UNUSED_PARAMETER(argc);
  switch( sqlite3_value_type(argv[0]) ){
    case SQLITE_FLOAT: {
      sqlite3_result_double(context, sqlite3_value_double(argv[0]));
      break;
    }
    case SQLITE_INTEGER: {
      i64 iVal = sqlite3_value_int64(argv[0]);
      double rVal = (double)iVal;
      if( iVal==rVal ){
        sqlite3_result_double(context, rVal);
      }
      break;
    }
    case SQLITE_BLOB:
    case SQLITE_TEXT: {
      const unsigned char *zStr = sqlite3_value_text(argv[0]);
      if( zStr ){
        int nStr = sqlite3_value_bytes(argv[0]);
Changes to test/func4.test.
10
11
12
13
14
15
16


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#***********************************************************************
# This file implements regression tests for SQLite library. The
# focus of this file is testing the tointeger() and toreal()
# functions.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl



do_execsql_test func4-1.1 {
  SELECT tointeger(NULL);
} {{}}
do_execsql_test func4-1.2 {
  SELECT tointeger('');
} {{}}
do_execsql_test func4-1.3 {
  SELECT tointeger('   ');
} {{}}
do_execsql_test func4-1.4 {
  SELECT tointeger('1234');
} {1234}
do_execsql_test func4-1.5 {
  SELECT tointeger('   1234');
} {1234}
do_execsql_test func4-1.6 {
  SELECT tointeger('bad');
} {{}}
do_execsql_test func4-1.7 {
  SELECT tointeger('0xBAD');
} {{}}
do_execsql_test func4-1.8 {







>
>















|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#***********************************************************************
# This file implements regression tests for SQLite library. The
# focus of this file is testing the tointeger() and toreal()
# functions.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set saved_tcl_precision $tcl_precision
set tcl_precision 0

do_execsql_test func4-1.1 {
  SELECT tointeger(NULL);
} {{}}
do_execsql_test func4-1.2 {
  SELECT tointeger('');
} {{}}
do_execsql_test func4-1.3 {
  SELECT tointeger('   ');
} {{}}
do_execsql_test func4-1.4 {
  SELECT tointeger('1234');
} {1234}
do_execsql_test func4-1.5 {
  SELECT tointeger('   1234');
} {{}}
do_execsql_test func4-1.6 {
  SELECT tointeger('bad');
} {{}}
do_execsql_test func4-1.7 {
  SELECT tointeger('0xBAD');
} {{}}
do_execsql_test func4-1.8 {
87
88
89
90
91
92
93









94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129









130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147









148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
do_execsql_test func4-1.24 {
  SELECT tointeger(-9223372036854775808);
} {-9223372036854775808}
do_execsql_test func4-1.25 {
  SELECT tointeger(-9223372036854775808 + 1);
} {-9223372036854775807}
do_execsql_test func4-1.26 {









  SELECT tointeger(-2147483648 - 1);
} {-2147483649}
do_execsql_test func4-1.27 {
  SELECT tointeger(-2147483648);
} {-2147483648}
do_execsql_test func4-1.28 {
  SELECT tointeger(-2147483648 + 1);
} {-2147483647}
do_execsql_test func4-1.29 {
  SELECT tointeger(2147483647 - 1);
} {2147483646}
do_execsql_test func4-1.30 {
  SELECT tointeger(2147483647);
} {2147483647}
do_execsql_test func4-1.31 {
  SELECT tointeger(2147483647 + 1);
} {2147483648}
do_execsql_test func4-1.32 {
  SELECT tointeger(9223372036854775807 - 1);
} {9223372036854775806}
do_execsql_test func4-1.33 {
  SELECT tointeger(9223372036854775807);
} {9223372036854775807}
do_execsql_test func4-1.34 {
  SELECT tointeger(9223372036854775807 + 1);
} {{}}
do_execsql_test func4-1.35 {
  SELECT tointeger(1.79769313486232e308 - 1);
} {{}}
do_execsql_test func4-1.36 {
  SELECT tointeger(1.79769313486232e308);
} {{}}
do_execsql_test func4-1.37 {
  SELECT tointeger(1.79769313486232e308 + 1);
} {{}}
do_execsql_test func4-1.38 {









  SELECT tointeger(4503599627370496 - 1);
} {4503599627370495}
do_execsql_test func4-1.39 {
  SELECT tointeger(4503599627370496);
} {4503599627370496}
do_execsql_test func4-1.40 {
  SELECT tointeger(4503599627370496 + 1);
} {4503599627370497}
do_execsql_test func4-1.41 {
  SELECT tointeger(9007199254740992 - 1);
} {9007199254740991}
do_execsql_test func4-1.42 {
  SELECT tointeger(9007199254740992);
} {9007199254740992}
do_execsql_test func4-1.43 {
  SELECT tointeger(9007199254740992 + 1);
} {9007199254740993}
do_execsql_test func4-1.44 {









  SELECT tointeger(9223372036854775808 - 1);
} {{}}
do_execsql_test func4-1.45 {
  SELECT tointeger(9223372036854775808);
} {{}}
do_execsql_test func4-1.46 {
  SELECT tointeger(9223372036854775808 + 1);
} {{}}
do_execsql_test func4-1.47 {
  SELECT tointeger(18446744073709551616 - 1);
} {{}}
do_execsql_test func4-1.48 {
  SELECT tointeger(18446744073709551616);
} {{}}
do_execsql_test func4-1.49 {
  SELECT tointeger(18446744073709551616 + 1);
} {{}}

ifcapable floatingpoint {
  set i 0
  do_execsql_test func4-2.1 {
    SELECT toreal(NULL);
  } {{}}
  do_execsql_test func4-2.2 {
    SELECT toreal('');
  } {{}}
  do_execsql_test func4-2.3 {
    SELECT toreal('   ');
  } {{}}
  do_execsql_test func4-2.4 {
    SELECT toreal('1234');
  } {1234.0}
  do_execsql_test func4-2.5 {
    SELECT toreal('   1234');
  } {1234.0}
  do_execsql_test func4-2.6 {
    SELECT toreal('bad');
  } {{}}
  do_execsql_test func4-2.7 {
    SELECT toreal('0xBAD');
  } {{}}
  do_execsql_test func4-2.8 {







>
>
>
>
>
>
>
>
>


|


|


|


|


|


|


|


|

<
<
<
<
<
<
<
<
<


>
>
>
>
>
>
>
>
>


|


|


|


|


|


|
>
>
>
>
>
>
>
>
>


|


|


|


|


|




<














|







89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129









130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186

187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
do_execsql_test func4-1.24 {
  SELECT tointeger(-9223372036854775808);
} {-9223372036854775808}
do_execsql_test func4-1.25 {
  SELECT tointeger(-9223372036854775808 + 1);
} {-9223372036854775807}
do_execsql_test func4-1.26 {
  SELECT tointeger(-9223372036854775807 - 1);
} {-9223372036854775808}
do_execsql_test func4-1.27 {
  SELECT tointeger(-9223372036854775807);
} {-9223372036854775807}
do_execsql_test func4-1.28 {
  SELECT tointeger(-9223372036854775807 + 1);
} {-9223372036854775806}
do_execsql_test func4-1.29 {
  SELECT tointeger(-2147483648 - 1);
} {-2147483649}
do_execsql_test func4-1.30 {
  SELECT tointeger(-2147483648);
} {-2147483648}
do_execsql_test func4-1.31 {
  SELECT tointeger(-2147483648 + 1);
} {-2147483647}
do_execsql_test func4-1.32 {
  SELECT tointeger(2147483647 - 1);
} {2147483646}
do_execsql_test func4-1.33 {
  SELECT tointeger(2147483647);
} {2147483647}
do_execsql_test func4-1.34 {
  SELECT tointeger(2147483647 + 1);
} {2147483648}
do_execsql_test func4-1.35 {
  SELECT tointeger(9223372036854775807 - 1);
} {9223372036854775806}
do_execsql_test func4-1.36 {
  SELECT tointeger(9223372036854775807);
} {9223372036854775807}
do_execsql_test func4-1.37 {
  SELECT tointeger(9223372036854775807 + 1);









} {{}}
do_execsql_test func4-1.38 {
  SELECT tointeger(1.79769313486232e308 - 1);
} {{}}
do_execsql_test func4-1.39 {
  SELECT tointeger(1.79769313486232e308);
} {{}}
do_execsql_test func4-1.40 {
  SELECT tointeger(1.79769313486232e308 + 1);
} {{}}
do_execsql_test func4-1.41 {
  SELECT tointeger(4503599627370496 - 1);
} {4503599627370495}
do_execsql_test func4-1.42 {
  SELECT tointeger(4503599627370496);
} {4503599627370496}
do_execsql_test func4-1.43 {
  SELECT tointeger(4503599627370496 + 1);
} {4503599627370497}
do_execsql_test func4-1.44 {
  SELECT tointeger(9007199254740992 - 1);
} {9007199254740991}
do_execsql_test func4-1.45 {
  SELECT tointeger(9007199254740992);
} {9007199254740992}
do_execsql_test func4-1.46 {
  SELECT tointeger(9007199254740992 + 1);
} {9007199254740993}
do_execsql_test func4-1.47 {
  SELECT tointeger(9223372036854775807 - 1);
} {9223372036854775806}
do_execsql_test func4-1.48 {
  SELECT tointeger(9223372036854775807);
} {9223372036854775807}
do_execsql_test func4-1.49 {
  SELECT tointeger(9223372036854775807 + 1);
} {{}}
do_execsql_test func4-1.50 {
  SELECT tointeger(9223372036854775808 - 1);
} {{}}
do_execsql_test func4-1.51 {
  SELECT tointeger(9223372036854775808);
} {{}}
do_execsql_test func4-1.52 {
  SELECT tointeger(9223372036854775808 + 1);
} {{}}
do_execsql_test func4-1.53 {
  SELECT tointeger(18446744073709551616 - 1);
} {{}}
do_execsql_test func4-1.54 {
  SELECT tointeger(18446744073709551616);
} {{}}
do_execsql_test func4-1.55 {
  SELECT tointeger(18446744073709551616 + 1);
} {{}}

ifcapable floatingpoint {

  do_execsql_test func4-2.1 {
    SELECT toreal(NULL);
  } {{}}
  do_execsql_test func4-2.2 {
    SELECT toreal('');
  } {{}}
  do_execsql_test func4-2.3 {
    SELECT toreal('   ');
  } {{}}
  do_execsql_test func4-2.4 {
    SELECT toreal('1234');
  } {1234.0}
  do_execsql_test func4-2.5 {
    SELECT toreal('   1234');
  } {{}}
  do_execsql_test func4-2.6 {
    SELECT toreal('bad');
  } {{}}
  do_execsql_test func4-2.7 {
    SELECT toreal('0xBAD');
  } {{}}
  do_execsql_test func4-2.8 {
229
230
231
232
233
234
235
236
237
238
239
240
241



242
243






244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295



296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
    SELECT toreal(-1.79769313486232e308);
  } {-Inf}
  do_execsql_test func4-2.22 {
    SELECT toreal(-1.79769313486232e308 + 1);
  } {-Inf}
  do_execsql_test func4-2.23 {
    SELECT toreal(-9223372036854775808 - 1);
  } {-9.22337203685478e+18}
  do_execsql_test func4-2.24 {
    SELECT toreal(-9223372036854775808);
  } {-9.22337203685478e+18}
  do_execsql_test func4-2.25 {
    SELECT toreal(-9223372036854775808 + 1);



  } {-9.22337203685478e+18}
  do_execsql_test func4-2.26 {






    SELECT toreal(-2147483648 - 1);
  } {-2147483649.0}
  do_execsql_test func4-2.27 {
    SELECT toreal(-2147483648);
  } {-2147483648.0}
  do_execsql_test func4-2.28 {
    SELECT toreal(-2147483648 + 1);
  } {-2147483647.0}
  do_execsql_test func4-2.29 {
    SELECT toreal(2147483647 - 1);
  } {2147483646.0}
  do_execsql_test func4-2.30 {
    SELECT toreal(2147483647);
  } {2147483647.0}
  do_execsql_test func4-2.31 {
    SELECT toreal(2147483647 + 1);
  } {2147483648.0}
  do_execsql_test func4-2.32 {
    SELECT toreal(9223372036854775807 - 1);
  } {9.22337203685478e+18}
  do_execsql_test func4-2.33 {
    SELECT toreal(9223372036854775807);
  } {9.22337203685478e+18}
  do_execsql_test func4-2.34 {
    SELECT toreal(9223372036854775807 + 1);
  } {9.22337203685478e+18}
  do_execsql_test func4-2.35 {
    SELECT toreal(1.79769313486232e308 - 1);
  } {Inf}
  do_execsql_test func4-2.36 {
    SELECT toreal(1.79769313486232e308);
  } {Inf}
  do_execsql_test func4-2.37 {
    SELECT toreal(1.79769313486232e308 + 1);
  } {Inf}
  do_execsql_test func4-2.38 {
    SELECT toreal(4503599627370496 - 1);
  } {4503599627370500.0}
  do_execsql_test func4-2.39 {
    SELECT toreal(4503599627370496);
  } {4503599627370500.0}
  do_execsql_test func4-2.40 {
    SELECT toreal(4503599627370496 + 1);
  } {4503599627370500.0}
  do_execsql_test func4-2.41 {
    SELECT toreal(9007199254740992 - 1);
  } {9007199254740990.0}
  do_execsql_test func4-2.42 {
    SELECT toreal(9007199254740992);
  } {9007199254740990.0}
  do_execsql_test func4-2.43 {
    SELECT toreal(9007199254740992 + 1);



  } {9007199254740990.0}
  do_execsql_test func4-2.44 {
    SELECT toreal(9223372036854775808 - 1);
  } {9.22337203685478e+18}
  do_execsql_test func4-2.45 {
    SELECT toreal(9223372036854775808);
  } {9.22337203685478e+18}
  do_execsql_test func4-2.46 {
    SELECT toreal(9223372036854775808 + 1);
  } {9.22337203685478e+18}
  do_execsql_test func4-2.47 {
    SELECT toreal(18446744073709551616 - 1);
  } {1.84467440737096e+19}
  do_execsql_test func4-2.48 {
    SELECT toreal(18446744073709551616);
  } {1.84467440737096e+19}
  do_execsql_test func4-2.49 {
    SELECT toreal(18446744073709551616 + 1);
  } {1.84467440737096e+19}
}

ifcapable check {
  set i 0
  do_execsql_test func4-3.1 {
    CREATE TABLE t1(
      x INTEGER CHECK(tointeger(x) IS NOT NULL AND x = CAST(x AS INTEGER))
    );
  } {}
  do_test func4-3.2 {
    catchsql {
      INSERT INTO t1 (x) VALUES (NULL);
    }
  } {1 {constraint failed}}







|


|


>
>
>
|
|
>
>
>
>
>
>


|


|


|


|


|


|

|
|

|
|

|
|


|


|


|

|
|

|
|

|
|

|
|

|
|

>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|



<


|







248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348

349
350
351
352
353
354
355
356
357
358
    SELECT toreal(-1.79769313486232e308);
  } {-Inf}
  do_execsql_test func4-2.22 {
    SELECT toreal(-1.79769313486232e308 + 1);
  } {-Inf}
  do_execsql_test func4-2.23 {
    SELECT toreal(-9223372036854775808 - 1);
  } {-9.223372036854776e+18}
  do_execsql_test func4-2.24 {
    SELECT toreal(-9223372036854775808);
  } {-9.223372036854776e+18}
  do_execsql_test func4-2.25 {
    SELECT toreal(-9223372036854775808 + 1);
  } {{}}
  do_execsql_test func4-2.26 {
    SELECT toreal(-9223372036854775807 - 1);
  } {-9.223372036854776e+18}
  do_execsql_test func4-2.27 {
    SELECT toreal(-9223372036854775807);
  } {{}}
  do_execsql_test func4-2.28 {
    SELECT toreal(-9223372036854775807 + 1);
  } {{}}
  do_execsql_test func4-2.29 {
    SELECT toreal(-2147483648 - 1);
  } {-2147483649.0}
  do_execsql_test func4-2.30 {
    SELECT toreal(-2147483648);
  } {-2147483648.0}
  do_execsql_test func4-2.31 {
    SELECT toreal(-2147483648 + 1);
  } {-2147483647.0}
  do_execsql_test func4-2.32 {
    SELECT toreal(2147483647 - 1);
  } {2147483646.0}
  do_execsql_test func4-2.33 {
    SELECT toreal(2147483647);
  } {2147483647.0}
  do_execsql_test func4-2.34 {
    SELECT toreal(2147483647 + 1);
  } {2147483648.0}
  do_execsql_test func4-2.35 {
    SELECT toreal(9223372036854775807 - 1);
  } {{}}
  do_execsql_test func4-2.36 {
    SELECT toreal(9223372036854775807);
  } {{}}
  do_execsql_test func4-2.37 {
    SELECT toreal(9223372036854775807 + 1);
  } {9.223372036854776e+18}
  do_execsql_test func4-2.38 {
    SELECT toreal(1.79769313486232e308 - 1);
  } {Inf}
  do_execsql_test func4-2.39 {
    SELECT toreal(1.79769313486232e308);
  } {Inf}
  do_execsql_test func4-2.40 {
    SELECT toreal(1.79769313486232e308 + 1);
  } {Inf}
  do_execsql_test func4-2.41 {
    SELECT toreal(4503599627370496 - 1);
  } {4503599627370495.0}
  do_execsql_test func4-2.42 {
    SELECT toreal(4503599627370496);
  } {4503599627370496.0}
  do_execsql_test func4-2.43 {
    SELECT toreal(4503599627370496 + 1);
  } {4503599627370497.0}
  do_execsql_test func4-2.44 {
    SELECT toreal(9007199254740992 - 1);
  } {9007199254740991.0}
  do_execsql_test func4-2.45 {
    SELECT toreal(9007199254740992);
  } {9007199254740992.0}
  do_execsql_test func4-2.46 {
    SELECT toreal(9007199254740992 + 1);
  } {{}}
  do_execsql_test func4-2.47 {
    SELECT toreal(9007199254740992 + 2);
  } {9007199254740994.0}
  do_execsql_test func4-2.48 {
    SELECT toreal(tointeger(9223372036854775808) - 1);
  } {{}}
  do_execsql_test func4-2.49 {
    SELECT toreal(tointeger(9223372036854775808));
  } {{}}
  do_execsql_test func4-2.50 {
    SELECT toreal(tointeger(9223372036854775808) + 1);
  } {{}}
  do_execsql_test func4-2.51 {
    SELECT toreal(tointeger(18446744073709551616) - 1);
  } {{}}
  do_execsql_test func4-2.52 {
    SELECT toreal(tointeger(18446744073709551616));
  } {{}}
  do_execsql_test func4-2.53 {
    SELECT toreal(tointeger(18446744073709551616) + 1);
  } {{}}
}

ifcapable check {

  do_execsql_test func4-3.1 {
    CREATE TABLE t1(
      x INTEGER CHECK(tointeger(x) IS NOT NULL)
    );
  } {}
  do_test func4-3.2 {
    catchsql {
      INSERT INTO t1 (x) VALUES (NULL);
    }
  } {1 {constraint failed}}
387
388
389
390
391
392
393




















394
395
396
397
398
399
400
401
402
403
404
405
406
    }
  } {1 {constraint failed}}
  do_test func4-3.15 {
    catchsql {
      INSERT INTO t1 (x) VALUES (X'12345678');
    }
  } {1 {constraint failed}}




















  do_execsql_test func4-3.16 {
    SELECT x FROM t1 ORDER BY x;
  } {1234 1234}

  ifcapable floatingpoint {
    set i 0
    do_execsql_test func4-4.1 {
      CREATE TABLE t2(
        x REAL CHECK(toreal(x) IS NOT NULL)
      );
    } {}
    do_test func4-4.2 {
      catchsql {







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|

|


<







417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448

449
450
451
452
453
454
455
    }
  } {1 {constraint failed}}
  do_test func4-3.15 {
    catchsql {
      INSERT INTO t1 (x) VALUES (X'12345678');
    }
  } {1 {constraint failed}}
  do_test func4-3.16 {
    catchsql {
      INSERT INTO t1 (x) VALUES ('1234.00');
    }
  } {1 {constraint failed}}
  do_test func4-3.17 {
    catchsql {
      INSERT INTO t1 (x) VALUES (1234.00);
    }
  } {0 {}}
  do_test func4-3.18 {
    catchsql {
      INSERT INTO t1 (x) VALUES ('-9223372036854775809');
    }
  } {1 {constraint failed}}
  do_test func4-3.19 {
    catchsql {
      INSERT INTO t1 (x) VALUES (9223372036854775808);
    }
  } {1 {constraint failed}}
  do_execsql_test func4-3.20 {
    SELECT x FROM t1 ORDER BY x;
  } {1234 1234 1234}

  ifcapable floatingpoint {

    do_execsql_test func4-4.1 {
      CREATE TABLE t2(
        x REAL CHECK(toreal(x) IS NOT NULL)
      );
    } {}
    do_test func4-4.2 {
      catchsql {
474
475
476
477
478
479
480































































































481
    } {1 {constraint failed}}
    do_execsql_test func4-4.16 {
      SELECT x FROM t2 ORDER BY x;
    } {1234.0 1234.0 1234.56 1234.56}
  }
}
































































































finish_test







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
    } {1 {constraint failed}}
    do_execsql_test func4-4.16 {
      SELECT x FROM t2 ORDER BY x;
    } {1234.0 1234.0 1234.56 1234.56}
  }
}

ifcapable floatingpoint {
  do_execsql_test func4-5.1 {
    SELECT tointeger(toreal('1234'));
  } {1234}
  do_execsql_test func4-5.2 {
    SELECT tointeger(toreal(-1));
  } {-1}
  do_execsql_test func4-5.3 {
    SELECT tointeger(toreal(-0));
  } {0}
  do_execsql_test func4-5.4 {
    SELECT tointeger(toreal(0));
  } {0}
  do_execsql_test func4-5.5 {
    SELECT tointeger(toreal(1));
  } {1}
  do_execsql_test func4-5.6 {
    SELECT tointeger(toreal(-9223372036854775808 - 1));
  } {-9223372036854775808}
  do_execsql_test func4-5.7 {
    SELECT tointeger(toreal(-9223372036854775808));
  } {-9223372036854775808}
  do_execsql_test func4-5.8 {
    SELECT tointeger(toreal(-9223372036854775808 + 1));
  } {{}}
  do_execsql_test func4-5.9 {
    SELECT tointeger(toreal(-2147483648 - 1));
  } {-2147483649}
  do_execsql_test func4-5.10 {
    SELECT tointeger(toreal(-2147483648));
  } {-2147483648}
  do_execsql_test func4-5.11 {
    SELECT tointeger(toreal(-2147483648 + 1));
  } {-2147483647}
  do_execsql_test func4-5.12 {
    SELECT tointeger(toreal(2147483647 - 1));
  } {2147483646}
  do_execsql_test func4-5.13 {
    SELECT tointeger(toreal(2147483647));
  } {2147483647}
  do_execsql_test func4-5.14 {
    SELECT tointeger(toreal(2147483647 + 1));
  } {2147483648}
  do_execsql_test func4-5.15 {
    SELECT tointeger(toreal(9223372036854775807 - 1));
  } {{}}
  do_execsql_test func4-5.16 {
    SELECT tointeger(toreal(9223372036854775807));
  } {{}}
  do_execsql_test func4-5.17 {
    SELECT tointeger(toreal(9223372036854775807 + 1));
  } {{}}
  do_execsql_test func4-5.18 {
    SELECT tointeger(toreal(4503599627370496 - 1));
  } {4503599627370495}
  do_execsql_test func4-5.19 {
    SELECT tointeger(toreal(4503599627370496));
  } {4503599627370496}
  do_execsql_test func4-5.20 {
    SELECT tointeger(toreal(4503599627370496 + 1));
  } {4503599627370497}
  do_execsql_test func4-5.21 {
    SELECT tointeger(toreal(9007199254740992 - 1));
  } {9007199254740991}
  do_execsql_test func4-5.22 {
    SELECT tointeger(toreal(9007199254740992));
  } {9007199254740992}
  do_execsql_test func4-5.23 {
    SELECT tointeger(toreal(9007199254740992 + 1));
  } {{}}
  do_execsql_test func4-5.24 {
    SELECT tointeger(toreal(9007199254740992 + 2));
  } {9007199254740994}
  do_execsql_test func4-5.25 {
    SELECT tointeger(toreal(9223372036854775808 - 1));
  } {{}}
  do_execsql_test func4-5.26 {
    SELECT tointeger(toreal(9223372036854775808));
  } {{}}
  do_execsql_test func4-5.27 {
    SELECT tointeger(toreal(9223372036854775808 + 1));
  } {{}}
  do_execsql_test func4-5.28 {
    SELECT tointeger(toreal(18446744073709551616 - 1));
  } {{}}
  do_execsql_test func4-5.29 {
    SELECT tointeger(toreal(18446744073709551616));
  } {{}}
  do_execsql_test func4-5.30 {
    SELECT tointeger(toreal(18446744073709551616 + 1));
  } {{}}
}

set tcl_precision $saved_tcl_precision
unset saved_tcl_precision
finish_test