~ubuntu-branches/ubuntu/oneiric/mozc/oneiric

« back to all changes in this revision

Viewing changes to storage/lru_storage_test.cc

  • Committer: Bazaar Package Importer
  • Author(s): Nobuhiro Iwamatsu
  • Date: 2010-07-14 03:26:47 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100714032647-13qjisj6m8cm8jdx
Tags: 0.12.410.102-1
* New upstream release (Closes: #588971).
  - Add mozc-server, mozc-utils-gui and scim-mozc packages.
* Update debian/rules.
  Add --gypdir option to build_mozc.py.
* Update debian/control.
  - Bumped standards-version to 3.9.0.
  - Update description.
* Add mozc icon (Closes: #588972).
* Add patch which revises issue 18.
  ibus_mozc_issue18.patch
* kFreeBSD build support.
  support_kfreebsd.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
#include "testing/base/public/gunit.h"
42
42
 
43
43
namespace mozc {
44
 
 
 
44
namespace {
45
45
int Random(int size) {
46
46
  return 1 + static_cast<int> (1.0 * size * rand() / (RAND_MAX + 1.0));
47
47
}
93
93
    EXPECT_TRUE(v2 == NULL);
94
94
  }
95
95
}
96
 
 
97
 
TEST(LRUStorageTest, LRUStorageTest) {
 
96
}  // anonymous namespace
 
97
 
 
98
class LRUStorageTest : public testing::Test {
 
99
 protected:
 
100
  LRUStorageTest() {}
 
101
 
 
102
  virtual void SetUp() {
 
103
    UnlinkDBFileIfExists();
 
104
  }
 
105
 
 
106
  virtual void TearDown() {
 
107
    UnlinkDBFileIfExists();
 
108
  }
 
109
 
 
110
  static void UnlinkDBFileIfExists() {
 
111
    const string path = GetTemporaryFilePath();
 
112
    if (Util::FileExists(path)) {
 
113
      Util::Unlink(path);
 
114
    }
 
115
  }
 
116
 
 
117
  static string GetTemporaryFilePath() {
 
118
    // This name should be unique to each test.
 
119
    return Util::JoinPath(FLAGS_test_tmpdir, "LRUStorageTest_test.db");
 
120
  }
 
121
 
 
122
 private:
 
123
  DISALLOW_COPY_AND_ASSIGN(LRUStorageTest);
 
124
};
 
125
 
 
126
TEST_F(LRUStorageTest, LRUStorageTest) {
98
127
  static const int kSize[] = {10, 100, 1000, 10000};
99
 
  const string file = FLAGS_test_tmpdir + "/test.db";
 
128
  const string file = GetTemporaryFilePath();
100
129
  for (int i = 0; i < arraysize(kSize); ++i) {
101
130
    LRUStorage::CreateStorageFile(file.c_str(), 4, kSize[i], 0x76fef);
102
131
    LRUStorage storage;
107
136
  }
108
137
}
109
138
 
110
 
TEST(LRUStorageTest, LRUStoragOpenOrCreate) {
111
 
  const string file = FLAGS_test_tmpdir + "/test2.db";
 
139
class LRUStoragOpenOrCreateTest : public testing::Test {
 
140
 protected:
 
141
  LRUStoragOpenOrCreateTest() {}
 
142
 
 
143
  virtual void SetUp() {
 
144
    UnlinkDBFileIfExists();
 
145
  }
 
146
 
 
147
  virtual void TearDown() {
 
148
    UnlinkDBFileIfExists();
 
149
  }
 
150
 
 
151
  static void UnlinkDBFileIfExists() {
 
152
    const string path = GetTemporaryFilePath();
 
153
    if (Util::FileExists(path)) {
 
154
      Util::Unlink(path);
 
155
    }
 
156
  }
 
157
 
 
158
  static string GetTemporaryFilePath() {
 
159
    // This name should be unique to each test.
 
160
    return Util::JoinPath(FLAGS_test_tmpdir,
 
161
                          "LRUStoragOpenOrCreateTest_test.db");
 
162
  }
 
163
 private:
 
164
  DISALLOW_COPY_AND_ASSIGN(LRUStoragOpenOrCreateTest);
 
165
};
 
166
 
 
167
TEST_F(LRUStoragOpenOrCreateTest, LRUStoragOpenOrCreateTest) {
 
168
  const string file = GetTemporaryFilePath();
112
169
  {
113
170
    OutputFileStream ofs(file.c_str());
114
171
    ofs << "test";
129
186
    CHECK_EQ(v, *result);
130
187
  }
131
188
}
132
 
}  // mozc
 
189
}  // namespace mozc