OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "testing/gtest/include/gtest/gtest.h" | |
6 #include "ui/base/range/range.h" | |
7 | |
8 TEST(RangeTest, FromCHARRANGE) { | |
9 CHARRANGE cr = { 10, 32 }; | |
10 ui::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()); | |
16 } | |
17 | |
18 TEST(RangeTest, FromReversedCHARRANGE) { | |
19 CHARRANGE cr = { 20, 10 }; | |
20 ui::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()); | |
26 } | |
27 | |
28 TEST(RangeTest, FromCHARRANGETotal) { | |
29 CHARRANGE cr = { 0, -1 }; | |
30 ui::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()); | |
36 } | |
37 | |
38 TEST(RangeTest, ToCHARRANGE) { | |
39 ui::Range r(10, 30); | |
40 CHARRANGE cr = r.ToCHARRANGE(); | |
41 EXPECT_EQ(10, cr.cpMin); | |
42 EXPECT_EQ(30, cr.cpMax); | |
43 } | |
44 | |
45 TEST(RangeTest, ReversedToCHARRANGE) { | |
46 ui::Range r(20, 10); | |
47 CHARRANGE cr = r.ToCHARRANGE(); | |
48 EXPECT_EQ(20U, cr.cpMin); | |
49 EXPECT_EQ(10U, cr.cpMax); | |
50 } | |
51 | |
52 TEST(RangeTest, FromCHARRANGEInvalid) { | |
53 CHARRANGE cr = { -1, -1 }; | |
54 ui::Range r(cr, 30); | |
55 EXPECT_FALSE(r.IsValid()); | |
56 } | |
57 | |
58 TEST(RangeTest, ToCHARRANGEInvalid) { | |
59 ui::Range r(ui::Range::InvalidRange()); | |
60 CHARRANGE cr = r.ToCHARRANGE(); | |
61 EXPECT_EQ(-1, cr.cpMin); | |
62 EXPECT_EQ(-1, cr.cpMax); | |
63 } | |
OLD | NEW |