Make castv2 performance test work.
[chromium-blink-merge.git] / chrome / browser / spellchecker / word_trimmer_unittest.cc
blob35b8e6a62298d9795cdca2a338bffc245bb0709e
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 "chrome/browser/spellchecker/word_trimmer.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 using base::ASCIIToUTF16;
12 TEST(WordTrimmerTest, TrimWordsEmptyText) {
13 size_t start = 0;
14 size_t end = 0;
15 EXPECT_EQ(base::string16(), TrimWords(&start, end, base::string16(), 0));
16 EXPECT_EQ(0UL, start);
19 TEST(WordTrimmerTest, TrimWordsStart) {
20 size_t start = 0;
21 size_t end = 3;
22 EXPECT_EQ(ASCIIToUTF16("one two three"),
23 TrimWords(&start, end, ASCIIToUTF16("one two three four"), 2));
24 EXPECT_EQ(0UL, start);
27 TEST(WordTrimmerTest, TrimWordsEnd) {
28 size_t start = 14;
29 size_t end = 18;
30 EXPECT_EQ(ASCIIToUTF16("two three four"),
31 TrimWords(&start, end, ASCIIToUTF16("one two three four"), 2));
32 EXPECT_EQ(10UL, start);
35 TEST(WordTrimmerTest, TrimWordsMiddle) {
36 size_t start = 14;
37 size_t end = 23;
38 EXPECT_EQ(ASCIIToUTF16("two three four five six seven"), TrimWords(
39 &start, end, ASCIIToUTF16("one two three four five six seven eight"), 2));
40 EXPECT_EQ(10UL, start);
43 TEST(WordTrimmerTest, TrimWordsEmptyKeep) {
44 size_t start = 18;
45 size_t end = 18;
46 EXPECT_EQ(ASCIIToUTF16("two three four five six"), TrimWords(
47 &start, end, ASCIIToUTF16("one two three four five six seven eight"), 2));
48 EXPECT_EQ(14UL, start);
51 TEST(WordTrimmerTest, TrimWordsOutOfBounds) {
52 size_t start = 4;
53 size_t end = 5;
54 EXPECT_EQ(ASCIIToUTF16("one"), TrimWords(
55 &start, end, ASCIIToUTF16("one"), 2));
56 EXPECT_EQ(4UL, start);
59 TEST(WordTrimmerTest, TrimWordsInvalid) {
60 size_t start = 23;
61 size_t end = 14;
62 EXPECT_EQ(ASCIIToUTF16("one two three four five six seven eight"), TrimWords(
63 &start, end, ASCIIToUTF16("one two three four five six seven eight"), 2));
64 EXPECT_EQ(23UL, start);