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