Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: chrome/browser/sync/util/query_helpers_unittest.cc

Issue 340055: String cleanup in sync code (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/util/query_helpers.cc ('k') | chrome/browser/sync/util/sync_types.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/file_util.h"
11 #include "chrome/common/sqlite_utils.h"
12 #include "chrome/test/file_test_utils.h"
11 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
12 14
13 using std::numeric_limits; 15 using std::numeric_limits;
14 using std::string; 16 using std::string;
15 17
16 TEST(QueryHelpers, APEncode) { 18 TEST(QueryHelpers, APEncode) {
17 string test; 19 string test;
18 char i; 20 char i;
19 for (i = numeric_limits<char>::min(); i < numeric_limits<char>::max(); ++i) 21 for (i = numeric_limits<char>::min(); i < numeric_limits<char>::max(); ++i)
20 test.push_back(i); 22 test.push_back(i);
21 test.push_back(i); 23 test.push_back(i);
22 const string encoded = APEncode(test); 24 const string encoded = APEncode(test);
23 const string decoded = APDecode(encoded); 25 const string decoded = APDecode(encoded);
24 ASSERT_EQ(test, decoded); 26 ASSERT_EQ(test, decoded);
25 } 27 }
26 28
27 TEST(QueryHelpers, TestExecFailure) { 29 TEST(QueryHelpers, TestExecFailure) {
28 sqlite3* database; 30 FilePath test_database;
29 const PathString test_database(PSTR("queryhelper_test.sqlite3")); 31 file_util::GetCurrentDirectory(&test_database);
30 PathRemove(test_database); 32 test_database = test_database.Append(
31 ASSERT_EQ(SQLITE_OK, SqliteOpen(test_database, &database)); 33 FILE_PATH_LITERAL("queryhelper_test.sqlite3"));
32 EXPECT_EQ(SQLITE_DONE, Exec(database, "CREATE TABLE test_table (idx int)")); 34 // Cleanup left-over file, if present.
33 EXPECT_NE(SQLITE_DONE, Exec(database, "ALTER TABLE test_table ADD COLUMN " 35 file_util::Delete(test_database, true);
34 "broken int32 default ?", -1)); 36 FileAutoDeleter file_deleter(test_database);
35 PathRemove(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 }
36 } 45 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/util/query_helpers.cc ('k') | chrome/browser/sync/util/sync_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698