Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / gfx / range / range_win_unittest.cc
blobf7a442c5bbfdf311df44be3a337a1b5ce572df36
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
3 // found in the LICENSE file.
5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "ui/gfx/range/range.h"
8 TEST(RangeTest, FromCHARRANGE) {
9 CHARRANGE cr = { 10, 32 };
10 gfx::Range r(cr, 50);
11 EXPECT_EQ(10U, r.start());
12 EXPECT_EQ(32U, r.end());
13 EXPECT_EQ(22U, r.length());
14 EXPECT_FALSE(r.is_reversed());
15 EXPECT_TRUE(r.IsValid());
18 TEST(RangeTest, FromReversedCHARRANGE) {
19 CHARRANGE cr = { 20, 10 };
20 gfx::Range r(cr, 40);
21 EXPECT_EQ(20U, r.start());
22 EXPECT_EQ(10U, r.end());
23 EXPECT_EQ(10U, r.length());
24 EXPECT_TRUE(r.is_reversed());
25 EXPECT_TRUE(r.IsValid());
28 TEST(RangeTest, FromCHARRANGETotal) {
29 CHARRANGE cr = { 0, -1 };
30 gfx::Range r(cr, 20);
31 EXPECT_EQ(0U, r.start());
32 EXPECT_EQ(20U, r.end());
33 EXPECT_EQ(20U, r.length());
34 EXPECT_FALSE(r.is_reversed());
35 EXPECT_TRUE(r.IsValid());
38 TEST(RangeTest, ToCHARRANGE) {
39 gfx::Range r(10, 30);
40 CHARRANGE cr = r.ToCHARRANGE();
41 EXPECT_EQ(10, cr.cpMin);
42 EXPECT_EQ(30, cr.cpMax);
45 TEST(RangeTest, ReversedToCHARRANGE) {
46 gfx::Range r(20, 10);
47 CHARRANGE cr = r.ToCHARRANGE();
48 EXPECT_EQ(20U, cr.cpMin);
49 EXPECT_EQ(10U, cr.cpMax);
52 TEST(RangeTest, FromCHARRANGEInvalid) {
53 CHARRANGE cr = { -1, -1 };
54 gfx::Range r(cr, 30);
55 EXPECT_FALSE(r.IsValid());
58 TEST(RangeTest, ToCHARRANGEInvalid) {
59 gfx::Range r(gfx::Range::InvalidRange());
60 CHARRANGE cr = r.ToCHARRANGE();
61 EXPECT_EQ(-1, cr.cpMin);
62 EXPECT_EQ(-1, cr.cpMax);