summaryrefslogtreecommitdiffstats
path: root/sql/test/test_helpers.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/test/test_helpers.cc')
-rw-r--r--sql/test/test_helpers.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/sql/test/test_helpers.cc b/sql/test/test_helpers.cc
index 607f146..20471dc 100644
--- a/sql/test/test_helpers.cc
+++ b/sql/test/test_helpers.cc
@@ -55,6 +55,20 @@ size_t CountTableColumns(sql::Connection* db, const char* table) {
return rows;
}
+bool CountTableRows(sql::Connection* db, const char* table, size_t* count) {
+ // TODO(shess): Table should probably be quoted with [] or "". See
+ // http://www.sqlite.org/lang_keywords.html . Meanwhile, odd names
+ // will throw an error.
+ std::string sql = "SELECT COUNT(*) FROM ";
+ sql += table;
+ sql::Statement s(db->GetUniqueStatement(sql.c_str()));
+ if (!s.Step())
+ return false;
+
+ *count = s.ColumnInt64(0);
+ return true;
+}
+
bool CreateDatabaseFromSQL(const base::FilePath& db_path,
const base::FilePath& sql_path) {
if (base::PathExists(db_path) || !base::PathExists(sql_path))