diff --git a/pmtiles/bucket_test.go b/pmtiles/bucket_test.go index 812f983..e3e9935 100644 --- a/pmtiles/bucket_test.go +++ b/pmtiles/bucket_test.go @@ -1,13 +1,12 @@ package pmtiles import ( + "fmt" "github.com/stretchr/testify/assert" - "testing" "strings" - "fmt" + "testing" ) - func TestNormalizeLocalFile(t *testing.T) { bucket, key, _ := NormalizeBucketKey("", "", "../foo/bar.pmtiles") assert.Equal(t, "bar.pmtiles", key) @@ -32,4 +31,4 @@ func TestNormalizePathPrefixServer(t *testing.T) { fmt.Println(bucket) assert.True(t, strings.HasSuffix(bucket, "/foo")) assert.True(t, strings.HasPrefix(bucket, "file://")) -} \ No newline at end of file +} diff --git a/pmtiles/convert_test.go b/pmtiles/convert_test.go index 0ce8464..a0be0ae 100644 --- a/pmtiles/convert_test.go +++ b/pmtiles/convert_test.go @@ -8,16 +8,16 @@ import ( func TestResolver(t *testing.T) { resolver := NewResolver(true, true) resolver.AddTileIsNew(1, []byte{0x1, 0x2}) - assert.Equal(t,1,len(resolver.Entries)) + assert.Equal(t, 1, len(resolver.Entries)) resolver.AddTileIsNew(2, []byte{0x1, 0x3}) - assert.Equal(t,uint64(52),resolver.Offset) + assert.Equal(t, uint64(52), resolver.Offset) is_new, _ := resolver.AddTileIsNew(3, []byte{0x1, 0x2}) - assert.False(t,is_new) - assert.Equal(t,uint64(52),resolver.Offset) + assert.False(t, is_new) + assert.Equal(t, uint64(52), resolver.Offset) resolver.AddTileIsNew(4, []byte{0x1, 0x2}) - assert.Equal(t,3,len(resolver.Entries)) + assert.Equal(t, 3, len(resolver.Entries)) resolver.AddTileIsNew(6, []byte{0x1, 0x2}) - assert.Equal(t,4,len(resolver.Entries)) + assert.Equal(t, 4, len(resolver.Entries)) } func TestV2UpgradeBarebones(t *testing.T) { @@ -25,17 +25,17 @@ func TestV2UpgradeBarebones(t *testing.T) { "bounds": "-180.0,-85,178,83", "attribution": "abcd", }, []byte{0x1f, 0x8b, 0x0, 0x0}) - assert.Nil(t,err) + assert.Nil(t, err) _, ok := json_metadata["attribution"] - assert.True(t,ok) - assert.Equal(t,int32(-180*10000000), header.MinLonE7) - assert.Equal(t,int32(-85*10000000), header.MinLatE7) - assert.Equal(t,int32(178*10000000), header.MaxLonE7) - assert.Equal(t,int32(83*10000000), header.MaxLatE7) + assert.True(t, ok) + assert.Equal(t, int32(-180*10000000), header.MinLonE7) + assert.Equal(t, int32(-85*10000000), header.MinLatE7) + assert.Equal(t, int32(178*10000000), header.MaxLonE7) + assert.Equal(t, int32(83*10000000), header.MaxLatE7) _, ok = json_metadata["bounds"] - assert.False(t,ok) - assert.Equal(t,Gzip,int(header.TileCompression)) - assert.Equal(t,Mvt,int(header.TileType)) + assert.False(t, ok) + assert.Equal(t, Gzip, int(header.TileCompression)) + assert.Equal(t, Mvt, int(header.TileType)) } func TestV2UpgradeExtra(t *testing.T) { @@ -47,7 +47,7 @@ func TestV2UpgradeExtra(t *testing.T) { "compression": "gzip", "json": "{\"abc\":\"def\"}", }, []byte{0x0, 0x0, 0x0, 0x0}) - assert.Nil(t,err) + assert.Nil(t, err) assert.Equal(t, int32(-122.1906*10000000), header.CenterLonE7) assert.Equal(t, int32(37.7599*10000000), header.CenterLatE7) assert.Equal(t, uint8(11), header.CenterZoom) @@ -94,8 +94,8 @@ func TestV2UpgradeInfer(t *testing.T) { "bounds": "-180.0,-85,180,85", }, []byte{0xff, 0xd8, 0xff, 0xe0}) assert.Nil(t, err) - assert.Equal(t,Jpeg, int(header.TileType)) - assert.Equal(t,NoCompression, int(header.TileCompression)) + assert.Equal(t, Jpeg, int(header.TileType)) + assert.Equal(t, NoCompression, int(header.TileCompression)) header, _, err = v2_to_header_json(map[string]interface{}{ "bounds": "-180.0,-85,180,85", }, []byte{0x89, 0x50, 0x4e, 0x47}) @@ -110,7 +110,7 @@ func TestV2UpgradeInfer(t *testing.T) { header, _, err = v2_to_header_json(map[string]interface{}{ "bounds": "-180.0,-85,180,85", }, []byte{0x1f, 0x8b, 00, 00}) - assert.Nil(t,err) + assert.Nil(t, err) assert.Equal(t, Mvt, int(header.TileType)) assert.Equal(t, Gzip, int(header.TileCompression)) } @@ -128,14 +128,14 @@ func TestMbtiles(t *testing.T) { "json", "{\"vector_layers\":[{\"abc\":123}],\"tilestats\":{\"def\":456}}", "compression", "gzip", }) - assert.Nil(t,err) - assert.Equal(t,int32(-180*10000000), header.MinLonE7) - assert.Equal(t,int32(-85*10000000), header.MinLatE7) - assert.Equal(t,int32(180*10000000), header.MaxLonE7) - assert.Equal(t,int32(85*10000000), header.MaxLatE7) + assert.Nil(t, err) + assert.Equal(t, int32(-180*10000000), header.MinLonE7) + assert.Equal(t, int32(-85*10000000), header.MinLatE7) + assert.Equal(t, int32(180*10000000), header.MaxLonE7) + assert.Equal(t, int32(85*10000000), header.MaxLatE7) assert.Equal(t, Mvt, int(header.TileType)) - assert.Equal(t,int32(-122.1906*10000000), header.CenterLonE7) - assert.Equal(t,int32(37.7599*10000000), header.CenterLatE7) + assert.Equal(t, int32(-122.1906*10000000), header.CenterLonE7) + assert.Equal(t, int32(37.7599*10000000), header.CenterLatE7) assert.Equal(t, 11, int(header.CenterZoom)) assert.Equal(t, Gzip, int(header.TileCompression)) @@ -187,13 +187,13 @@ func TestMbtilesMissingBoundsCenter(t *testing.T) { "json", "{\"vector_layers\":[{\"abc\":123}],\"tilestats\":{\"def\":456}}", "compression", "gzip", }) - assert.Nil(t,err) - assert.Equal(t,int32(-180*10000000), header.MinLonE7) - assert.Equal(t,int32(-85*10000000), header.MinLatE7) - assert.Equal(t,int32(180*10000000), header.MaxLonE7) - assert.Equal(t,int32(85*10000000), header.MaxLatE7) - assert.Equal(t,int32(0), header.CenterLonE7) - assert.Equal(t,int32(0), header.CenterLatE7) + assert.Nil(t, err) + assert.Equal(t, int32(-180*10000000), header.MinLonE7) + assert.Equal(t, int32(-85*10000000), header.MinLatE7) + assert.Equal(t, int32(180*10000000), header.MaxLonE7) + assert.Equal(t, int32(85*10000000), header.MaxLatE7) + assert.Equal(t, int32(0), header.CenterLonE7) + assert.Equal(t, int32(0), header.CenterLatE7) } func TestMbtilesDegenerateBounds(t *testing.T) { @@ -208,5 +208,5 @@ func TestMbtilesDegenerateBounds(t *testing.T) { "json", "{\"vector_layers\":[{\"abc\":123}],\"tilestats\":{\"def\":456}}", "compression", "gzip", }) - assert.NotNil(t,err) + assert.NotNil(t, err) } diff --git a/pmtiles/directory_test.go b/pmtiles/directory_test.go index e421887..e93c7f6 100644 --- a/pmtiles/directory_test.go +++ b/pmtiles/directory_test.go @@ -58,30 +58,30 @@ func TestHeaderRoundtrip(t *testing.T) { header.CenterLatE7 = 3.2 * 10000000 b := serialize_header(header) result, _ := deserialize_header(b) - assert.Equal(t,uint64(1),result.RootOffset) - assert.Equal(t,uint64(2),result.RootLength) - assert.Equal(t,uint64(3),result.MetadataOffset) - assert.Equal(t,uint64(4),result.MetadataLength) - assert.Equal(t,uint64(5),result.LeafDirectoryOffset) - assert.Equal(t,uint64(6),result.LeafDirectoryLength) - assert.Equal(t,uint64(7),result.TileDataOffset) - assert.Equal(t,uint64(8),result.TileDataLength) - assert.Equal(t,uint64(9),result.AddressedTilesCount) - assert.Equal(t,uint64(10),result.TileEntriesCount) - assert.Equal(t,uint64(11),result.TileContentsCount) - assert.Equal(t,true,result.Clustered) - assert.Equal(t,Gzip,int(result.InternalCompression)) - assert.Equal(t,Brotli,int(result.TileCompression)) - assert.Equal(t,Mvt,int(result.TileType)) - assert.Equal(t,uint8(1),result.MinZoom) - assert.Equal(t,uint8(2),result.MaxZoom) - assert.Equal(t,int32(11000000), result.MinLonE7) - assert.Equal(t,int32(21000000), result.MinLatE7) - assert.Equal(t,int32(12000000), result.MaxLonE7) - assert.Equal(t,int32(22000000), result.MaxLatE7) - assert.Equal(t,uint8(3),result.CenterZoom) - assert.Equal(t,int32(31000000), result.CenterLonE7) - assert.Equal(t,int32(32000000), result.CenterLatE7) + assert.Equal(t, uint64(1), result.RootOffset) + assert.Equal(t, uint64(2), result.RootLength) + assert.Equal(t, uint64(3), result.MetadataOffset) + assert.Equal(t, uint64(4), result.MetadataLength) + assert.Equal(t, uint64(5), result.LeafDirectoryOffset) + assert.Equal(t, uint64(6), result.LeafDirectoryLength) + assert.Equal(t, uint64(7), result.TileDataOffset) + assert.Equal(t, uint64(8), result.TileDataLength) + assert.Equal(t, uint64(9), result.AddressedTilesCount) + assert.Equal(t, uint64(10), result.TileEntriesCount) + assert.Equal(t, uint64(11), result.TileContentsCount) + assert.Equal(t, true, result.Clustered) + assert.Equal(t, Gzip, int(result.InternalCompression)) + assert.Equal(t, Brotli, int(result.TileCompression)) + assert.Equal(t, Mvt, int(result.TileType)) + assert.Equal(t, uint8(1), result.MinZoom) + assert.Equal(t, uint8(2), result.MaxZoom) + assert.Equal(t, int32(11000000), result.MinLonE7) + assert.Equal(t, int32(21000000), result.MinLatE7) + assert.Equal(t, int32(12000000), result.MaxLonE7) + assert.Equal(t, int32(22000000), result.MaxLatE7) + assert.Equal(t, uint8(3), result.CenterZoom) + assert.Equal(t, int32(31000000), result.CenterLonE7) + assert.Equal(t, int32(32000000), result.CenterLatE7) } func TestOptimizeDirectories(t *testing.T) { @@ -168,6 +168,6 @@ func TestBuildRootsLeaves(t *testing.T) { entries := []EntryV3{ {TileId: 100, Offset: 1, Length: 1, RunLength: 0}, } - _, _, num_leaves := build_roots_leaves(entries,1) + _, _, num_leaves := build_roots_leaves(entries, 1) assert.Equal(t, 1, num_leaves) -} \ No newline at end of file +} diff --git a/pmtiles/readerv2_test.go b/pmtiles/readerv2_test.go index 98b7fdb..5b802ec 100644 --- a/pmtiles/readerv2_test.go +++ b/pmtiles/readerv2_test.go @@ -7,7 +7,7 @@ import ( func TestUint24(t *testing.T) { b := []byte{255, 255, 255} - assert.Equal(t,uint32(16777215), readUint24(b)) + assert.Equal(t, uint32(16777215), readUint24(b)) b = []byte{255, 0, 0} assert.Equal(t, uint32(255), readUint24(b)) } @@ -21,5 +21,5 @@ func TestUint48(t *testing.T) { func TestGetParentTile(t *testing.T) { a := Zxy{Z: 8, X: 125, Y: 69} - assert.Equal(t,Zxy{Z: 7, X: 62, Y: 34},GetParentTile(a,7) ) + assert.Equal(t, Zxy{Z: 7, X: 62, Y: 34}, GetParentTile(a, 7)) } diff --git a/pmtiles/tile_id_test.go b/pmtiles/tile_id_test.go index 41a5c52..8669914 100644 --- a/pmtiles/tile_id_test.go +++ b/pmtiles/tile_id_test.go @@ -71,25 +71,25 @@ func TestExtremes(t *testing.T) { } func TestParent(t *testing.T) { - assert.Equal(t, ZxyToId(0,0,0), ParentId(ZxyToId(1,0,0))) + assert.Equal(t, ZxyToId(0, 0, 0), ParentId(ZxyToId(1, 0, 0))) - assert.Equal(t, ZxyToId(1,0,0), ParentId(ZxyToId(2,0,0))) - assert.Equal(t, ZxyToId(1,0,0), ParentId(ZxyToId(2,0,1))) - assert.Equal(t, ZxyToId(1,0,0), ParentId(ZxyToId(2,1,0))) - assert.Equal(t, ZxyToId(1,0,0), ParentId(ZxyToId(2,1,1))) + assert.Equal(t, ZxyToId(1, 0, 0), ParentId(ZxyToId(2, 0, 0))) + assert.Equal(t, ZxyToId(1, 0, 0), ParentId(ZxyToId(2, 0, 1))) + assert.Equal(t, ZxyToId(1, 0, 0), ParentId(ZxyToId(2, 1, 0))) + assert.Equal(t, ZxyToId(1, 0, 0), ParentId(ZxyToId(2, 1, 1))) - assert.Equal(t, ZxyToId(1,0,1), ParentId(ZxyToId(2,0,2))) - assert.Equal(t, ZxyToId(1,0,1), ParentId(ZxyToId(2,0,3))) - assert.Equal(t, ZxyToId(1,0,1), ParentId(ZxyToId(2,1,2))) - assert.Equal(t, ZxyToId(1,0,1), ParentId(ZxyToId(2,1,3))) + assert.Equal(t, ZxyToId(1, 0, 1), ParentId(ZxyToId(2, 0, 2))) + assert.Equal(t, ZxyToId(1, 0, 1), ParentId(ZxyToId(2, 0, 3))) + assert.Equal(t, ZxyToId(1, 0, 1), ParentId(ZxyToId(2, 1, 2))) + assert.Equal(t, ZxyToId(1, 0, 1), ParentId(ZxyToId(2, 1, 3))) - assert.Equal(t, ZxyToId(1,1,0), ParentId(ZxyToId(2,2,0))) - assert.Equal(t, ZxyToId(1,1,0), ParentId(ZxyToId(2,2,1))) - assert.Equal(t, ZxyToId(1,1,0), ParentId(ZxyToId(2,3,0))) - assert.Equal(t, ZxyToId(1,1,0), ParentId(ZxyToId(2,3,1))) + assert.Equal(t, ZxyToId(1, 1, 0), ParentId(ZxyToId(2, 2, 0))) + assert.Equal(t, ZxyToId(1, 1, 0), ParentId(ZxyToId(2, 2, 1))) + assert.Equal(t, ZxyToId(1, 1, 0), ParentId(ZxyToId(2, 3, 0))) + assert.Equal(t, ZxyToId(1, 1, 0), ParentId(ZxyToId(2, 3, 1))) - assert.Equal(t, ZxyToId(1,1,1), ParentId(ZxyToId(2,2,2))) - assert.Equal(t, ZxyToId(1,1,1), ParentId(ZxyToId(2,2,3))) - assert.Equal(t, ZxyToId(1,1,1), ParentId(ZxyToId(2,3,2))) - assert.Equal(t, ZxyToId(1,1,1), ParentId(ZxyToId(2,3,3))) + assert.Equal(t, ZxyToId(1, 1, 1), ParentId(ZxyToId(2, 2, 2))) + assert.Equal(t, ZxyToId(1, 1, 1), ParentId(ZxyToId(2, 2, 3))) + assert.Equal(t, ZxyToId(1, 1, 1), ParentId(ZxyToId(2, 3, 2))) + assert.Equal(t, ZxyToId(1, 1, 1), ParentId(ZxyToId(2, 3, 3))) }