Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: third_party/sqlite/src/test/capi3.test

Issue 6990047: Import SQLite 3.7.6.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/sqlite/src/test/capi2.test ('k') | third_party/sqlite/src/test/capi3b.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2003 January 29 1 # 2003 January 29
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
11 # This file implements regression tests for SQLite library. The 11 # This file implements regression tests for SQLite library. The
12 # focus of this script testing the callback-free C/C++ API. 12 # focus of this script testing the callback-free C/C++ API.
13 # 13 #
14 # $Id: capi3.test,v 1.70 2009/01/09 02:49:32 drh Exp $ 14 # $Id: capi3.test,v 1.70 2009/01/09 02:49:32 drh Exp $
15 # 15 #
16 16
17 set testdir [file dirname $argv0] 17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl 18 source $testdir/tester.tcl
19 19
20 # Do not use a codec for tests in this file, as the database file is
21 # manipulated directly using tcl scripts (using the [hexio_write] command).
22 #
23 do_not_use_codec
24
20 # Return the UTF-16 representation of the supplied UTF-8 string $str. 25 # Return the UTF-16 representation of the supplied UTF-8 string $str.
21 # If $nt is true, append two 0x00 bytes as a nul terminator. 26 # If $nt is true, append two 0x00 bytes as a nul terminator.
22 proc utf16 {str {nt 1}} { 27 proc utf16 {str {nt 1}} {
23 set r [encoding convertto unicode $str] 28 set r [encoding convertto unicode $str]
24 if {$nt} { 29 if {$nt} {
25 append r "\x00\x00" 30 append r "\x00\x00"
26 } 31 }
27 return $r 32 return $r
28 } 33 }
29 34
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 sqlite3_finalize $STMT 633 sqlite3_finalize $STMT
629 } SQLITE_OK 634 } SQLITE_OK
630 635
631 636
632 set ::ENC [execsql {pragma encoding}] 637 set ::ENC [execsql {pragma encoding}]
633 db close 638 db close
634 639
635 do_test capi3-6.0 { 640 do_test capi3-6.0 {
636 sqlite3 db test.db 641 sqlite3 db test.db
637 set DB [sqlite3_connection_pointer db] 642 set DB [sqlite3_connection_pointer db]
638 sqlite3_key $DB xyzzy 643 if {[sqlite3 -has-codec]==0} { sqlite3_key $DB xyzzy }
639 set sql {SELECT a FROM t1 order by rowid} 644 set sql {SELECT a FROM t1 order by rowid}
640 set STMT [sqlite3_prepare $DB $sql -1 TAIL] 645 set STMT [sqlite3_prepare $DB $sql -1 TAIL]
641 expr 0 646 expr 0
642 } {0} 647 } {0}
643 do_test capi3-6.1 { 648 do_test capi3-6.1 {
644 db cache flush 649 db cache flush
645 sqlite3_close $DB 650 sqlite3_close $DB
646 } {SQLITE_BUSY} 651 } {SQLITE_BUSY}
647 do_test capi3-6.2 { 652 do_test capi3-6.2 {
648 sqlite3_step $STMT 653 sqlite3_step $STMT
649 } {SQLITE_ROW} 654 } {SQLITE_ERROR}
650 check_data $STMT capi3-6.3 {INTEGER} {1} {1.0} {1} 655 #check_data $STMT capi3-6.3 {INTEGER} {1} {1.0} {1}
651 do_test capi3-6.3 { 656 do_test capi3-6.3 {
652 sqlite3_finalize $STMT 657 sqlite3_finalize $STMT
653 } {SQLITE_OK} 658 } {SQLITE_SCHEMA}
654 do_test capi3-6.4-misuse { 659 do_test capi3-6.4-misuse {
655 db cache flush 660 db cache flush
656 sqlite3_close $DB 661 sqlite3_close $DB
657 } {SQLITE_OK} 662 } {SQLITE_OK}
658 db close 663 db close
659 664
660 # This procedure sets the value of the file-format in file 'test.db' 665 # This procedure sets the value of the file-format in file 'test.db'
661 # to $newval. Also, the schema cookie is incremented. 666 # to $newval. Also, the schema cookie is incremented.
662 # 667 #
663 proc set_file_format {newval} { 668 proc set_file_format {newval} {
664 hexio_write test.db 44 [hexio_render_int32 $newval] 669 hexio_write test.db 44 [hexio_render_int32 $newval]
665 set schemacookie [hexio_get_int [hexio_read test.db 40 4]] 670 set schemacookie [hexio_get_int [hexio_read test.db 40 4]]
666 incr schemacookie 671 incr schemacookie
667 hexio_write test.db 40 [hexio_render_int32 $schemacookie] 672 hexio_write test.db 40 [hexio_render_int32 $schemacookie]
668 return {} 673 return {}
669 } 674 }
670 675
671 # This procedure returns the value of the file-format in file 'test.db'. 676 # This procedure returns the value of the file-format in file 'test.db'.
672 # 677 #
673 proc get_file_format {{fname test.db}} { 678 proc get_file_format {{fname test.db}} {
674 return [hexio_get_int [hexio_read $fname 44 4]] 679 return [hexio_get_int [hexio_read $fname 44 4]]
675 } 680 }
676 681
677 if {![sqlite3 -has-codec]} { 682 if {![sqlite3 -has-codec]} {
678 # Test what happens when the library encounters a newer file format. 683 # Test what happens when the library encounters a newer file format.
679 do_test capi3-7.1 { 684 do_test capi3-7.1 {
680 set_file_format 5 685 set_file_format 5
681 } {} 686 } {}
682 do_test capi3-7.2 { 687 do_test capi3-7.2 {
683 sqlite3 db test.db 688 catch { sqlite3 db test.db }
684 catchsql { 689 catchsql {
685 SELECT * FROM sqlite_master; 690 SELECT * FROM sqlite_master;
686 } 691 }
687 } {1 {unsupported file format}} 692 } {1 {unsupported file format}}
688 db close 693 db close
689 } 694 }
690 695
691 if {![sqlite3 -has-codec]} { 696 if {![sqlite3 -has-codec]} {
692 # Now test that the library correctly handles bogus entries in the 697 # Now test that the library correctly handles bogus entries in the
693 # sqlite_master table (schema corruption). 698 # sqlite_master table (schema corruption).
694 do_test capi3-8.1 { 699 do_test capi3-8.1 {
695 file delete -force test.db test.db-journal 700 file delete -force test.db test.db-journal
696 sqlite3 db test.db 701 sqlite3 db test.db
697 execsql { 702 execsql {
698 CREATE TABLE t1(a); 703 CREATE TABLE t1(a);
699 } 704 }
700 db close 705 db close
701 } {} 706 } {}
702 do_test capi3-8.2 { 707 do_test capi3-8.2 {
703 sqlite3 db test.db 708 sqlite3 db test.db
704 execsql { 709 execsql {
705 PRAGMA writable_schema=ON; 710 PRAGMA writable_schema=ON;
706 INSERT INTO sqlite_master VALUES(NULL,NULL,NULL,NULL,NULL); 711 INSERT INTO sqlite_master VALUES(NULL,NULL,NULL,NULL,NULL);
707 } 712 }
708 db close 713 db close
709 } {} 714 } {}
710 do_test capi3-8.3 { 715 do_test capi3-8.3 {
711 sqlite3 db test.db 716 catch { sqlite3 db test.db }
712 catchsql { 717 catchsql {
713 SELECT * FROM sqlite_master; 718 SELECT * FROM sqlite_master;
714 } 719 }
715 } {1 {malformed database schema (?)}} 720 } {1 {malformed database schema (?)}}
716 do_test capi3-8.4 { 721 do_test capi3-8.4 {
717 # Build a 5-field row record. The first field is a string 'table', and 722 # Build a 5-field row record. The first field is a string 'table', and
718 # subsequent fields are all NULL. 723 # subsequent fields are all NULL.
719 db close 724 db close
720 file delete -force test.db test.db-journal 725 file delete -force test.db test.db-journal
721 sqlite3 db test.db 726 sqlite3 db test.db
722 execsql { 727 execsql {
723 CREATE TABLE t1(a); 728 CREATE TABLE t1(a);
724 PRAGMA writable_schema=ON; 729 PRAGMA writable_schema=ON;
725 INSERT INTO sqlite_master VALUES('table',NULL,NULL,NULL,NULL); 730 INSERT INTO sqlite_master VALUES('table',NULL,NULL,NULL,NULL);
726 } 731 }
727 db close 732 db close
728 } {}; 733 } {};
729 do_test capi3-8.5 { 734 do_test capi3-8.5 {
730 sqlite3 db test.db 735 catch { sqlite3 db test.db }
731 catchsql { 736 catchsql {
732 SELECT * FROM sqlite_master; 737 SELECT * FROM sqlite_master;
733 } 738 }
734 } {1 {malformed database schema (?)}} 739 } {1 {malformed database schema (?)}}
735 db close 740 db close
736 } 741 }
737 file delete -force test.db 742 file delete -force test.db
738 file delete -force test.db-journal 743 file delete -force test.db-journal
739 744
740 745
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 if {![info exists tester_do_binarylog]} { 1206 if {![info exists tester_do_binarylog]} {
1202 db close 1207 db close
1203 vfs_unregister_all 1208 vfs_unregister_all
1204 do_test capi3-20.1 { 1209 do_test capi3-20.1 {
1205 sqlite3_sleep 100 1210 sqlite3_sleep 100
1206 } {0} 1211 } {0}
1207 vfs_reregister_all 1212 vfs_reregister_all
1208 } 1213 }
1209 1214
1210 finish_test 1215 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/capi2.test ('k') | third_party/sqlite/src/test/capi3b.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698