| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // Insert in the foo table the primary key. It is an error to insert | 113 // Insert in the foo table the primary key. It is an error to insert |
| 114 // something other than an number. This error causes the error callback | 114 // something other than an number. This error causes the error callback |
| 115 // handler to be called with SQLITE_MISMATCH as error code. | 115 // handler to be called with SQLITE_MISMATCH as error code. |
| 116 sql::Statement s(db().GetUniqueStatement("INSERT INTO foo (a) VALUES (?)")); | 116 sql::Statement s(db().GetUniqueStatement("INSERT INTO foo (a) VALUES (?)")); |
| 117 EXPECT_TRUE(s.is_valid()); | 117 EXPECT_TRUE(s.is_valid()); |
| 118 s.BindCString(0, "bad bad"); | 118 s.BindCString(0, "bad bad"); |
| 119 EXPECT_FALSE(s.Run()); | 119 EXPECT_FALSE(s.Run()); |
| 120 EXPECT_EQ(SQLITE_MISMATCH, sqlite_error()); | 120 EXPECT_EQ(SQLITE_MISMATCH, sqlite_error()); |
| 121 reset_error(); | 121 reset_error(); |
| 122 } | 122 } |
| 123 |
| 124 TEST_F(SQLStatementTest, ResetWithoutClearingBoundVariables) { |
| 125 ASSERT_TRUE(db().Execute("CREATE TABLE foo (a, b)")); |
| 126 ASSERT_TRUE(db().Execute("INSERT INTO foo (a, b) VALUES (3, 12)")); |
| 127 ASSERT_TRUE(db().Execute("INSERT INTO foo (a, b) VALUES (4, 13)")); |
| 128 |
| 129 sql::Statement s(db().GetUniqueStatement("SELECT b FROM foo ORDER BY a ASC")); |
| 130 ASSERT_TRUE(s.Step()); |
| 131 EXPECT_EQ(12, s.ColumnInt(0)); |
| 132 ASSERT_TRUE(s.Step()); |
| 133 EXPECT_EQ(13, s.ColumnInt(0)); |
| 134 EXPECT_FALSE(s.Step()); |
| 135 |
| 136 s.ResetWithoutClearingBoundVariables(); |
| 137 // Verify that we can get all rows again. |
| 138 ASSERT_TRUE(s.Step()); |
| 139 EXPECT_EQ(12, s.ColumnInt(0)); |
| 140 ASSERT_TRUE(s.Step()); |
| 141 EXPECT_EQ(13, s.ColumnInt(0)); |
| 142 EXPECT_FALSE(s.Step()); |
| 143 } |
| OLD | NEW |