github.com/jdgcs/sqlite3@v1.12.1-0.20210908114423-bc5f96e4dd51/testdata/tcl/func4.test (about) 1 # 2013 March 10 2 # 3 # The author disclaims copyright to this source code. In place of 4 # a legal notice, here is a blessing: 5 # 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. 9 # 10 #*********************************************************************** 11 # This file implements regression tests for SQLite library. The focus of 12 # this file is testing the tointeger() and toreal() functions. 13 # 14 # Several of the toreal() tests are disabled on platforms where floating 15 # point precision is not high enough to represent their constant integer 16 # expression arguments as double precision floating point values. 17 # 18 set testdir [file dirname $argv0] 19 source $testdir/tester.tcl 20 set saved_tcl_precision $tcl_precision 21 set tcl_precision 0 22 load_static_extension db totype 23 24 set highPrecision(1) [expr \ 25 {[db eval {SELECT tointeger(9223372036854775807 + 1);}] eq {{}}}] 26 27 do_execsql_test func4-1.1 { 28 SELECT tointeger(NULL); 29 } {{}} 30 do_execsql_test func4-1.2 { 31 SELECT tointeger(''); 32 } {{}} 33 do_execsql_test func4-1.3 { 34 SELECT tointeger(' '); 35 } {{}} 36 do_execsql_test func4-1.4 { 37 SELECT tointeger('1234'); 38 } {1234} 39 do_execsql_test func4-1.5 { 40 SELECT tointeger(' 1234'); 41 } {{}} 42 do_execsql_test func4-1.6 { 43 SELECT tointeger('bad'); 44 } {{}} 45 do_execsql_test func4-1.7 { 46 SELECT tointeger('0xBAD'); 47 } {{}} 48 do_execsql_test func4-1.8 { 49 SELECT tointeger('123BAD'); 50 } {{}} 51 do_execsql_test func4-1.9 { 52 SELECT tointeger('0x123BAD'); 53 } {{}} 54 do_execsql_test func4-1.10 { 55 SELECT tointeger('123NO'); 56 } {{}} 57 do_execsql_test func4-1.11 { 58 SELECT tointeger('0x123NO'); 59 } {{}} 60 do_execsql_test func4-1.12 { 61 SELECT tointeger('-0x1'); 62 } {{}} 63 do_execsql_test func4-1.13 { 64 SELECT tointeger('-0x0'); 65 } {{}} 66 do_execsql_test func4-1.14 { 67 SELECT tointeger('0x0'); 68 } {{}} 69 do_execsql_test func4-1.15 { 70 SELECT tointeger('0x1'); 71 } {{}} 72 do_execsql_test func4-1.16 { 73 SELECT tointeger(-1); 74 } {-1} 75 do_execsql_test func4-1.17 { 76 SELECT tointeger(-0); 77 } {0} 78 do_execsql_test func4-1.18 { 79 SELECT tointeger(0); 80 } {0} 81 do_execsql_test func4-1.19 { 82 SELECT tointeger(1); 83 } {1} 84 do_execsql_test func4-1.20 { 85 SELECT tointeger(-1.79769313486232e308 - 1); 86 } {{}} 87 do_execsql_test func4-1.21 { 88 SELECT tointeger(-1.79769313486232e308); 89 } {{}} 90 do_execsql_test func4-1.22 { 91 SELECT tointeger(-1.79769313486232e308 + 1); 92 } {{}} 93 do_execsql_test func4-1.23 { 94 SELECT tointeger(-9223372036854775808 - 1); 95 } {-9223372036854775808} 96 do_execsql_test func4-1.24 { 97 SELECT tointeger(-9223372036854775808); 98 } {-9223372036854775808} 99 do_execsql_test func4-1.25 { 100 SELECT tointeger(-9223372036854775808 + 1); 101 } {-9223372036854775807} 102 do_execsql_test func4-1.26 { 103 SELECT tointeger(-9223372036854775807 - 1); 104 } {-9223372036854775808} 105 do_execsql_test func4-1.27 { 106 SELECT tointeger(-9223372036854775807); 107 } {-9223372036854775807} 108 do_execsql_test func4-1.28 { 109 SELECT tointeger(-9223372036854775807 + 1); 110 } {-9223372036854775806} 111 do_execsql_test func4-1.29 { 112 SELECT tointeger(-2147483648 - 1); 113 } {-2147483649} 114 do_execsql_test func4-1.30 { 115 SELECT tointeger(-2147483648); 116 } {-2147483648} 117 do_execsql_test func4-1.31 { 118 SELECT tointeger(-2147483648 + 1); 119 } {-2147483647} 120 do_execsql_test func4-1.32 { 121 SELECT tointeger(2147483647 - 1); 122 } {2147483646} 123 do_execsql_test func4-1.33 { 124 SELECT tointeger(2147483647); 125 } {2147483647} 126 do_execsql_test func4-1.34 { 127 SELECT tointeger(2147483647 + 1); 128 } {2147483648} 129 do_execsql_test func4-1.35 { 130 SELECT tointeger(9223372036854775807 - 1); 131 } {9223372036854775806} 132 do_execsql_test func4-1.36 { 133 SELECT tointeger(9223372036854775807); 134 } {9223372036854775807} 135 if {$highPrecision(1)} { 136 do_execsql_test func4-1.37 { 137 SELECT tointeger(9223372036854775807 + 1); 138 } {{}} 139 } 140 do_execsql_test func4-1.38 { 141 SELECT tointeger(1.79769313486232e308 - 1); 142 } {{}} 143 do_execsql_test func4-1.39 { 144 SELECT tointeger(1.79769313486232e308); 145 } {{}} 146 do_execsql_test func4-1.40 { 147 SELECT tointeger(1.79769313486232e308 + 1); 148 } {{}} 149 do_execsql_test func4-1.41 { 150 SELECT tointeger(4503599627370496 - 1); 151 } {4503599627370495} 152 do_execsql_test func4-1.42 { 153 SELECT tointeger(4503599627370496); 154 } {4503599627370496} 155 do_execsql_test func4-1.43 { 156 SELECT tointeger(4503599627370496 + 1); 157 } {4503599627370497} 158 do_execsql_test func4-1.44 { 159 SELECT tointeger(9007199254740992 - 1); 160 } {9007199254740991} 161 do_execsql_test func4-1.45 { 162 SELECT tointeger(9007199254740992); 163 } {9007199254740992} 164 do_execsql_test func4-1.46 { 165 SELECT tointeger(9007199254740992 + 1); 166 } {9007199254740993} 167 do_execsql_test func4-1.47 { 168 SELECT tointeger(9223372036854775807 - 1); 169 } {9223372036854775806} 170 do_execsql_test func4-1.48 { 171 SELECT tointeger(9223372036854775807); 172 } {9223372036854775807} 173 if {$highPrecision(1)} { 174 do_execsql_test func4-1.49 { 175 SELECT tointeger(9223372036854775807 + 1); 176 } {{}} 177 do_execsql_test func4-1.50 { 178 SELECT tointeger(9223372036854775808 - 1); 179 } {{}} 180 do_execsql_test func4-1.51 { 181 SELECT tointeger(9223372036854775808); 182 } {{}} 183 do_execsql_test func4-1.52 { 184 SELECT tointeger(9223372036854775808 + 1); 185 } {{}} 186 } 187 do_execsql_test func4-1.53 { 188 SELECT tointeger(18446744073709551616 - 1); 189 } {{}} 190 do_execsql_test func4-1.54 { 191 SELECT tointeger(18446744073709551616); 192 } {{}} 193 do_execsql_test func4-1.55 { 194 SELECT tointeger(18446744073709551616 + 1); 195 } {{}} 196 197 ifcapable floatingpoint { 198 set highPrecision(2) [expr \ 199 {[db eval {SELECT toreal(-9223372036854775808 + 1);}] eq {{}}}] 200 201 do_execsql_test func4-2.1 { 202 SELECT toreal(NULL); 203 } {{}} 204 do_execsql_test func4-2.2 { 205 SELECT toreal(''); 206 } {{}} 207 do_execsql_test func4-2.3 { 208 SELECT toreal(' '); 209 } {{}} 210 do_execsql_test func4-2.4 { 211 SELECT toreal('1234'); 212 } {1234.0} 213 do_execsql_test func4-2.5 { 214 SELECT toreal(' 1234'); 215 } {{}} 216 do_execsql_test func4-2.6 { 217 SELECT toreal('bad'); 218 } {{}} 219 do_execsql_test func4-2.7 { 220 SELECT toreal('0xBAD'); 221 } {{}} 222 do_execsql_test func4-2.8 { 223 SELECT toreal('123BAD'); 224 } {{}} 225 do_execsql_test func4-2.9 { 226 SELECT toreal('0x123BAD'); 227 } {{}} 228 do_execsql_test func4-2.10 { 229 SELECT toreal('123NO'); 230 } {{}} 231 do_execsql_test func4-2.11 { 232 SELECT toreal('0x123NO'); 233 } {{}} 234 do_execsql_test func4-2.12 { 235 SELECT toreal('-0x1'); 236 } {{}} 237 do_execsql_test func4-2.13 { 238 SELECT toreal('-0x0'); 239 } {{}} 240 do_execsql_test func4-2.14 { 241 SELECT toreal('0x0'); 242 } {{}} 243 do_execsql_test func4-2.15 { 244 SELECT toreal('0x1'); 245 } {{}} 246 do_execsql_test func4-2.16 { 247 SELECT toreal(-1); 248 } {-1.0} 249 do_execsql_test func4-2.17 { 250 SELECT toreal(-0); 251 } {0.0} 252 do_execsql_test func4-2.18 { 253 SELECT toreal(0); 254 } {0.0} 255 do_execsql_test func4-2.19 { 256 SELECT toreal(1); 257 } {1.0} 258 do_execsql_test func4-2.20 { 259 SELECT toreal(-1.79769313486232e308 - 1); 260 } {-Inf} 261 do_execsql_test func4-2.21 { 262 SELECT toreal(-1.79769313486232e308); 263 } {-Inf} 264 do_execsql_test func4-2.22 { 265 SELECT toreal(-1.79769313486232e308 + 1); 266 } {-Inf} 267 do_execsql_test func4-2.23 { 268 SELECT toreal(-9223372036854775808 - 1); 269 } {-9.223372036854776e+18} 270 do_execsql_test func4-2.24 { 271 SELECT toreal(-9223372036854775808); 272 } {-9.223372036854776e+18} 273 if {$highPrecision(2)} { 274 do_execsql_test func4-2.25 { 275 SELECT toreal(-9223372036854775808 + 1); 276 } {{}} 277 } 278 do_execsql_test func4-2.26 { 279 SELECT toreal(-9223372036854775807 - 1); 280 } {-9.223372036854776e+18} 281 if {$highPrecision(2)} { 282 do_execsql_test func4-2.27 { 283 SELECT toreal(-9223372036854775807); 284 } {{}} 285 do_execsql_test func4-2.28 { 286 SELECT toreal(-9223372036854775807 + 1); 287 } {{}} 288 } 289 do_execsql_test func4-2.29 { 290 SELECT toreal(-2147483648 - 1); 291 } {-2147483649.0} 292 do_execsql_test func4-2.30 { 293 SELECT toreal(-2147483648); 294 } {-2147483648.0} 295 do_execsql_test func4-2.31 { 296 SELECT toreal(-2147483648 + 1); 297 } {-2147483647.0} 298 do_execsql_test func4-2.32 { 299 SELECT toreal(2147483647 - 1); 300 } {2147483646.0} 301 do_execsql_test func4-2.33 { 302 SELECT toreal(2147483647); 303 } {2147483647.0} 304 do_execsql_test func4-2.34 { 305 SELECT toreal(2147483647 + 1); 306 } {2147483648.0} 307 if {$highPrecision(2)} { 308 do_execsql_test func4-2.35 { 309 SELECT toreal(9223372036854775807 - 1); 310 } {{}} 311 if {$highPrecision(1)} { 312 do_execsql_test func4-2.36 { 313 SELECT toreal(9223372036854775807); 314 } {{}} 315 } 316 } 317 do_execsql_test func4-2.37 { 318 SELECT toreal(9223372036854775807 + 1); 319 } {9.223372036854776e+18} 320 do_execsql_test func4-2.38 { 321 SELECT toreal(1.79769313486232e308 - 1); 322 } {Inf} 323 do_execsql_test func4-2.39 { 324 SELECT toreal(1.79769313486232e308); 325 } {Inf} 326 do_execsql_test func4-2.40 { 327 SELECT toreal(1.79769313486232e308 + 1); 328 } {Inf} 329 do_execsql_test func4-2.41 { 330 SELECT toreal(4503599627370496 - 1); 331 } {4503599627370495.0} 332 do_execsql_test func4-2.42 { 333 SELECT toreal(4503599627370496); 334 } {4503599627370496.0} 335 do_execsql_test func4-2.43 { 336 SELECT toreal(4503599627370496 + 1); 337 } {4503599627370497.0} 338 do_execsql_test func4-2.44 { 339 SELECT toreal(9007199254740992 - 1); 340 } {9007199254740991.0} 341 do_execsql_test func4-2.45 { 342 SELECT toreal(9007199254740992); 343 } {9007199254740992.0} 344 if {$highPrecision(2)} { 345 do_execsql_test func4-2.46 { 346 SELECT toreal(9007199254740992 + 1); 347 } {{}} 348 } 349 do_execsql_test func4-2.47 { 350 SELECT toreal(9007199254740992 + 2); 351 } {9007199254740994.0} 352 do_execsql_test func4-2.48 { 353 SELECT toreal(tointeger(9223372036854775808) - 1); 354 } {{}} 355 if {$highPrecision(1)} { 356 do_execsql_test func4-2.49 { 357 SELECT toreal(tointeger(9223372036854775808)); 358 } {{}} 359 do_execsql_test func4-2.50 { 360 SELECT toreal(tointeger(9223372036854775808) + 1); 361 } {{}} 362 } 363 do_execsql_test func4-2.51 { 364 SELECT toreal(tointeger(18446744073709551616) - 1); 365 } {{}} 366 do_execsql_test func4-2.52 { 367 SELECT toreal(tointeger(18446744073709551616)); 368 } {{}} 369 do_execsql_test func4-2.53 { 370 SELECT toreal(tointeger(18446744073709551616) + 1); 371 } {{}} 372 } 373 374 ifcapable check { 375 do_execsql_test func4-3.1 { 376 CREATE TABLE t1( 377 x INTEGER CHECK(tointeger(x) IS NOT NULL) 378 ); 379 } {} 380 do_test func4-3.2 { 381 catchsql { 382 INSERT INTO t1 (x) VALUES (NULL); 383 } 384 } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} 385 do_test func4-3.3 { 386 catchsql { 387 INSERT INTO t1 (x) VALUES (NULL); 388 } 389 } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} 390 do_test func4-3.4 { 391 catchsql { 392 INSERT INTO t1 (x) VALUES (''); 393 } 394 } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} 395 do_test func4-3.5 { 396 catchsql { 397 INSERT INTO t1 (x) VALUES ('bad'); 398 } 399 } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} 400 do_test func4-3.6 { 401 catchsql { 402 INSERT INTO t1 (x) VALUES ('1234bad'); 403 } 404 } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} 405 do_test func4-3.7 { 406 catchsql { 407 INSERT INTO t1 (x) VALUES ('1234.56bad'); 408 } 409 } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} 410 do_test func4-3.8 { 411 catchsql { 412 INSERT INTO t1 (x) VALUES (1234); 413 } 414 } {0 {}} 415 do_test func4-3.9 { 416 catchsql { 417 INSERT INTO t1 (x) VALUES (1234.56); 418 } 419 } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} 420 do_test func4-3.10 { 421 catchsql { 422 INSERT INTO t1 (x) VALUES ('1234'); 423 } 424 } {0 {}} 425 do_test func4-3.11 { 426 catchsql { 427 INSERT INTO t1 (x) VALUES ('1234.56'); 428 } 429 } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} 430 do_test func4-3.12 { 431 catchsql { 432 INSERT INTO t1 (x) VALUES (ZEROBLOB(4)); 433 } 434 } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} 435 do_test func4-3.13 { 436 catchsql { 437 INSERT INTO t1 (x) VALUES (X''); 438 } 439 } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} 440 do_test func4-3.14 { 441 catchsql { 442 INSERT INTO t1 (x) VALUES (X'1234'); 443 } 444 } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} 445 do_test func4-3.15 { 446 catchsql { 447 INSERT INTO t1 (x) VALUES (X'12345678'); 448 } 449 } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} 450 do_test func4-3.16 { 451 catchsql { 452 INSERT INTO t1 (x) VALUES ('1234.00'); 453 } 454 } {0 {}} 455 do_test func4-3.17 { 456 catchsql { 457 INSERT INTO t1 (x) VALUES (1234.00); 458 } 459 } {0 {}} 460 do_test func4-3.18 { 461 catchsql { 462 INSERT INTO t1 (x) VALUES ('-9223372036854775809'); 463 } 464 } {0 {}} 465 if {$highPrecision(1)} { 466 do_test func4-3.19 { 467 catchsql { 468 INSERT INTO t1 (x) VALUES (9223372036854775808); 469 } 470 } {1 {CHECK constraint failed: tointeger(x) IS NOT NULL}} 471 } 472 do_execsql_test func4-3.20 { 473 SELECT x FROM t1 WHERE x>0 ORDER BY x; 474 } {1234 1234 1234 1234} 475 476 ifcapable floatingpoint { 477 do_execsql_test func4-4.1 { 478 CREATE TABLE t2( 479 x REAL CHECK(toreal(x) IS NOT NULL) 480 ); 481 } {} 482 do_test func4-4.2 { 483 catchsql { 484 INSERT INTO t2 (x) VALUES (NULL); 485 } 486 } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} 487 do_test func4-4.3 { 488 catchsql { 489 INSERT INTO t2 (x) VALUES (NULL); 490 } 491 } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} 492 do_test func4-4.4 { 493 catchsql { 494 INSERT INTO t2 (x) VALUES (''); 495 } 496 } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} 497 do_test func4-4.5 { 498 catchsql { 499 INSERT INTO t2 (x) VALUES ('bad'); 500 } 501 } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} 502 do_test func4-4.6 { 503 catchsql { 504 INSERT INTO t2 (x) VALUES ('1234bad'); 505 } 506 } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} 507 do_test func4-4.7 { 508 catchsql { 509 INSERT INTO t2 (x) VALUES ('1234.56bad'); 510 } 511 } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} 512 do_test func4-4.8 { 513 catchsql { 514 INSERT INTO t2 (x) VALUES (1234); 515 } 516 } {0 {}} 517 do_test func4-4.9 { 518 catchsql { 519 INSERT INTO t2 (x) VALUES (1234.56); 520 } 521 } {0 {}} 522 do_test func4-4.10 { 523 catchsql { 524 INSERT INTO t2 (x) VALUES ('1234'); 525 } 526 } {0 {}} 527 do_test func4-4.11 { 528 catchsql { 529 INSERT INTO t2 (x) VALUES ('1234.56'); 530 } 531 } {0 {}} 532 do_test func4-4.12 { 533 catchsql { 534 INSERT INTO t2 (x) VALUES (ZEROBLOB(4)); 535 } 536 } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} 537 do_test func4-4.13 { 538 catchsql { 539 INSERT INTO t2 (x) VALUES (X''); 540 } 541 } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} 542 do_test func4-4.14 { 543 catchsql { 544 INSERT INTO t2 (x) VALUES (X'1234'); 545 } 546 } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} 547 do_test func4-4.15 { 548 catchsql { 549 INSERT INTO t2 (x) VALUES (X'12345678'); 550 } 551 } {1 {CHECK constraint failed: toreal(x) IS NOT NULL}} 552 do_execsql_test func4-4.16 { 553 SELECT x FROM t2 ORDER BY x; 554 } {1234.0 1234.0 1234.56 1234.56} 555 } 556 } 557 558 ifcapable floatingpoint { 559 do_execsql_test func4-5.1 { 560 SELECT tointeger(toreal('1234')); 561 } {1234} 562 do_execsql_test func4-5.2 { 563 SELECT tointeger(toreal(-1)); 564 } {-1} 565 do_execsql_test func4-5.3 { 566 SELECT tointeger(toreal(-0)); 567 } {0} 568 do_execsql_test func4-5.4 { 569 SELECT tointeger(toreal(0)); 570 } {0} 571 do_execsql_test func4-5.5 { 572 SELECT tointeger(toreal(1)); 573 } {1} 574 do_execsql_test func4-5.6 { 575 SELECT tointeger(toreal(-9223372036854775808 - 1)); 576 } {-9223372036854775808} 577 do_execsql_test func4-5.7 { 578 SELECT tointeger(toreal(-9223372036854775808)); 579 } {-9223372036854775808} 580 if {$highPrecision(2)} { 581 do_execsql_test func4-5.8 { 582 SELECT tointeger(toreal(-9223372036854775808 + 1)); 583 } {{}} 584 } 585 do_execsql_test func4-5.9 { 586 SELECT tointeger(toreal(-2147483648 - 1)); 587 } {-2147483649} 588 do_execsql_test func4-5.10 { 589 SELECT tointeger(toreal(-2147483648)); 590 } {-2147483648} 591 do_execsql_test func4-5.11 { 592 SELECT tointeger(toreal(-2147483648 + 1)); 593 } {-2147483647} 594 do_execsql_test func4-5.12 { 595 SELECT tointeger(toreal(2147483647 - 1)); 596 } {2147483646} 597 do_execsql_test func4-5.13 { 598 SELECT tointeger(toreal(2147483647)); 599 } {2147483647} 600 do_execsql_test func4-5.14 { 601 SELECT tointeger(toreal(2147483647 + 1)); 602 } {2147483648} 603 do_execsql_test func4-5.15 { 604 SELECT tointeger(toreal(9223372036854775807 - 1)); 605 } {{}} 606 if {$highPrecision(1)} { 607 do_execsql_test func4-5.16 { 608 SELECT tointeger(toreal(9223372036854775807)); 609 } {{}} 610 do_execsql_test func4-5.17 { 611 SELECT tointeger(toreal(9223372036854775807 + 1)); 612 } {{}} 613 } 614 do_execsql_test func4-5.18 { 615 SELECT tointeger(toreal(4503599627370496 - 1)); 616 } {4503599627370495} 617 do_execsql_test func4-5.19 { 618 SELECT tointeger(toreal(4503599627370496)); 619 } {4503599627370496} 620 do_execsql_test func4-5.20 { 621 SELECT tointeger(toreal(4503599627370496 + 1)); 622 } {4503599627370497} 623 do_execsql_test func4-5.21 { 624 SELECT tointeger(toreal(9007199254740992 - 1)); 625 } {9007199254740991} 626 do_execsql_test func4-5.22 { 627 SELECT tointeger(toreal(9007199254740992)); 628 } {9007199254740992} 629 if {$highPrecision(2)} { 630 do_execsql_test func4-5.23 { 631 SELECT tointeger(toreal(9007199254740992 + 1)); 632 } {{}} 633 } 634 do_execsql_test func4-5.24 { 635 SELECT tointeger(toreal(9007199254740992 + 2)); 636 } {9007199254740994} 637 if {$highPrecision(1)} { 638 do_execsql_test func4-5.25 { 639 SELECT tointeger(toreal(9223372036854775808 - 1)); 640 } {{}} 641 do_execsql_test func4-5.26 { 642 SELECT tointeger(toreal(9223372036854775808)); 643 } {{}} 644 do_execsql_test func4-5.27 { 645 SELECT tointeger(toreal(9223372036854775808 + 1)); 646 } {{}} 647 } 648 do_execsql_test func4-5.28 { 649 SELECT tointeger(toreal(18446744073709551616 - 1)); 650 } {{}} 651 do_execsql_test func4-5.29 { 652 SELECT tointeger(toreal(18446744073709551616)); 653 } {{}} 654 do_execsql_test func4-5.30 { 655 SELECT tointeger(toreal(18446744073709551616 + 1)); 656 } {{}} 657 } 658 659 for {set i 0} {$i < 10} {incr i} { 660 if {$i == 8} continue 661 do_execsql_test func4-6.1.$i.1 [subst { 662 SELECT tointeger(x'[string repeat 01 $i]'); 663 }] {{}} 664 ifcapable floatingpoint { 665 do_execsql_test func4-6.1.$i.2 [subst { 666 SELECT toreal(x'[string repeat 01 $i]'); 667 }] {{}} 668 } 669 } 670 671 do_execsql_test func4-6.2.1 { 672 SELECT tointeger(x'0102030405060708'); 673 } {578437695752307201} 674 do_execsql_test func4-6.2.2 { 675 SELECT tointeger(x'0807060504030201'); 676 } {72623859790382856} 677 678 ifcapable floatingpoint { 679 do_execsql_test func4-6.3.1 { 680 SELECT toreal(x'ffefffffffffffff'); 681 } {-1.7976931348623157e+308} 682 do_execsql_test func4-6.3.2 { 683 SELECT toreal(x'8010000000000000'); 684 } {-2.2250738585072014e-308} 685 do_execsql_test func4-6.3.3 { 686 SELECT toreal(x'c000000000000000'); 687 } {-2.0} 688 do_execsql_test func4-6.3.4 { 689 SELECT toreal(x'bff0000000000000'); 690 } {-1.0} 691 do_execsql_test func4-6.3.5 { 692 SELECT toreal(x'8000000000000000'); 693 } {-0.0} 694 do_execsql_test func4-6.3.6 { 695 SELECT toreal(x'0000000000000000'); 696 } {0.0} 697 do_execsql_test func4-6.3.7 { 698 SELECT toreal(x'3ff0000000000000'); 699 } {1.0} 700 do_execsql_test func4-6.3.8 { 701 SELECT toreal(x'4000000000000000'); 702 } {2.0} 703 do_execsql_test func4-6.3.9 { 704 SELECT toreal(x'0010000000000000'); 705 } {2.2250738585072014e-308} 706 do_execsql_test func4-6.3.10 { 707 SELECT toreal(x'7fefffffffffffff'); 708 } {1.7976931348623157e+308} 709 do_execsql_test func4-6.3.11 { 710 SELECT toreal(x'8000000000000001'); 711 } {-5e-324} 712 do_execsql_test func4-6.3.12 { 713 SELECT toreal(x'800fffffffffffff'); 714 } {-2.225073858507201e-308} 715 do_execsql_test func4-6.3.13 { 716 SELECT toreal(x'0000000000000001'); 717 } {5e-324} 718 do_execsql_test func4-6.3.14 { 719 SELECT toreal(x'000fffffffffffff'); 720 } {2.225073858507201e-308} 721 do_execsql_test func4-6.3.15 { 722 SELECT toreal(x'fff0000000000000'); 723 } {-Inf} 724 do_execsql_test func4-6.3.16 { 725 SELECT toreal(x'7ff0000000000000'); 726 } {Inf} 727 do_execsql_test func4-6.3.17 { 728 SELECT toreal(x'fff8000000000000'); 729 } {{}} 730 do_execsql_test func4-6.3.18 { 731 SELECT toreal(x'fff0000000000001'); 732 } {{}} 733 do_execsql_test func4-6.3.19 { 734 SELECT toreal(x'fff7ffffffffffff'); 735 } {{}} 736 do_execsql_test func4-6.3.20 { 737 SELECT toreal(x'7ff0000000000001'); 738 } {{}} 739 do_execsql_test func4-6.3.21 { 740 SELECT toreal(x'7ff7ffffffffffff'); 741 } {{}} 742 do_execsql_test func4-6.3.22 { 743 SELECT toreal(x'fff8000000000001'); 744 } {{}} 745 do_execsql_test func4-6.3.23 { 746 SELECT toreal(x'ffffffffffffffff'); 747 } {{}} 748 do_execsql_test func4-6.3.24 { 749 SELECT toreal(x'7ff8000000000000'); 750 } {{}} 751 do_execsql_test func4-6.3.25 { 752 SELECT toreal(x'7fffffffffffffff'); 753 } {{}} 754 } 755 756 set tcl_precision $saved_tcl_precision 757 unset saved_tcl_precision 758 finish_test