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

Side by Side Diff: sql/meta_table_unittest.cc

Issue 1133053004: sql: Remove basictypes.h includes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: shess review Created 5 years, 7 months 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
« no previous file with comments | « sql/meta_table.cc ('k') | sql/recovery.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "sql/meta_table.h" 5 #include "sql/meta_table.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "sql/connection.h" 9 #include "sql/connection.h"
10 #include "sql/statement.h" 10 #include "sql/statement.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 EXPECT_TRUE(meta_table.Init(&db(), 1, 1)); 201 EXPECT_TRUE(meta_table.Init(&db(), 1, 1));
202 202
203 int value; 203 int value;
204 EXPECT_TRUE(meta_table.GetValue(kKey, &value)); 204 EXPECT_TRUE(meta_table.GetValue(kKey, &value));
205 EXPECT_EQ(kSecondValue, value); 205 EXPECT_EQ(kSecondValue, value);
206 } 206 }
207 } 207 }
208 208
209 TEST_F(SQLMetaTableTest, Int64Value) { 209 TEST_F(SQLMetaTableTest, Int64Value) {
210 const char kKey[] = "Int Key"; 210 const char kKey[] = "Int Key";
211 const int64 kFirstValue = 5000000017LL; 211 const int64_t kFirstValue = 5000000017LL;
212 const int64 kSecondValue = 5000000023LL; 212 const int64_t kSecondValue = 5000000023LL;
213 213
214 // Initially, the value isn't there until set. 214 // Initially, the value isn't there until set.
215 { 215 {
216 sql::MetaTable meta_table; 216 sql::MetaTable meta_table;
217 EXPECT_TRUE(meta_table.Init(&db(), 1, 1)); 217 EXPECT_TRUE(meta_table.Init(&db(), 1, 1));
218 218
219 int64 value; 219 int64_t value;
220 EXPECT_FALSE(meta_table.GetValue(kKey, &value)); 220 EXPECT_FALSE(meta_table.GetValue(kKey, &value));
221 221
222 EXPECT_TRUE(meta_table.SetValue(kKey, kFirstValue)); 222 EXPECT_TRUE(meta_table.SetValue(kKey, kFirstValue));
223 EXPECT_TRUE(meta_table.GetValue(kKey, &value)); 223 EXPECT_TRUE(meta_table.GetValue(kKey, &value));
224 EXPECT_EQ(kFirstValue, value); 224 EXPECT_EQ(kFirstValue, value);
225 } 225 }
226 226
227 // Value is persistent across different instances. 227 // Value is persistent across different instances.
228 { 228 {
229 sql::MetaTable meta_table; 229 sql::MetaTable meta_table;
230 EXPECT_TRUE(meta_table.Init(&db(), 1, 1)); 230 EXPECT_TRUE(meta_table.Init(&db(), 1, 1));
231 231
232 int64 value; 232 int64_t value;
233 EXPECT_TRUE(meta_table.GetValue(kKey, &value)); 233 EXPECT_TRUE(meta_table.GetValue(kKey, &value));
234 EXPECT_EQ(kFirstValue, value); 234 EXPECT_EQ(kFirstValue, value);
235 235
236 EXPECT_TRUE(meta_table.SetValue(kKey, kSecondValue)); 236 EXPECT_TRUE(meta_table.SetValue(kKey, kSecondValue));
237 } 237 }
238 238
239 // Existing value was successfully changed. 239 // Existing value was successfully changed.
240 { 240 {
241 sql::MetaTable meta_table; 241 sql::MetaTable meta_table;
242 EXPECT_TRUE(meta_table.Init(&db(), 1, 1)); 242 EXPECT_TRUE(meta_table.Init(&db(), 1, 1));
243 243
244 int64 value; 244 int64_t value;
245 EXPECT_TRUE(meta_table.GetValue(kKey, &value)); 245 EXPECT_TRUE(meta_table.GetValue(kKey, &value));
246 EXPECT_EQ(kSecondValue, value); 246 EXPECT_EQ(kSecondValue, value);
247 } 247 }
248 } 248 }
249 249
250 TEST_F(SQLMetaTableTest, DeleteKey) { 250 TEST_F(SQLMetaTableTest, DeleteKey) {
251 const char kKey[] = "String Key"; 251 const char kKey[] = "String Key";
252 const std::string kValue("String Value"); 252 const std::string kValue("String Value");
253 253
254 sql::MetaTable meta_table; 254 sql::MetaTable meta_table;
255 EXPECT_TRUE(meta_table.Init(&db(), 1, 1)); 255 EXPECT_TRUE(meta_table.Init(&db(), 1, 1));
256 256
257 // Value isn't present. 257 // Value isn't present.
258 std::string value; 258 std::string value;
259 EXPECT_FALSE(meta_table.GetValue(kKey, &value)); 259 EXPECT_FALSE(meta_table.GetValue(kKey, &value));
260 260
261 // Now value is present. 261 // Now value is present.
262 EXPECT_TRUE(meta_table.SetValue(kKey, kValue)); 262 EXPECT_TRUE(meta_table.SetValue(kKey, kValue));
263 EXPECT_TRUE(meta_table.GetValue(kKey, &value)); 263 EXPECT_TRUE(meta_table.GetValue(kKey, &value));
264 EXPECT_EQ(kValue, value); 264 EXPECT_EQ(kValue, value);
265 265
266 // After delete value isn't present. 266 // After delete value isn't present.
267 EXPECT_TRUE(meta_table.DeleteKey(kKey)); 267 EXPECT_TRUE(meta_table.DeleteKey(kKey));
268 EXPECT_FALSE(meta_table.GetValue(kKey, &value)); 268 EXPECT_FALSE(meta_table.GetValue(kKey, &value));
269 } 269 }
270 270
271 } // namespace 271 } // namespace
OLDNEW
« no previous file with comments | « sql/meta_table.cc ('k') | sql/recovery.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698