OLD | NEW |
(Empty) | |
| 1 #include <gtest/gtest.h> |
| 2 #include "../database.h" |
| 3 |
| 4 TEST( Database, open ) |
| 5 { |
| 6 File_System_Database db( L"test-installer-lib.msi" ) ; |
| 7 } |
| 8 |
| 9 class Database_F |
| 10 : public ::testing::Test |
| 11 { |
| 12 protected: |
| 13 File_System_Database db ; |
| 14 |
| 15 Database_F() |
| 16 : db( L"test-installer-lib.msi" ) |
| 17 {} |
| 18 } ; |
| 19 |
| 20 TEST_F( Database_F, view_n_columns_and_n_rows ) |
| 21 { |
| 22 View v( db, L"SELECT * FROM AbpUIText" ) ; |
| 23 Record r( v.first() ) ; |
| 24 unsigned int j ; |
| 25 for ( j = 0 ; r != v.end() ; ++ j ) |
| 26 { |
| 27 ASSERT_EQ( 3, r.n_fields() ) ; |
| 28 r = v.next() ; |
| 29 } |
| 30 ASSERT_EQ( 4, j ) ; |
| 31 } |
| 32 |
| 33 TEST_F( Database_F, view_single_record ) |
| 34 { |
| 35 View v( db, L"SELECT `content` FROM `AbpUIText` WHERE `component`='close_ie' a
nd `id`='dialog_unknown'" ) ; |
| 36 Record r( v.first() ) ; |
| 37 ASSERT_EQ( 1, r.n_fields() ) ; |
| 38 std::wstring s( r.value_string( 1 ) ) ; |
| 39 std::wstring expected( L"IE is still running" ) ; |
| 40 ASSERT_GT( s.length(), expected.length() ) ; |
| 41 std::wstring prefix( s.substr( 0, expected.length() ) ) ; |
| 42 ASSERT_EQ( prefix, expected ) ; |
| 43 r = v.next() ; |
| 44 ASSERT_EQ( v.end(), r ) ; |
| 45 } |
| 46 |
| 47 TEST_F( Database_F, view_single_record_parametric ) |
| 48 { |
| 49 View v( db, L"SELECT `content` FROM `AbpUIText` WHERE `component`='close_ie' a
nd `id`=?" ) ; |
| 50 Record arg( 1 ) ; |
| 51 arg.assign_string( 1, L"dialog_unknown" ) ; |
| 52 Record r( v.first( arg ) ) ; |
| 53 ASSERT_EQ( 1, r.n_fields() ) ; |
| 54 std::wstring s( r.value_string( 1 ) ) ; |
| 55 std::wstring expected( L"IE is still running" ) ; |
| 56 ASSERT_GT( s.length(), expected.length() ) ; |
| 57 std::wstring prefix( s.substr( 0, expected.length() ) ) ; |
| 58 ASSERT_EQ( prefix, expected ) ; |
| 59 r = v.next() ; |
| 60 ASSERT_EQ( v.end(), r ) ; |
| 61 } |
OLD | NEW |