Add log testing
8/10 of SetLogWriter tested
This commit is contained in:
parent
95167204d9
commit
24c3873956
2 changed files with 53 additions and 2 deletions
51
log_test.go
Normal file
51
log_test.go
Normal file
|
@ -0,0 +1,51 @@
|
|||
// Copyright (c) 2013-2014 Conformal Systems LLC.
|
||||
// Use of this source code is governed by an ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package btcscript_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/conformal/btcscript"
|
||||
)
|
||||
|
||||
func TestSetLogWriter(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
w io.Writer
|
||||
level string
|
||||
expected error
|
||||
}{
|
||||
{
|
||||
name: "nil writer",
|
||||
w: nil,
|
||||
level: "trace",
|
||||
expected: errors.New("nil writer"),
|
||||
},
|
||||
{
|
||||
name: "invalid log level",
|
||||
w: os.Stdout,
|
||||
level: "wrong",
|
||||
expected: errors.New("invalid log level"),
|
||||
},
|
||||
{
|
||||
name: "use off level",
|
||||
w: os.Stdout,
|
||||
level: "off",
|
||||
expected: errors.New("Min level can't be greater than max. Got min: 6, max: 5"),
|
||||
},
|
||||
}
|
||||
|
||||
t.Logf("Running %d tests", len(tests))
|
||||
for i, test := range tests {
|
||||
if err := btcscript.SetLogWriter(test.w, test.level); err.Error() != test.expected.Error() {
|
||||
t.Errorf("SetLogWriter #%d (%s) wrong result\n"+
|
||||
"got: %x\nwant: %x", i, test.name, err,
|
||||
test.expected)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -169,7 +169,7 @@ github.com/conformal/btcscript/script.go IsPushOnlyScript 75.00% (3/4)
|
|||
github.com/conformal/btcscript/script.go p2pkSignatureScript 75.00% (3/4)
|
||||
github.com/conformal/btcscript/script.go HasCanonicalPushes 71.43% (5/7)
|
||||
github.com/conformal/btcscript/script.go sign 69.23% (18/26)
|
||||
github.com/conformal/btcscript/log.go SetLogWriter 0.00% (0/10)
|
||||
github.com/conformal/btcscript/log.go SetLogWriter 0.00% (8/10)
|
||||
github.com/conformal/btcscript/script.go CalcMultiSigStats 0.00% (0/8)
|
||||
github.com/conformal/btcscript/script.go @586:34 0.00% (0/6)
|
||||
github.com/conformal/btcscript/script.go @574:34 0.00% (0/4)
|
||||
|
@ -178,5 +178,5 @@ github.com/conformal/btcscript/log.go UseLogger 0.00% (0/1)
|
|||
github.com/conformal/btcscript/opcode.go opcodeDisabled 0.00% (0/1)
|
||||
github.com/conformal/btcscript/log.go logClosure.String 0.00% (0/1)
|
||||
github.com/conformal/btcscript/opcode.go @1803:33 0.00% (0/1)
|
||||
github.com/conformal/btcscript -------------------------- 95.15% (1197/1258)
|
||||
github.com/conformal/btcscript -------------------------- 95.79% (1205/1258)
|
||||
|
||||
|
|
Loading…
Reference in a new issue