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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « sql/test/test_helpers.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sql/test/test_helpers.h" 5 #include "sql/test/test_helpers.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 263
264 std::string IntegrityCheck(sql::Connection* db) { 264 std::string IntegrityCheck(sql::Connection* db) {
265 sql::Statement statement(db->GetUniqueStatement("PRAGMA integrity_check")); 265 sql::Statement statement(db->GetUniqueStatement("PRAGMA integrity_check"));
266 266
267 // SQLite should always return a row of data. 267 // SQLite should always return a row of data.
268 EXPECT_TRUE(statement.Step()); 268 EXPECT_TRUE(statement.Step());
269 269
270 return statement.ColumnString(0); 270 return statement.ColumnString(0);
271 } 271 }
272 272
273 std::string ExecuteWithResult(sql::Connection* db, const char* sql) {
274 sql::Statement s(db->GetUniqueStatement(sql));
275 return s.Step() ? s.ColumnString(0) : std::string();
276 }
277
278 std::string ExecuteWithResults(sql::Connection* db,
279 const char* sql,
280 const char* column_sep,
281 const char* row_sep) {
282 sql::Statement s(db->GetUniqueStatement(sql));
283 std::string ret;
284 while (s.Step()) {
285 if (!ret.empty())
286 ret += row_sep;
287 for (int i = 0; i < s.ColumnCount(); ++i) {
288 if (i > 0)
289 ret += column_sep;
290 ret += s.ColumnString(i);
291 }
292 }
293 return ret;
294 }
295
273 } // namespace test 296 } // namespace test
274 } // namespace sql 297 } // namespace sql
OLDNEW
« 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