| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "sql/connection.h" | 10 #include "sql/connection.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 const char kPageSql[] = "SELECT rootpage FROM sqlite_master WHERE name = ?"; | 35 const char kPageSql[] = "SELECT rootpage FROM sqlite_master WHERE name = ?"; |
| 36 sql::Statement s(db->GetUniqueStatement(kPageSql)); | 36 sql::Statement s(db->GetUniqueStatement(kPageSql)); |
| 37 s.BindString(0, name); | 37 s.BindString(0, name); |
| 38 if (!s.Step()) | 38 if (!s.Step()) |
| 39 return false; | 39 return false; |
| 40 *page_number = s.ColumnInt(0); | 40 *page_number = s.ColumnInt(0); |
| 41 return true; | 41 return true; |
| 42 } | 42 } |
| 43 | 43 |
| 44 // Helper for reading a number from the SQLite header. | 44 // Helper for reading a number from the SQLite header. |
| 45 // See net/base/big_endian.h. | 45 // See base/big_endian.h. |
| 46 unsigned ReadBigEndian(unsigned char* buf, size_t bytes) { | 46 unsigned ReadBigEndian(unsigned char* buf, size_t bytes) { |
| 47 unsigned r = buf[0]; | 47 unsigned r = buf[0]; |
| 48 for (size_t i = 1; i < bytes; i++) { | 48 for (size_t i = 1; i < bytes; i++) { |
| 49 r <<= 8; | 49 r <<= 8; |
| 50 r |= buf[i]; | 50 r |= buf[i]; |
| 51 } | 51 } |
| 52 return r; | 52 return r; |
| 53 } | 53 } |
| 54 | 54 |
| 55 // Helper for writing a number to the SQLite header. | 55 // Helper for writing a number to the SQLite header. |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 sql::Statement statement(db->GetUniqueStatement("PRAGMA integrity_check")); | 241 sql::Statement statement(db->GetUniqueStatement("PRAGMA integrity_check")); |
| 242 | 242 |
| 243 // SQLite should always return a row of data. | 243 // SQLite should always return a row of data. |
| 244 EXPECT_TRUE(statement.Step()); | 244 EXPECT_TRUE(statement.Step()); |
| 245 | 245 |
| 246 return statement.ColumnString(0); | 246 return statement.ColumnString(0); |
| 247 } | 247 } |
| 248 | 248 |
| 249 } // namespace test | 249 } // namespace test |
| 250 } // namespace sql | 250 } // namespace sql |
| OLD | NEW |