From 55ad967b4d6699b511b7d941a7a192536a8c56aa Mon Sep 17 00:00:00 2001 From: Michalis Kargakis Date: Sun, 3 Aug 2014 23:30:37 +0300 Subject: [PATCH] Complete SetLogWriter testing --- log_test.go | 23 +++++++++++++++++++---- test_coverage.txt | 6 +++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/log_test.go b/log_test.go index 0a7527c6..ade92316 100644 --- a/log_test.go +++ b/log_test.go @@ -38,14 +38,29 @@ func TestSetLogWriter(t *testing.T) { level: "off", expected: errors.New("Min level can't be greater than max. Got min: 6, max: 5"), }, + { + name: "pass", + w: os.Stdout, + level: "debug", + expected: nil, + }, } 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) + err := btcscript.SetLogWriter(test.w, test.level) + if err != nil { + if err.Error() != test.expected.Error() { + t.Errorf("SetLogWriter #%d (%s) wrong result\n"+ + "got: %x\nwant: %x", i, test.name, err, + test.expected) + } + } else { + if test.expected != nil { + t.Errorf("SetLogWriter #%d (%s) wrong result\n"+ + "got: %x\nwant: %x", i, test.name, err, + test.expected) + } } } } diff --git a/test_coverage.txt b/test_coverage.txt index d34a6428..40536a8a 100644 --- a/test_coverage.txt +++ b/test_coverage.txt @@ -23,6 +23,7 @@ github.com/conformal/btcscript/opcode.go opcodeNotIf 100.00% (11/11) github.com/conformal/btcscript/opcode.go opcodeIf 100.00% (11/11) github.com/conformal/btcscript/script.go typeOfScript 100.00% (11/11) github.com/conformal/btcscript/opcode.go opcodeMin 100.00% (10/10) +github.com\conformal\btcscript/log.go SetLogWriter 100.00% (10/10) github.com/conformal/btcscript/opcode.go opcodeBoolAnd 100.00% (10/10) github.com/conformal/btcscript/opcode.go opcodeBoolOr 100.00% (10/10) github.com/conformal/btcscript/opcode.go opcodeNumEqual 100.00% (10/10) @@ -132,6 +133,7 @@ github.com/conformal/btcscript/opcode.go init 100.00% (1/1) github.com/conformal/btcscript/script.go payToPubKeyHashScript 100.00% (1/1) github.com/conformal/btcscript/script.go payToScriptHashScript 100.00% (1/1) github.com/conformal/btcscript/log.go newLogClosure 100.00% (1/1) +github.com\conformal\btcscript/log.go UseLogger 100.00% (1/1) github.com/conformal/btcscript/opcode.go opcodeSwap 100.00% (1/1) github.com/conformal/btcscript/opcode.go opcodeRot 100.00% (1/1) github.com/conformal/btcscript/scriptbuilder.go ScriptBuilder.Script 100.00% (1/1) @@ -169,14 +171,12 @@ 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% (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) github.com/conformal/btcscript/script.go @619:34 0.00% (0/3) -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.79% (1205/1258) +github.com/conformal/btcscript -------------------------- 96.03% (1208/1258)