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

Side by Side Diff: courgette/consecutive_range_visitor_unittest.cc

Issue 1491703003: [Courgette] Initial Implementation of LabelManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync. Created 5 years 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
« no previous file with comments | « courgette/consecutive_range_visitor.h ('k') | courgette/courgette.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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 "courgette/consecutive_range_visitor.h"
6
7 #include <string>
8
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace courgette {
12
13 TEST(ConsecutiveRangeVisitorTest, Basic) {
14 std::string s = "AAAAABZZZZOO";
15 ConsecutiveRangeVisitor<std::string::iterator> vis(s.begin(), s.end());
16 EXPECT_TRUE(vis.has_more());
17 EXPECT_EQ('A', *vis.cur());
18 EXPECT_EQ(5U, vis.repeat());
19 vis.advance();
20
21 EXPECT_TRUE(vis.has_more());
22 EXPECT_EQ('B', *vis.cur());
23 EXPECT_EQ(1U, vis.repeat());
24 vis.advance();
25
26 EXPECT_TRUE(vis.has_more());
27 EXPECT_EQ('Z', *vis.cur());
28 EXPECT_EQ(4U, vis.repeat());
29 vis.advance();
30
31 EXPECT_TRUE(vis.has_more());
32 EXPECT_EQ('O', *vis.cur());
33 EXPECT_EQ(2U, vis.repeat());
34 vis.advance();
35
36 EXPECT_FALSE(vis.has_more());
37 }
38
39 TEST(ConsecutiveRangeVisitorTest, UnitRanges) {
40 // Unsorted, no consecutive characters.
41 const char s[] = "elephant elephant";
42 ConsecutiveRangeVisitor<const char*> vis(std::begin(s), std::end(s) - 1);
43 for (const char* scan = &s[0]; *scan; ++scan) {
44 EXPECT_TRUE(vis.has_more());
45 EXPECT_EQ(*scan, *vis.cur());
46 EXPECT_EQ(1U, vis.repeat());
47 vis.advance();
48 }
49 EXPECT_FALSE(vis.has_more());
50 }
51
52 TEST(ConsecutiveRangeVisitorTest, SingleRange) {
53 for (size_t len = 1U; len < 10U; ++len) {
54 std::vector<int> v(len, 137);
55 ConsecutiveRangeVisitor<std::vector<int>::iterator> vis(v.begin(), v.end());
56 EXPECT_TRUE(vis.has_more());
57 EXPECT_EQ(137, *vis.cur());
58 EXPECT_EQ(len, vis.repeat());
59 vis.advance();
60 EXPECT_FALSE(vis.has_more());
61 }
62 }
63
64 TEST(ConsecutiveRangeVisitorTest, Empty) {
65 std::string s;
66 ConsecutiveRangeVisitor<std::string::iterator> vis(s.begin(), s.end());
67 EXPECT_FALSE(vis.has_more());
68 }
69
70 } // namespace courgette
OLDNEW
« no previous file with comments | « courgette/consecutive_range_visitor.h ('k') | courgette/courgette.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698