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/base/range/range.h"
8 TEST(RangeTest, FromNSRange) {
9 NSRange nsr = NSMakeRange(10, 3);
11 EXPECT_EQ(nsr.location, r.start());
12 EXPECT_EQ(13U, r.end());
13 EXPECT_EQ(nsr.length, r.length());
14 EXPECT_FALSE(r.is_reversed());
15 EXPECT_TRUE(r.IsValid());
18 TEST(RangeTest, ToNSRange) {
20 NSRange nsr = r.ToNSRange();
21 EXPECT_EQ(10U, nsr.location);
22 EXPECT_EQ(2U, nsr.length);
25 TEST(RangeTest, ReversedToNSRange) {
27 NSRange nsr = r.ToNSRange();
28 EXPECT_EQ(10U, nsr.location);
29 EXPECT_EQ(10U, nsr.length);
32 TEST(RangeTest, FromNSRangeInvalid) {
33 NSRange nsr = NSMakeRange(NSNotFound, 0);
35 EXPECT_FALSE(r.IsValid());
38 TEST(RangeTest, ToNSRangeInvalid) {
39 ui::Range r(ui::Range::InvalidRange());
40 NSRange nsr = r.ToNSRange();
41 EXPECT_EQ(NSNotFound, nsr.location);
42 EXPECT_EQ(0U, nsr.length);