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

Side by Side Diff: ui/gfx/utf16_indexing_unittest.cc

Issue 23769011: Move a bunch of windows stuff from ui/base/win to ui/gfx/win (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moar bustage. Created 7 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 | « ui/gfx/utf16_indexing.cc ('k') | ui/gfx/win/dpi.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "ui/base/text/utf16_indexing.h" 6 #include "ui/gfx/utf16_indexing.h"
7 7
8 namespace ui { 8 namespace gfx {
9 9
10 TEST(UTF16IndexingTest, IndexOffsetConversions) { 10 TEST(UTF16IndexingTest, IndexOffsetConversions) {
11 // Valid surrogate pair surrounded by unpaired surrogates 11 // Valid surrogate pair surrounded by unpaired surrogates
12 const char16 foo[] = {0xDC00, 0xD800, 0xD800, 0xDFFF, 0xDFFF, 0xDBFF, 0}; 12 const char16 foo[] = {0xDC00, 0xD800, 0xD800, 0xDFFF, 0xDFFF, 0xDBFF, 0};
13 const string16 s(foo); 13 const string16 s(foo);
14 const size_t the_invalid_index = 3; 14 const size_t the_invalid_index = 3;
15 for (size_t i = 0; i <= s.length(); ++i) 15 for (size_t i = 0; i <= s.length(); ++i)
16 EXPECT_EQ(i != the_invalid_index, IsValidCodePointIndex(s, i)); 16 EXPECT_EQ(i != the_invalid_index, IsValidCodePointIndex(s, i));
17 for (size_t i = 0; i <= s.length(); ++i) { 17 for (size_t i = 0; i <= s.length(); ++i) {
18 for (size_t j = i; j <= s.length(); ++j) { 18 for (size_t j = i; j <= s.length(); ++j) {
19 ptrdiff_t offset = static_cast<ptrdiff_t>(j - i); 19 ptrdiff_t offset = static_cast<ptrdiff_t>(j - i);
20 if (i <= the_invalid_index && j > the_invalid_index) 20 if (i <= the_invalid_index && j > the_invalid_index)
21 --offset; 21 --offset;
22 EXPECT_EQ(offset, UTF16IndexToOffset(s, i, j)); 22 EXPECT_EQ(offset, UTF16IndexToOffset(s, i, j));
23 EXPECT_EQ(-offset, UTF16IndexToOffset(s, j, i)); 23 EXPECT_EQ(-offset, UTF16IndexToOffset(s, j, i));
24 size_t adjusted_j = (j == the_invalid_index) ? j + 1 : j; 24 size_t adjusted_j = (j == the_invalid_index) ? j + 1 : j;
25 EXPECT_EQ(adjusted_j, UTF16OffsetToIndex(s, i, offset)); 25 EXPECT_EQ(adjusted_j, UTF16OffsetToIndex(s, i, offset));
26 size_t adjusted_i = (i == the_invalid_index) ? i + 1 : i; 26 size_t adjusted_i = (i == the_invalid_index) ? i + 1 : i;
27 EXPECT_EQ(adjusted_i, UTF16OffsetToIndex(s, j, -offset)); 27 EXPECT_EQ(adjusted_i, UTF16OffsetToIndex(s, j, -offset));
28 } 28 }
29 } 29 }
30 } 30 }
31 31
32 } // namespace ui 32 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/utf16_indexing.cc ('k') | ui/gfx/win/dpi.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698