| 26 | ) |
| 27 | |
| 28 | func TestNewAndValues(t *testing.T) { |
| 29 | hm, err := New(CellWidth(2)) |
| 30 | if err != nil { |
| 31 | t.Fatalf("New => unexpected error: %v", err) |
| 32 | } |
| 33 | |
| 34 | if err := hm.Values(nil, nil, [][]float64{{1, 2}, {3, 4}}); err != nil { |
| 35 | t.Fatalf("Values => unexpected error: %v", err) |
| 36 | } |
| 37 | |
| 38 | if got, want := hm.xLabels, []string{"0", "1"}; len(got) != len(want) || got[0] != want[0] || got[1] != want[1] { |
| 39 | t.Fatalf("xLabels = %v, want %v", got, want) |
| 40 | } |
| 41 | if got, want := hm.yLabels, []string{"0", "1"}; len(got) != len(want) || got[0] != want[0] || got[1] != want[1] { |
| 42 | t.Fatalf("yLabels = %v, want %v", got, want) |
| 43 | } |
| 44 | if got, want := hm.minValue, 1.0; got != want { |
| 45 | t.Fatalf("minValue = %v, want %v", got, want) |
| 46 | } |
| 47 | if got, want := hm.maxValue, 4.0; got != want { |
| 48 | t.Fatalf("maxValue = %v, want %v", got, want) |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | func TestValuesRejectsInvalidInput(t *testing.T) { |
| 53 | hm, err := New() |