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 <roubert@google.com> |
| 16 |
| 17 #include <cstddef> |
| 18 #include <string> |
| 19 |
| 20 #include <gtest/gtest.h> |
| 21 #include <re2/re2.h> |
| 22 |
| 23 #include "re2_cache.h" |
| 24 |
| 25 namespace i18n { |
| 26 namespace phonenumbers { |
| 27 |
| 28 using std::string; |
| 29 |
| 30 class RE2CacheTest : public testing::Test { |
| 31 protected: |
| 32 static const size_t min_items_ = 2; |
| 33 |
| 34 RE2CacheTest() : cache_(min_items_) {} |
| 35 virtual ~RE2CacheTest() {} |
| 36 |
| 37 RE2Cache cache_; |
| 38 }; |
| 39 |
| 40 TEST_F(RE2CacheTest, CacheConstructor) { |
| 41 ASSERT_TRUE(cache_.cache_impl_ != NULL); |
| 42 EXPECT_TRUE(cache_.cache_impl_->empty()); |
| 43 } |
| 44 |
| 45 TEST_F(RE2CacheTest, AccessConstructor) { |
| 46 static const string foo("foo"); |
| 47 RE2Cache::ScopedAccess access(&cache_, foo); |
| 48 |
| 49 EXPECT_TRUE(access.regexp_ != NULL); |
| 50 ASSERT_TRUE(cache_.cache_impl_ != NULL); |
| 51 EXPECT_EQ(1, cache_.cache_impl_->size()); |
| 52 } |
| 53 |
| 54 TEST_F(RE2CacheTest, OperatorRE2) { |
| 55 static const string foo("foo"); |
| 56 RE2Cache::ScopedAccess access(&cache_, foo); |
| 57 |
| 58 const RE2& regexp = access; |
| 59 EXPECT_EQ(foo, regexp.pattern()); |
| 60 } |
| 61 |
| 62 } // namespace phonenumbers |
| 63 } // namespace i18n |
OLD | NEW |