1 // Copyright (C) 2014 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 #include <libaddressinput/region_data.h> 16 17 #include <string> 18 19 #include <gtest/gtest.h> 20 21 namespace { 22 23 using i18n::addressinput::RegionData; 24 25 TEST(RegionDataTest, NoParentByDefault) { 26 static const std::string kEmpty; 27 RegionData region(kEmpty); 28 EXPECT_FALSE(region.has_parent()); 29 } 30 31 TEST(RegionDataTest, NoSubRegionsByDefault) { 32 static const std::string kEmpty; 33 RegionData region(kEmpty); 34 EXPECT_TRUE(region.sub_regions().empty()); 35 } 36 37 TEST(RegionDataTest, SubRegionGetsParent) { 38 static const std::string kEmpty; 39 RegionData region(kEmpty); 40 region.AddSubRegion(kEmpty, kEmpty); 41 ASSERT_EQ(1U, region.sub_regions().size()); 42 ASSERT_TRUE(region.sub_regions()[0] != NULL); 43 EXPECT_EQ(®ion, ®ion.sub_regions()[0]->parent()); 44 } 45 46 } // namespace 47