summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/util/query_helpers_unittest.cc
blob: 0fb86e2ff36a485c27611991586d51aab5bf66c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/sync/util/query_helpers.h"

#include <limits>
#include <string>

#include "chrome/browser/sync/util/compat_file.h"
#include "testing/gtest/include/gtest/gtest.h"

using std::numeric_limits;
using std::string;

TEST(QueryHelpers, APEncode) {
  string test;
  char i;
  for (i = numeric_limits<char>::min(); i < numeric_limits<char>::max(); ++i)
    test.push_back(i);
  test.push_back(i);
  const string encoded = APEncode(test);
  const string decoded = APDecode(encoded);
  ASSERT_EQ(test, decoded);
}

TEST(QueryHelpers, TestExecFailure) {
  sqlite3* database;
  const PathString test_database(PSTR("queryhelper_test.sqlite3"));
  PathRemove(test_database);
  ASSERT_EQ(SQLITE_OK, SqliteOpen(test_database, &database));
  EXPECT_EQ(SQLITE_DONE, Exec(database, "CREATE TABLE test_table (idx int)"));
  EXPECT_NE(SQLITE_DONE, Exec(database, "ALTER TABLE test_table ADD COLUMN "
      "broken int32 default ?", -1));
  PathRemove(test_database);
}