| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "sql/connection.h" | 9 #include "sql/connection.h" |
| 10 #include "sql/statement.h" | 10 #include "sql/statement.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "third_party/sqlite/sqlite3.h" | 12 #include "third_party/sqlite/sqlite3.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 class StatementErrorHandler : public sql::ErrorDelegate { | 16 class StatementErrorHandler : public sql::ErrorDelegate { |
| 17 public: | 17 public: |
| 18 StatementErrorHandler(int* error, std::string* sql_text) | 18 StatementErrorHandler(int* error, std::string* sql_text) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 sql::Connection& db() { return db_; } | 58 sql::Connection& db() { return db_; } |
| 59 | 59 |
| 60 int sqlite_error() const { return error_; } | 60 int sqlite_error() const { return error_; } |
| 61 | 61 |
| 62 void ResetError() { | 62 void ResetError() { |
| 63 error_ = SQLITE_OK; | 63 error_ = SQLITE_OK; |
| 64 sql_text_.clear(); | 64 sql_text_.clear(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 ScopedTempDir temp_dir_; | 68 base::ScopedTempDir temp_dir_; |
| 69 sql::Connection db_; | 69 sql::Connection db_; |
| 70 | 70 |
| 71 // The error code of the most recent error. | 71 // The error code of the most recent error. |
| 72 int error_; | 72 int error_; |
| 73 // Original statement which caused the error. | 73 // Original statement which caused the error. |
| 74 std::string sql_text_; | 74 std::string sql_text_; |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 } // namespace | 77 } // namespace |
| 78 | 78 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 143 |
| 144 s.Reset(false); | 144 s.Reset(false); |
| 145 // Verify that we can get all rows again. | 145 // Verify that we can get all rows again. |
| 146 ASSERT_TRUE(s.Step()); | 146 ASSERT_TRUE(s.Step()); |
| 147 EXPECT_EQ(12, s.ColumnInt(0)); | 147 EXPECT_EQ(12, s.ColumnInt(0)); |
| 148 EXPECT_FALSE(s.Step()); | 148 EXPECT_FALSE(s.Step()); |
| 149 | 149 |
| 150 s.Reset(true); | 150 s.Reset(true); |
| 151 ASSERT_FALSE(s.Step()); | 151 ASSERT_FALSE(s.Step()); |
| 152 } | 152 } |
| OLD | NEW |