github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/execution/errors/errors_test.go (about)

     1  package errors
     2  
     3  import (
     4  	"encoding/json"
     5  	"fmt"
     6  	"testing"
     7  
     8  	"github.com/stretchr/testify/assert"
     9  	"github.com/stretchr/testify/require"
    10  )
    11  
    12  func TestErrorCode_MarshalJSON(t *testing.T) {
    13  	ec := NewException(Codes.DataStackOverflow, "arrgh")
    14  	bs, err := json.Marshal(ec)
    15  	require.NoError(t, err)
    16  
    17  	ecOut := new(Exception)
    18  	err = json.Unmarshal(bs, ecOut)
    19  	require.NoError(t, err)
    20  
    21  	assert.Equal(t, ec, ecOut)
    22  }
    23  
    24  func TestCode_String(t *testing.T) {
    25  	err := Codes.CodeOutOfBounds
    26  	fmt.Println(err.Error())
    27  }
    28  
    29  func TestPrintCodes(t *testing.T) {
    30  	fmt.Printf("%v", Codes)
    31  }