imposm3/cache/binary/tags_test.go

49 lines
1.1 KiB
Go
Raw Normal View History

package binary
import (
2014-08-04 17:19:35 +04:00
"github.com/omniscale/imposm3/element"
2014-06-23 17:03:23 +04:00
"sort"
"testing"
)
func TestTagsAsAndFromArray(t *testing.T) {
tags := element.Tags{"name": "foo", "highway": "residential", "oneway": "yes"}
array := tagsAsArray(tags)
2013-06-05 12:10:04 +04:00
if len(array) != 3 {
t.Fatal("invalid length", array)
}
2014-06-23 17:03:23 +04:00
sort.Strings(array)
for i, expected := range []string{
"\x01foo",
string(tagsToCodePoint["highway"]["residential"]),
2014-06-23 17:03:23 +04:00
string(tagsToCodePoint["oneway"]["yes"]),
} {
if array[i] != expected {
t.Fatal("invalid value", array, i, expected)
}
}
tags = tagsFromArray(array)
if len(tags) != 3 {
t.Fatal("invalid length", tags)
}
2013-06-05 12:10:04 +04:00
if tags["name"] != "foo" || tags["highway"] != "residential" || tags["oneway"] != "yes" {
t.Fatal("invalid tags", tags)
}
}
func TestCodePoints(t *testing.T) {
// codepoints should never change, so check a few for sanity
if c := tagsToCodePoint["building"]["yes"]; c != codepoint('\ue000') {
t.Fatalf("%x\n", c)
}
if c := tagsToCodePoint["surface"]["grass"]; c != codepoint('\ue052') {
t.Fatalf("%x\n", c)
}
if c := tagsToCodePoint["type"]["associatedStreet"]; c != codepoint('\ue0a5') {
t.Fatalf("%x\n", c)
}
}