1
// Copyright 2005 Google Inc. All Rights Reserved.
3
#include "s2pointregion.h"
5
#include "testing/base/public/gunit.h"
6
#include "util/coding/coder.h"
9
#include "s2latlngrect.h"
13
TEST(S2PointRegionTest, Basic) {
16
EXPECT_EQ(r0.point(), p);
17
EXPECT_TRUE(r0.Contains(p));
18
EXPECT_TRUE(r0.VirtualContainsPoint(p));
19
EXPECT_TRUE(r0.VirtualContainsPoint(r0.point()));
20
EXPECT_FALSE(r0.VirtualContainsPoint(S2Point(1, 0, 1)));
21
scoped_ptr<S2PointRegion> r0_clone(r0.Clone());
22
EXPECT_EQ(r0_clone->point(), r0.point());
23
EXPECT_EQ(r0.GetCapBound(), S2Cap::FromAxisHeight(p, 0));
25
EXPECT_EQ(r0.GetRectBound(), S2LatLngRect(ll, ll));
27
// The leaf cell containing a point is still much larger than the point.
29
EXPECT_FALSE(r0.Contains(cell));
30
EXPECT_TRUE(r0.MayIntersect(cell));
33
TEST(S2PointRegionTest, EncodeAndDecode) {
40
Decoder decoder(encoder.base(), encoder.length());
41
S2PointRegion decoded_r(S2Point(1, 0, 0));
42
decoded_r.Decode(&decoder);
43
S2Point decoded_p = decoded_r.point();
45
EXPECT_EQ(0.6, decoded_p[0]);
46
EXPECT_EQ(0.8, decoded_p[1]);
47
EXPECT_EQ(0.0, decoded_p[2]);