From 3ffe28e3640c41802bf5479dc3857ad5194f7871 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Thu, 30 May 2013 11:12:29 -0500 Subject: [PATCH] Add test for OutOfRangeError. --- block_test.go | 8 ++++++++ test_coverage.txt | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/block_test.go b/block_test.go index 5231a21..30c8e78 100644 --- a/block_test.go +++ b/block_test.go @@ -256,6 +256,14 @@ func TestNewBlockFromBlockAndBytes(t *testing.T) { // TestBlockErrors tests the error paths for the Block API. func TestBlockErrors(t *testing.T) { + // Ensure out of range errors are as expected. + wantErr := "transaction index -1 is out of range - max 3" + testErr := btcutil.OutOfRangeError(wantErr) + if testErr.Error() != wantErr { + t.Errorf("OutOfRangeError: wrong error - got %v, want %v", + testErr.Error(), wantErr) + } + // Encode the test block to bytes. pver := btcwire.ProtocolVersion var block100000Buf bytes.Buffer diff --git a/test_coverage.txt b/test_coverage.txt index 0be2a59..2f5bb3c 100644 --- a/test_coverage.txt +++ b/test_coverage.txt @@ -3,14 +3,14 @@ github.com/conformal/btcutil/block.go Block.TxSha 100.00% (11/11) github.com/conformal/btcutil/block.go Block.TxShas 100.00% (10/10) github.com/conformal/btcutil/block.go NewBlockFromBytes 100.00% (7/7) github.com/conformal/btcutil/block.go Block.Sha 100.00% (5/5) -github.com/conformal/btcutil/block.go NewBlockFromBlockAndBytes 100.00% (1/1) +github.com/conformal/btcutil/block.go OutOfRangeError.Error 100.00% (1/1) github.com/conformal/btcutil/block.go Block.MsgBlock 100.00% (1/1) github.com/conformal/btcutil/block.go Block.ProtocolVersion 100.00% (1/1) +github.com/conformal/btcutil/block.go NewBlock 100.00% (1/1) +github.com/conformal/btcutil/block.go NewBlockFromBlockAndBytes 100.00% (1/1) github.com/conformal/btcutil/block.go Block.Height 100.00% (1/1) github.com/conformal/btcutil/block.go Block.SetHeight 100.00% (1/1) -github.com/conformal/btcutil/block.go NewBlock 100.00% (1/1) github.com/conformal/btcutil/block.go Block.Bytes 88.89% (8/9) github.com/conformal/btcutil/block.go Block.TxLoc 77.78% (7/9) -github.com/conformal/btcutil/block.go OutOfRangeError.Error 0.00% (0/1) -github.com/conformal/btcutil ------------------------- 93.10% (54/58) +github.com/conformal/btcutil ------------------------- 94.83% (55/58)