-
Notifications
You must be signed in to change notification settings - Fork 0
/
collection_test.go
50 lines (40 loc) · 1.07 KB
/
collection_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// Copyright (C) 2021 Dmitry Kolesnikov
//
// This file may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
// https://github.com/fogfish/geojson
//
package geojson_test
import (
"encoding/json"
"testing"
"github.com/fogfish/geojson"
"github.com/fogfish/it"
)
func TestCollection(t *testing.T) {
spb := GeoJsonCity{
Feature: geojson.NewPoint("city:spb", geojson.Coord{100.0, 0.0}),
City: City{Name: "Saint-Petersburg"},
}
hel := GeoJsonCity{
Feature: geojson.NewPoint("city:hel", geojson.Coord{101.0, 1.0}),
City: City{Name: "Helsinki"},
}
sto := GeoJsonCity{
Feature: geojson.NewPoint("city:sto", geojson.Coord{102.0, 2.0}),
City: City{Name: "Stockholm"},
}
seq := geojson.Collection[GeoJsonCity]{
Features: []GeoJsonCity{spb, hel, sto},
}
bin, err := json.Marshal(seq)
it.Ok(t).IfNil(err)
var c geojson.Collection[GeoJsonCity]
err = json.Unmarshal([]byte(bin), &c)
it.Ok(t).
IfNil(err).
If(c.Features[0]).Equal(spb).
If(c.Features[1]).Equal(hel).
If(c.Features[2]).Equal(sto)
}