OLD | NEW |
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 Loading... |
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 |
OLD | NEW |