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 "app/sql/connection.h" | |
8 #include "app/sql/statement.h" | |
9 #include "base/file_util.h" | 7 #include "base/file_util.h" |
10 #include "base/scoped_temp_dir.h" | 8 #include "base/scoped_temp_dir.h" |
| 9 #include "sql/connection.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 class StatementErrorHandler : public sql::ErrorDelegate { | 14 class StatementErrorHandler : public sql::ErrorDelegate { |
15 public: | 15 public: |
16 StatementErrorHandler() : error_(SQLITE_OK) {} | 16 StatementErrorHandler() : error_(SQLITE_OK) {} |
17 | 17 |
18 virtual int OnError(int error, sql::Connection* connection, | 18 virtual int OnError(int error, sql::Connection* connection, |
19 sql::Statement* stmt) { | 19 sql::Statement* stmt) { |
20 error_ = error; | 20 error_ = error; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // Insert in the foo table the primary key. It is an error to insert | 117 // Insert in the foo table the primary key. It is an error to insert |
118 // something other than an number. This error causes the error callback | 118 // something other than an number. This error causes the error callback |
119 // handler to be called with SQLITE_MISMATCH as error code. | 119 // handler to be called with SQLITE_MISMATCH as error code. |
120 sql::Statement s(db().GetUniqueStatement("INSERT INTO foo (a) VALUES (?)")); | 120 sql::Statement s(db().GetUniqueStatement("INSERT INTO foo (a) VALUES (?)")); |
121 EXPECT_TRUE(s.is_valid()); | 121 EXPECT_TRUE(s.is_valid()); |
122 s.BindCString(0, "bad bad"); | 122 s.BindCString(0, "bad bad"); |
123 EXPECT_FALSE(s.Run()); | 123 EXPECT_FALSE(s.Run()); |
124 EXPECT_EQ(SQLITE_MISMATCH, sqlite_error()); | 124 EXPECT_EQ(SQLITE_MISMATCH, sqlite_error()); |
125 reset_error(); | 125 reset_error(); |
126 } | 126 } |
OLD | NEW |