From 5c89884df94592ac1b94ca7bd229240762e59b0f Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 1 Apr 2018 12:13:14 +0300 Subject: [PATCH] fix binary code mixup mixed get_word with get_internal_word --- lib/parfait/binary_code.rb | 4 ++-- test/parfait/test_binary_code.rb | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/parfait/binary_code.rb b/lib/parfait/binary_code.rb index 7020f5a1..f6adfc20 100644 --- a/lib/parfait/binary_code.rb +++ b/lib/parfait/binary_code.rb @@ -25,8 +25,8 @@ module Parfait end def each_word index = 1 - while( index < 14) - yield get_internal_word(index) + while( index <= data_length) + yield get_word(index) index += 1 end end diff --git a/test/parfait/test_binary_code.rb b/test/parfait/test_binary_code.rb index 3f7d038c..e343232f 100644 --- a/test/parfait/test_binary_code.rb +++ b/test/parfait/test_binary_code.rb @@ -74,5 +74,16 @@ module Parfait @code.each_word{ len += 1} assert_equal 13 , len end + def test_set_word + assert_equal 1 , @code.set_word(1 , 1) + end + def test_get_word + @code.set_word(1 , 1) + assert_equal 1, @code.get_word(1) + end + def test_get_internal_word + @code.set_word(1 , 1) + assert_equal 1, @code.get_internal_word(@code.data_start + 1) + end end end