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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/files/scoped_file.h" | 7 #include "base/files/scoped_file.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "sql/connection.h" | 10 #include "sql/connection.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 EXPECT_TRUE(db().DoesTableExist("FOO")); | 191 EXPECT_TRUE(db().DoesTableExist("FOO")); |
192 EXPECT_TRUE(db().DoesColumnExist("FOO", "A")); | 192 EXPECT_TRUE(db().DoesColumnExist("FOO", "A")); |
193 } | 193 } |
194 | 194 |
195 TEST_F(SQLConnectionTest, GetLastInsertRowId) { | 195 TEST_F(SQLConnectionTest, GetLastInsertRowId) { |
196 ASSERT_TRUE(db().Execute("CREATE TABLE foo (id INTEGER PRIMARY KEY, value)")); | 196 ASSERT_TRUE(db().Execute("CREATE TABLE foo (id INTEGER PRIMARY KEY, value)")); |
197 | 197 |
198 ASSERT_TRUE(db().Execute("INSERT INTO foo (value) VALUES (12)")); | 198 ASSERT_TRUE(db().Execute("INSERT INTO foo (value) VALUES (12)")); |
199 | 199 |
200 // Last insert row ID should be valid. | 200 // Last insert row ID should be valid. |
201 int64 row = db().GetLastInsertRowId(); | 201 int64_t row = db().GetLastInsertRowId(); |
202 EXPECT_LT(0, row); | 202 EXPECT_LT(0, row); |
203 | 203 |
204 // It should be the primary key of the row we just inserted. | 204 // It should be the primary key of the row we just inserted. |
205 sql::Statement s(db().GetUniqueStatement("SELECT value FROM foo WHERE id=?")); | 205 sql::Statement s(db().GetUniqueStatement("SELECT value FROM foo WHERE id=?")); |
206 s.BindInt64(0, row); | 206 s.BindInt64(0, row); |
207 ASSERT_TRUE(s.Step()); | 207 ASSERT_TRUE(s.Step()); |
208 EXPECT_EQ(12, s.ColumnInt(0)); | 208 EXPECT_EQ(12, s.ColumnInt(0)); |
209 } | 209 } |
210 | 210 |
211 TEST_F(SQLConnectionTest, Rollback) { | 211 TEST_F(SQLConnectionTest, Rollback) { |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 EXPECT_LT(1u, messages.size()); | 899 EXPECT_LT(1u, messages.size()); |
900 EXPECT_NE(kOk, messages[0]); | 900 EXPECT_NE(kOk, messages[0]); |
901 ASSERT_TRUE(ignore_errors.CheckIgnoredErrors()); | 901 ASSERT_TRUE(ignore_errors.CheckIgnoredErrors()); |
902 } | 902 } |
903 | 903 |
904 // TODO(shess): CorruptTableOrIndex could be used to produce a | 904 // TODO(shess): CorruptTableOrIndex could be used to produce a |
905 // file that would pass the quick check and fail the full check. | 905 // file that would pass the quick check and fail the full check. |
906 } | 906 } |
907 | 907 |
908 } // namespace | 908 } // namespace |
OLD | NEW |