go-hep.org/x/hep@v0.38.1/lcio/cmd/lcio-ls/main_test.go (about)

     1  // Copyright ©2018 The go-hep 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 main
     6  
     7  import (
     8  	"bytes"
     9  	"os"
    10  	"testing"
    11  )
    12  
    13  func TestInspect(t *testing.T) {
    14  	for _, fname := range []string{
    15  		"../../testdata/run-header_golden.slcio",
    16  		"../../testdata/event_golden.slcio",
    17  	} {
    18  
    19  		t.Run(fname, func(t *testing.T) {
    20  			buf := new(bytes.Buffer)
    21  			inspect(buf, fname, -1, false)
    22  
    23  			got := buf.Bytes()
    24  			want, err := os.ReadFile(fname + ".txt")
    25  			if err != nil {
    26  				t.Fatal(err)
    27  			}
    28  			if !bytes.Equal(got, want) {
    29  				t.Fatalf("error.\ngot = %q\nwant= %q\n", string(got), string(want))
    30  			}
    31  		})
    32  	}
    33  }