github.com/turingchain2020/turingchain@v1.1.21/types/log_test.go (about) 1 // Copyright Turing Corp. 2018 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 types 6 7 import ( 8 "testing" 9 10 "github.com/stretchr/testify/assert" 11 ) 12 13 func TestLogErr(t *testing.T) { 14 var errlog LogErr = []byte("hello world") 15 logty := LoadLog(nil, TyLogErr) 16 assert.NotNil(t, logty) 17 assert.Equal(t, logty.Name(), "LogErr") 18 result, err := logty.Decode([]byte("hello world")) 19 assert.Nil(t, err) 20 assert.Equal(t, LogErr(result.(string)), errlog) 21 22 //json test 23 data, err := logty.JSON([]byte("hello world")) 24 assert.Nil(t, err) 25 assert.Equal(t, string(data), `"hello world"`) 26 }