github.com/linuxboot/fiano@v1.2.0/pkg/visitors/json_test.go (about) 1 // Copyright 2018 the LinuxBoot 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 visitors 6 7 import ( 8 "bytes" 9 "encoding/json" 10 "testing" 11 ) 12 13 // TestJSON tests the JSON visitor. The amount of testing is negligible. This 14 // simply tests that valid ROMs produce valid JSON. 15 func TestJSON(t *testing.T) { 16 f := parseImage(t) 17 18 out := &bytes.Buffer{} 19 jason := &JSON{ 20 W: out, 21 } 22 23 if err := f.Apply(jason); err != nil { 24 t.Fatal(err) 25 } 26 27 var dec interface{} 28 if err := json.Unmarshal(out.Bytes(), &dec); err != nil { 29 t.Errorf("invalid json: %q", out.String()) 30 } 31 }