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 "chrome/browser/sync/util/compat-file.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 using std::numeric_limits; |
| 14 using std::string; |
| 15 |
| 16 TEST(QueryHelpers, APEncode) { |
| 17 string test; |
| 18 char i; |
| 19 for (i = numeric_limits<char>::min(); i < numeric_limits<char>::max(); ++i) |
| 20 test.push_back(i); |
| 21 test.push_back(i); |
| 22 const string encoded = APEncode(test); |
| 23 const string decoded = APDecode(encoded); |
| 24 ASSERT_EQ(test, decoded); |
| 25 } |
| 26 |
| 27 TEST(QueryHelpers, TestExecFailure) { |
| 28 sqlite3* database; |
| 29 const PathString test_database(PSTR("queryhelper_test.sqlite3")); |
| 30 PathRemove(test_database); |
| 31 ASSERT_EQ(SQLITE_OK, SqliteOpen(test_database, &database)); |
| 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 " |
| 34 "broken int32 default ?", -1)); |
| 35 PathRemove(test_database); |
| 36 } |
OLD | NEW |