| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/sync/util/query_helpers.h" | 5 #include "chrome/browser/sync/util/query_helpers.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/sync/util/compat-file.h" | 10 #include "chrome/browser/sync/util/compat_file.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 using std::numeric_limits; | 13 using std::numeric_limits; |
| 14 using std::string; | 14 using std::string; |
| 15 | 15 |
| 16 TEST(QueryHelpers, APEncode) { | 16 TEST(QueryHelpers, APEncode) { |
| 17 string test; | 17 string test; |
| 18 char i; | 18 char i; |
| 19 for (i = numeric_limits<char>::min(); i < numeric_limits<char>::max(); ++i) | 19 for (i = numeric_limits<char>::min(); i < numeric_limits<char>::max(); ++i) |
| 20 test.push_back(i); | 20 test.push_back(i); |
| 21 test.push_back(i); | 21 test.push_back(i); |
| 22 const string encoded = APEncode(test); | 22 const string encoded = APEncode(test); |
| 23 const string decoded = APDecode(encoded); | 23 const string decoded = APDecode(encoded); |
| 24 ASSERT_EQ(test, decoded); | 24 ASSERT_EQ(test, decoded); |
| 25 } | 25 } |
| 26 | 26 |
| 27 TEST(QueryHelpers, TestExecFailure) { | 27 TEST(QueryHelpers, TestExecFailure) { |
| 28 sqlite3* database; | 28 sqlite3* database; |
| 29 const PathString test_database(PSTR("queryhelper_test.sqlite3")); | 29 const PathString test_database(PSTR("queryhelper_test.sqlite3")); |
| 30 PathRemove(test_database); | 30 PathRemove(test_database); |
| 31 ASSERT_EQ(SQLITE_OK, SqliteOpen(test_database, &database)); | 31 ASSERT_EQ(SQLITE_OK, SqliteOpen(test_database, &database)); |
| 32 EXPECT_EQ(SQLITE_DONE, Exec(database, "CREATE TABLE test_table (idx int)")); | 32 EXPECT_EQ(SQLITE_DONE, Exec(database, "CREATE TABLE test_table (idx int)")); |
| 33 EXPECT_NE(SQLITE_DONE, Exec(database, "ALTER TABLE test_table ADD COLUMN " | 33 EXPECT_NE(SQLITE_DONE, Exec(database, "ALTER TABLE test_table ADD COLUMN " |
| 34 "broken int32 default ?", -1)); | 34 "broken int32 default ?", -1)); |
| 35 PathRemove(test_database); | 35 PathRemove(test_database); |
| 36 } | 36 } |
| OLD | NEW |