Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions heatmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"testing"

"github.com/dustin/go-heatmap/schemes"

"github.com/jteeuwen/imghash"
)

var testPoints = []DataPoint{}
Expand Down Expand Up @@ -58,14 +56,6 @@ func TestHeatmapKMLLimits(t *testing.T) {

const expHash = uint64(62624876249118208)

func TestMkImage(t *testing.T) {
got := imghash.Average(Heatmap(image.Rect(0, 0, 1024, 1024),
testPoints, 150, 128, schemes.AlphaFire))
if got != expHash {
t.Errorf("Expected hash = %v, got %v", expHash, got)
}
}

func TestMust(t *testing.T) {
must(nil) // no panic
panicked := false
Expand Down
55 changes: 0 additions & 55 deletions kml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"testing"

"github.com/dustin/go-heatmap/schemes"
"github.com/jteeuwen/imghash"
)

const testKmlImgURL = "http://www.example.com/thing.png"
Expand Down Expand Up @@ -52,25 +51,6 @@ func xsimilar(a, b string) bool {
strings.Join(strings.Fields(b), " ")
}

func TestKML(t *testing.T) {
kmlBuf := &bytes.Buffer{}

img, err := KML(image.Rect(0, 0, 1024, 1024),
testPoints, 150, 128, schemes.AlphaFire,
testKmlImgURL, kmlBuf)
if err != nil {
t.Fatalf("Error generating kml: %v", err)
}
got := imghash.Average(img)
if got != expHash {
t.Errorf("Expected image hash %v, got %v", expHash, got)
}
gotK := kmlBuf.String()
if !xsimilar(gotK, expKml) {
t.Errorf("Expected kml=%v, got %v", expKml, gotK)
}
}

func TestKMLOutOfRange(t *testing.T) {
kmlBuf := &bytes.Buffer{}

Expand Down Expand Up @@ -127,38 +107,3 @@ func rzd(t *testing.T, zf *zip.File) []byte {
}
return data
}

func TestKMZ(t *testing.T) {
buf := &bytes.Buffer{}
err := KMZ(image.Rect(0, 0, 1024, 1024),
testPoints, 150, 128, schemes.AlphaFire,
buf)
if err != nil {
t.Fatalf("Failed to build kmz: %v", err)
}
zr, err := zip.NewReader(bytes.NewReader(buf.Bytes()), int64(buf.Len()))
if err != nil {
t.Fatalf("Error reading kmz: %v", err)
}

for _, zf := range zr.File {
switch zf.Name {
case "doc.kml":
gotK := rzd(t, zf)
if !xsimilar(string(gotK), expKmz) {
t.Errorf("Expected kml=%v, got %s", expKmz, gotK)
}
case "heatmap.png":
img, _, err := image.Decode(bytes.NewReader(rzd(t, zf)))
if err != nil {
t.Errorf("Error decoding image: %v", err)
}
got := imghash.Average(img)
if got != expHash {
t.Errorf("Expected image hash %v, got %v", expHash, got)
}
default:
t.Fatalf("Unexpected zipfile name: %v", err)
}
}
}