| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/sync/util/query_helpers.h" | |
| 6 | |
| 7 #include <limits> | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/file_util.h" | |
| 11 #include "chrome/common/sqlite_utils.h" | |
| 12 #include "chrome/test/file_test_utils.h" | |
| 13 #include "testing/gtest/include/gtest/gtest.h" | |
| 14 | |
| 15 using std::numeric_limits; | |
| 16 using std::string; | |
| 17 | |
| 18 TEST(QueryHelpers, APEncode) { | |
| 19 string test; | |
| 20 char i; | |
| 21 for (i = numeric_limits<char>::min(); i < numeric_limits<char>::max(); ++i) | |
| 22 test.push_back(i); | |
| 23 test.push_back(i); | |
| 24 const string encoded = APEncode(test); | |
| 25 const string decoded = APDecode(encoded); | |
| 26 ASSERT_EQ(test, decoded); | |
| 27 } | |
| 28 | |
| 29 TEST(QueryHelpers, TestExecFailure) { | |
| 30 FilePath test_database; | |
| 31 file_util::GetCurrentDirectory(&test_database); | |
| 32 test_database = test_database.Append( | |
| 33 FILE_PATH_LITERAL("queryhelper_test.sqlite3")); | |
| 34 // Cleanup left-over file, if present. | |
| 35 file_util::Delete(test_database, true); | |
| 36 FileAutoDeleter file_deleter(test_database); | |
| 37 { | |
| 38 sqlite3* database = NULL; | |
| 39 ASSERT_EQ(SQLITE_OK, SqliteOpen(test_database, &database)); | |
| 40 sqlite_utils::scoped_sqlite_db_ptr database_deleter(database); | |
| 41 EXPECT_EQ(SQLITE_DONE, Exec(database, "CREATE TABLE test_table (idx int)")); | |
| 42 EXPECT_NE(SQLITE_DONE, Exec(database, "ALTER TABLE test_table ADD COLUMN " | |
| 43 "broken int32 default ?", -1)); | |
| 44 } | |
| 45 } | |
| OLD | NEW |