OLD | NEW |
| (Empty) |
1 // Copyright (C) 2011 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 | |
15 // Author: Fredrik Roubert | |
16 | |
17 #include <cstddef> | |
18 #include <string> | |
19 | |
20 #include <gtest/gtest.h> | |
21 | |
22 #include "regexp_adapter.h" | |
23 #include "regexp_cache.h" | |
24 | |
25 namespace i18n { | |
26 namespace phonenumbers { | |
27 | |
28 using std::string; | |
29 | |
30 class RegExpCacheTest : public testing::Test { | |
31 protected: | |
32 static const size_t min_items_ = 2; | |
33 | |
34 RegExpCacheTest() : cache_(min_items_) {} | |
35 virtual ~RegExpCacheTest() {} | |
36 | |
37 RegExpCache cache_; | |
38 }; | |
39 | |
40 TEST_F(RegExpCacheTest, CacheConstructor) { | |
41 ASSERT_TRUE(cache_.cache_impl_ != NULL); | |
42 EXPECT_TRUE(cache_.cache_impl_->empty()); | |
43 } | |
44 | |
45 TEST_F(RegExpCacheTest, GetRegExp) { | |
46 static const string pattern1("foo"); | |
47 static const string pattern2("foo"); | |
48 | |
49 const RegExp& regexp1 = cache_.GetRegExp(pattern1); | |
50 // "foo" has been cached therefore we must get the same object. | |
51 const RegExp& regexp2 = cache_.GetRegExp(pattern2); | |
52 | |
53 EXPECT_TRUE(®exp1 == ®exp2); | |
54 } | |
55 | |
56 } // namespace phonenumbers | |
57 } // namespace i18n | |
OLD | NEW |