Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: sql/statement_unittest.cc

Issue 10171014: Changed to Reset(bool clear_bound_vars) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mac build error. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sql/statement.cc ('k') | sync/syncable/directory_backing_store.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/statement_unittest.cc
diff --git a/sql/statement_unittest.cc b/sql/statement_unittest.cc
index b6b6aa8b5f9b4c184271151d1f1e0ec2397bbd9a..95fafb30e68c095702c777256d042b5aa3d2e0bf 100644
--- a/sql/statement_unittest.cc
+++ b/sql/statement_unittest.cc
@@ -88,14 +88,14 @@ TEST_F(SQLStatementTest, Run) {
// Run should fail since this produces output, and we should use Step(). This
// gets a bit wonky since sqlite says this is OK so succeeded is set.
- s.Reset();
+ s.Reset(true);
s.BindInt(0, 3);
EXPECT_FALSE(s.Run());
EXPECT_EQ(SQLITE_ROW, db().GetErrorCode());
EXPECT_TRUE(s.Succeeded());
// Resetting it should put it back to the previous state (not runnable).
- s.Reset();
+ s.Reset(true);
EXPECT_FALSE(s.Succeeded());
// Binding and stepping should produce one row.
@@ -120,3 +120,25 @@ TEST_F(SQLStatementTest, BasicErrorCallback) {
EXPECT_EQ(SQLITE_MISMATCH, sqlite_error());
reset_error();
}
+
+TEST_F(SQLStatementTest, Reset) {
+ ASSERT_TRUE(db().Execute("CREATE TABLE foo (a, b)"));
+ ASSERT_TRUE(db().Execute("INSERT INTO foo (a, b) VALUES (3, 12)"));
+ ASSERT_TRUE(db().Execute("INSERT INTO foo (a, b) VALUES (4, 13)"));
+
+ sql::Statement s(db().GetUniqueStatement(
+ "SELECT b FROM foo WHERE a = ? "));
+ s.BindInt(0, 3);
+ ASSERT_TRUE(s.Step());
+ EXPECT_EQ(12, s.ColumnInt(0));
+ ASSERT_FALSE(s.Step());
+
+ s.Reset(false);
+ // Verify that we can get all rows again.
+ ASSERT_TRUE(s.Step());
+ EXPECT_EQ(12, s.ColumnInt(0));
+ EXPECT_FALSE(s.Step());
+
+ s.Reset(true);
+ ASSERT_FALSE(s.Step());
+}
« no previous file with comments | « sql/statement.cc ('k') | sync/syncable/directory_backing_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698