github.com/jgbaldwinbrown/perf@v0.1.1/analysis/app/trend_test.go (about) 1 // Copyright 2017 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package app 6 7 import ( 8 "testing" 9 10 "github.com/aclements/go-gg/table" 11 "golang.org/x/perf/internal/diff" 12 ) 13 14 func TestTableToJS(t *testing.T) { 15 in := table.TableFromStrings( 16 []string{"text", "num"}, 17 [][]string{ 18 {"hello", "15.1"}, 19 {"world", "20"}, 20 }, true) 21 have := tableToJS(in, []column{{Name: "text"}, {Name: "num"}}) 22 want := `{cols: [{"id":"text","type":"string","label":"text"}, 23 {"id":"num","type":"number","label":"num"}], 24 rows: [{c:[{v: "hello"}, {v: 15.1}]}, 25 {c:[{v: "world"}, {v: 20}]}]}` 26 if d := diff.Diff(string(have), want); d != "" { 27 t.Errorf("tableToJS returned wrong JS (- have, + want):\n%s", d) 28 } 29 }