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

Side by Side Diff: ui/base/text/bytes_formatting_unittest.cc

Issue 7719007: Add a gyp flag to enable dcheck by default in release without (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_protocol_test.cc ('k') | ui/gfx/rect_unittest.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "ui/base/text/bytes_formatting.h" 7 #include "ui/base/text/bytes_formatting.h"
8 8
9 namespace ui { 9 namespace ui {
10 10
11 TEST(BytesFormattingTest, GetByteDisplayUnits) { 11 TEST(BytesFormattingTest, GetByteDisplayUnits) {
12 static const struct { 12 static const struct {
13 int64 bytes; 13 int64 bytes;
14 DataUnits expected; 14 DataUnits expected;
15 } cases[] = { 15 } cases[] = {
16 {0, DATA_UNITS_BYTE}, 16 {0, DATA_UNITS_BYTE},
17 {512, DATA_UNITS_BYTE}, 17 {512, DATA_UNITS_BYTE},
18 {10*1024, DATA_UNITS_KIBIBYTE}, 18 {10*1024, DATA_UNITS_KIBIBYTE},
19 {10*1024*1024, DATA_UNITS_MEBIBYTE}, 19 {10*1024*1024, DATA_UNITS_MEBIBYTE},
20 {10LL*1024*1024*1024, DATA_UNITS_GIBIBYTE}, 20 {10LL*1024*1024*1024, DATA_UNITS_GIBIBYTE},
21 {10LL*1024*1024*1024*1024, DATA_UNITS_TEBIBYTE}, 21 {10LL*1024*1024*1024*1024, DATA_UNITS_TEBIBYTE},
22 {~(1LL<<63), DATA_UNITS_PEBIBYTE}, 22 {~(1LL<<63), DATA_UNITS_PEBIBYTE},
23 #ifdef NDEBUG 23 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
24 {-1, DATA_UNITS_BYTE}, 24 {-1, DATA_UNITS_BYTE},
25 #endif 25 #endif
26 }; 26 };
27 27
28 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) 28 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i)
29 EXPECT_EQ(cases[i].expected, GetByteDisplayUnits(cases[i].bytes)); 29 EXPECT_EQ(cases[i].expected, GetByteDisplayUnits(cases[i].bytes));
30 } 30 }
31 31
32 TEST(BytesFormattingTest, FormatBytes) { 32 TEST(BytesFormattingTest, FormatBytes) {
33 static const struct { 33 static const struct {
(...skipping 22 matching lines...) Expand all
56 {~(1LL<<63), DATA_UNITS_GIBIBYTE, "8,589,934,592", "8,589,934,592 GB"}, 56 {~(1LL<<63), DATA_UNITS_GIBIBYTE, "8,589,934,592", "8,589,934,592 GB"},
57 {~(1LL<<63), DATA_UNITS_PEBIBYTE, "8,192", "8,192 PB"}, 57 {~(1LL<<63), DATA_UNITS_PEBIBYTE, "8,192", "8,192 PB"},
58 58
59 {99*1024 + 103, DATA_UNITS_KIBIBYTE, "99.1", "99.1 kB"}, 59 {99*1024 + 103, DATA_UNITS_KIBIBYTE, "99.1", "99.1 kB"},
60 {1024*1024 + 103, DATA_UNITS_KIBIBYTE, "1,024", "1,024 kB"}, 60 {1024*1024 + 103, DATA_UNITS_KIBIBYTE, "1,024", "1,024 kB"},
61 {1024*1024 + 205 * 1024, DATA_UNITS_MEBIBYTE, "1.2", "1.2 MB"}, 61 {1024*1024 + 205 * 1024, DATA_UNITS_MEBIBYTE, "1.2", "1.2 MB"},
62 {1024*1024*1024 + (927 * 1024*1024), DATA_UNITS_GIBIBYTE, 62 {1024*1024*1024 + (927 * 1024*1024), DATA_UNITS_GIBIBYTE,
63 "1.9", "1.9 GB"}, 63 "1.9", "1.9 GB"},
64 {10LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, "10.0", "10.0 GB"}, 64 {10LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, "10.0", "10.0 GB"},
65 {100LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, "100", "100 GB"}, 65 {100LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, "100", "100 GB"},
66 #ifdef NDEBUG 66 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
67 {-1, DATA_UNITS_BYTE, "", ""}, 67 {-1, DATA_UNITS_BYTE, "", ""},
68 #endif 68 #endif
69 }; 69 };
70 70
71 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 71 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
72 EXPECT_EQ(ASCIIToUTF16(cases[i].expected), 72 EXPECT_EQ(ASCIIToUTF16(cases[i].expected),
73 FormatBytesWithUnits(cases[i].bytes, cases[i].units, false)); 73 FormatBytesWithUnits(cases[i].bytes, cases[i].units, false));
74 EXPECT_EQ(ASCIIToUTF16(cases[i].expected_with_units), 74 EXPECT_EQ(ASCIIToUTF16(cases[i].expected_with_units),
75 FormatBytesWithUnits(cases[i].bytes, cases[i].units, true)); 75 FormatBytesWithUnits(cases[i].bytes, cases[i].units, true));
76 } 76 }
77 } 77 }
78 78
79 } // namespace ui 79 } // namespace ui
OLDNEW
« no previous file with comments | « net/spdy/spdy_protocol_test.cc ('k') | ui/gfx/rect_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698