[MacViews] Show comboboxes with a native NSMenu
[chromium-blink-merge.git] / content / common / indexed_db / indexed_db_key_unittest.cc
blobf908f6031b5d6e4a87121349b86767dc27b30f39
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
3 // found in the LICENSE file.
5 #include <vector>
7 #include "base/basictypes.h"
8 #include "base/strings/string16.h"
9 #include "content/common/indexed_db/indexed_db_key.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 namespace content {
14 namespace {
16 TEST(IndexedDBKeyTest, KeySizeEstimates) {
17 std::vector<IndexedDBKey> keys;
18 std::vector<size_t> estimates;
20 keys.push_back(IndexedDBKey());
21 estimates.push_back(16u); // Overhead.
23 keys.push_back(IndexedDBKey(blink::WebIDBKeyTypeNull));
24 estimates.push_back(16u);
26 double number = 3.14159;
27 keys.push_back(IndexedDBKey(number, blink::WebIDBKeyTypeNumber));
28 estimates.push_back(24u); // Overhead + sizeof(double).
30 double date = 1370884329.0;
31 keys.push_back(IndexedDBKey(date, blink::WebIDBKeyTypeDate));
32 estimates.push_back(24u); // Overhead + sizeof(double).
34 const base::string16 string(1024, static_cast<base::char16>('X'));
35 keys.push_back(IndexedDBKey(string));
36 // Overhead + string length * sizeof(base::char16).
37 estimates.push_back(2064u);
39 const size_t array_size = 1024;
40 IndexedDBKey::KeyArray array;
41 double value = 123.456;
42 for (size_t i = 0; i < array_size; ++i) {
43 array.push_back(IndexedDBKey(value, blink::WebIDBKeyTypeNumber));
45 keys.push_back(IndexedDBKey(array));
46 // Overhead + array length * (Overhead + sizeof(double)).
47 estimates.push_back(24592u);
49 ASSERT_EQ(keys.size(), estimates.size());
50 for (size_t i = 0; i < keys.size(); ++i) {
51 EXPECT_EQ(estimates[i], keys[i].size_estimate());
55 } // namespace
57 } // namespace content