예제 #1
0
func (s *S) TestEncodeCoordinates(c *C) {
	var tweet ts.Tweet
	tweet.Coordinates = &ts.Point{ts.Latitude(10.1), ts.Longitude(-12.5)}
	data := decodeJson(marshal(tweet))
	coords := data["coordinates"].(map[string]interface{})
	points := coords["coordinates"].([]interface{})
	c.Assert(points[0], Equals, -12.5)
	c.Assert(points[1], Equals, 10.1)
}
예제 #2
0
func (s *S) TestDecodeCoordinates(c *C) {
	tweet := decodeTweet(makeJson(JSON{
		"coordinates": JSON{
			"coordinates": []float64{12.5, 10.2},
			"type":        "Point",
		},
	}))
	c.Assert(tweet.Coordinates, NotNil)
	c.Assert(tweet.Coordinates.Lat, Equals, ts.Latitude(10.2))
	c.Assert(tweet.Coordinates.Long, Equals, ts.Longitude(12.5))
}