Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Unified Diff: sql/test/test_helpers.cc

Issue 2441153002: [sql] Test helpers to ease testing of simple queries. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sql/test/test_helpers.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/test/test_helpers.cc
diff --git a/sql/test/test_helpers.cc b/sql/test/test_helpers.cc
index 7c21aea9fa6926db843c3e7ebfeae3bfd6e32e3b..0e32164acdc782ca32927ee20c438a1ffbaa3387 100644
--- a/sql/test/test_helpers.cc
+++ b/sql/test/test_helpers.cc
@@ -270,5 +270,28 @@ std::string IntegrityCheck(sql::Connection* db) {
return statement.ColumnString(0);
}
+std::string ExecuteWithResult(sql::Connection* db, const char* sql) {
+ sql::Statement s(db->GetUniqueStatement(sql));
+ return s.Step() ? s.ColumnString(0) : std::string();
+}
+
+std::string ExecuteWithResults(sql::Connection* db,
+ const char* sql,
+ const char* column_sep,
+ const char* row_sep) {
+ sql::Statement s(db->GetUniqueStatement(sql));
+ std::string ret;
+ while (s.Step()) {
+ if (!ret.empty())
+ ret += row_sep;
+ for (int i = 0; i < s.ColumnCount(); ++i) {
+ if (i > 0)
+ ret += column_sep;
+ ret += s.ColumnString(i);
+ }
+ }
+ return ret;
+}
+
} // namespace test
} // namespace sql
« no previous file with comments | « sql/test/test_helpers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698