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/files/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" |
(...skipping 22 matching lines...) Expand all Loading... |
33 int* error_; | 33 int* error_; |
34 std::string* sql_text_; | 34 std::string* sql_text_; |
35 | 35 |
36 DISALLOW_COPY_AND_ASSIGN(StatementErrorHandler); | 36 DISALLOW_COPY_AND_ASSIGN(StatementErrorHandler); |
37 }; | 37 }; |
38 | 38 |
39 class SQLStatementTest : public testing::Test { | 39 class SQLStatementTest : public testing::Test { |
40 public: | 40 public: |
41 SQLStatementTest() : error_(SQLITE_OK) {} | 41 SQLStatementTest() : error_(SQLITE_OK) {} |
42 | 42 |
43 void SetUp() { | 43 virtual void SetUp() { |
44 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 44 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
45 ASSERT_TRUE(db_.Open(temp_dir_.path().AppendASCII("SQLStatementTest.db"))); | 45 ASSERT_TRUE(db_.Open(temp_dir_.path().AppendASCII("SQLStatementTest.db"))); |
46 // The error delegate will set |error_| and |sql_text_| when any sqlite | 46 // The error delegate will set |error_| and |sql_text_| when any sqlite |
47 // statement operation returns an error code. | 47 // statement operation returns an error code. |
48 db_.set_error_delegate(new StatementErrorHandler(&error_, &sql_text_)); | 48 db_.set_error_delegate(new StatementErrorHandler(&error_, &sql_text_)); |
49 } | 49 } |
50 | 50 |
51 void TearDown() { | 51 virtual void TearDown() { |
52 // If any error happened the original sql statement can be found in | 52 // If any error happened the original sql statement can be found in |
53 // |sql_text_|. | 53 // |sql_text_|. |
54 EXPECT_EQ(SQLITE_OK, error_); | 54 EXPECT_EQ(SQLITE_OK, error_); |
55 db_.Close(); | 55 db_.Close(); |
56 } | 56 } |
57 | 57 |
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 |
(...skipping 81 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 |