Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: installer/src/installer-lib/test/database_test.cpp

Issue 6202981292703744: Whole installer (Closed)
Patch Set: Created June 24, 2014, 7:27 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #include <gtest/gtest.h>
2 #include "../database.h"
3
4 /*
5 * Note: These tests need to be run in the same directory as the MSI file.
6 * There's a batch file for that purpose "run-tests.cmd".
7 */
8
9 TEST( Database, open )
10 {
11 File_System_Database db( L"test-installer-lib.msi" ) ;
12 }
13
14 class Database_F
15 : public ::testing::Test
16 {
17 protected:
18 File_System_Database db ;
19
20 Database_F()
21 : db( L"test-installer-lib.msi" )
22 {}
23 } ;
24
25 TEST_F( Database_F, view_n_columns_and_n_rows )
26 {
27 View v( db, L"SELECT * FROM AbpUIText" ) ;
28 Record r( v.first() ) ;
29 unsigned int j ;
30 for ( j = 0 ; r != v.end() ; ++ j )
31 {
32 ASSERT_EQ( 3, r.n_fields() ) ;
33 r = v.next() ;
34 }
35 ASSERT_EQ( 4, j ) ;
36 }
37
38 TEST_F( Database_F, view_single_record )
39 {
40 View v( db, L"SELECT `content` FROM `AbpUIText` WHERE `component`='close_ie' a nd `id`='dialog_unknown'" ) ;
41 Record r( v.first() ) ;
42 ASSERT_EQ( 1, r.n_fields() ) ;
43 std::wstring s( r.value_string( 1 ) ) ;
44 std::wstring expected( L"IE is still running" ) ;
45 ASSERT_GT( s.length(), expected.length() ) ;
46 std::wstring prefix( s.substr( 0, expected.length() ) ) ;
47 ASSERT_EQ( prefix, expected ) ;
48 r = v.next() ;
49 ASSERT_EQ( v.end(), r ) ;
50 }
51
52 TEST_F( Database_F, view_single_record_parametric )
53 {
54 View v( db, L"SELECT `content` FROM `AbpUIText` WHERE `component`='close_ie' a nd `id`=?" ) ;
55 Record arg( 1 ) ;
56 arg.assign_string( 1, L"dialog_unknown" ) ;
57 Record r( v.first( arg ) ) ;
58 ASSERT_EQ( 1, r.n_fields() ) ;
59 std::wstring s( r.value_string( 1 ) ) ;
60 std::wstring expected( L"IE is still running" ) ;
61 ASSERT_GT( s.length(), expected.length() ) ;
62 std::wstring prefix( s.substr( 0, expected.length() ) ) ;
63 ASSERT_EQ( prefix, expected ) ;
64 r = v.next() ;
65 ASSERT_EQ( v.end(), r ) ;
66 }
OLDNEW

Powered by Google App Engine
This is Rietveld