/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: Tim Marston
  • Date: 2015-02-26 08:59:16 UTC
  • Revision ID: tim@ed.am-20150226085916-1z7761knxbutpr7n
updated tests for blob support

Show diffs side-by-side

added added

removed removed

1
1
/*
2
 
 * test-database.cc
 
2
 * test-main.cc
3
3
 *
4
4
 * Copyright (C) 2009 Tim Marston <tim@ed.am>
5
5
 *
56
56
        sqlite::command c6( conn, "INSERT INTO pets VALUES( ?, ? )" );
57
57
        c6.bind_null( 1 ); c6.bind( 2, 123 ); c6.exec();
58
58
        sqlite::command c7( conn, "INSERT INTO pets VALUES( :foo, :bar )" );
59
 
        c7.bind( ":foo", "foocat" ); c7.bind( ":bar", 22 ); c7.exec();
 
59
        c7.bind( ":foo", "foocat" ); c7.bind( ":bar", 22.5 ); c7.exec();
60
60
 
61
61
        // test command binding via stream operator
62
62
        sqlite::command( conn, "INSERT INTO pets VALUES( ?, ? )" ) <<
91
91
 
92
92
        // test rows
93
93
        unsigned int age;
 
94
        double dblage;
94
95
        std::string name;
95
96
        q1.step().column( 0, age ); assert( age == 12 );
96
97
        name = q1.step().column< std::string >( 2 ); assert( name == "mopti" );
100
101
        r1 >> age; assert( age == 16 );
101
102
        r1 >> age; assert( age == 19 );
102
103
        r1 >> name; assert( name == "tessa" );
103
 
        q1.step() >> age >> sqlite::null >> name;
104
 
        assert( age == 22 && name == "foocat" );
 
104
        q1.step() >> dblage >> sqlite::null >> name;
 
105
        assert( dblage == 22.5 && name == "foocat" );
105
106
        sqlite::row row = q1.step();
106
107
        row >> age >> sqlite::null >> sqlite::null; assert( age == 123 );
107
108
        row >> sqlite::set_index( 1 ) >> age; assert( age == 126 );
184
185
        sqlite::query( conn, "SELECT age FROM pets ORDER BY age DESC LIMIT 1" )
185
186
                .step() >> age; assert( age == 123 );
186
187
 
 
188
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
189
 
187
190
        // ok
188
191
        return 0;
189
192
}