/sqlite3cc

To get this branch, use:
bzr branch http://bzr.ed.am/sqlite3cc

« back to all changes in this revision

Viewing changes to test/test-main.cc

  • Committer: edam
  • Date: 2010-02-02 16:13:16 UTC
  • Revision ID: edam@waxworlds.org-20100202161316-tceybmdeotltldow
- print "ok" when test program is successful!
- renamed 'Makefile's 'subdir.mk' so that the edam.mk build system will live happily along side an autotools build system

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
        // test basic_statement binding via stream operator
60
60
        sqlite::command c4( db, "INSERT INTO pets VALUES( ?, ? )" );
61
61
        c4 << "tessa" << 16 << sqlite::exec;
62
 
        sqlite::command c5( db, "INSERT INTO pets VALUES( ?, ? )" );
63
 
        c5 << sqlite::null << sqlite::null <<
 
62
        sqlite::command( db, "INSERT INTO pets VALUES( ?, ? )" ) <<
 
63
                sqlite::null << sqlite::null <<
64
64
                sqlite::set_index( 1 ) << "tamara" << sqlite::exec;
65
65
 
66
66
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
96
96
        // test end of results
97
97
        assert( !q1.step() );
98
98
 
 
99
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
100
 
 
101
        // test transactions
 
102
        {       sqlite::transaction_guard< > t1( db ); }
 
103
        {       sqlite::transaction_guard< sqlite::exclusive_transaction > t1( db ); }
 
104
        {       sqlite::transaction_guard< sqlite::recursive_transaction > t1( db );
 
105
                sqlite::transaction_guard< sqlite::recursive_transaction > t2( db ); }
 
106
 
 
107
        // test transaction guard rollback
 
108
        {
 
109
                sqlite::transaction_guard< > t1( db );
 
110
                db.exec( "UPDATE pets SET age = 99" );
 
111
        }
 
112
        sqlite::query( db, "SELECT age FROM pets ORDER BY age DESC LIMIT 1" )
 
113
                .step() >> age; assert( age == 123 );
 
114
 
 
115
        // text recursive transactions
 
116
        {
 
117
                sqlite::transaction_guard< sqlite::recursive_transaction > t1( db );
 
118
                db.exec( "UPDATE pets SET age = 99" );
 
119
 
 
120
                {
 
121
                        sqlite::transaction_guard< sqlite::recursive_transaction > t2( db );
 
122
                        db.exec( "UPDATE pets SET age = 1" );
 
123
                }
 
124
 
 
125
                sqlite::query( db, "SELECT age FROM pets ORDER BY age DESC LIMIT 1" )
 
126
                        .step() >> age; assert( age == 99 );
 
127
 
 
128
                t1.commit();
 
129
        }
 
130
        sqlite::query( db, "SELECT age FROM pets ORDER BY age DESC LIMIT 1" )
 
131
                .step() >> age; assert( age == 99 );
 
132
 
 
133
        // ok
 
134
        std::cout << "ok\n";
99
135
        return 0;
100
136
}