On Thu, Jan 17, 2019 at 11:40:09AM +0100, Pino Toscano wrote:
Use better functions to check for proper values instead of assert:
- refute_nil for non-null functions
- assert_equal for checking equality
Also, make sure that the parameters for assert_equal are correct:
expected value, then got value.
---
ruby/tests/tc_120_rlenvalue.rb | 4 ++--
ruby/tests/tc_130_special.rb | 12 ++++++------
ruby/tests/tc_200_write.rb | 4 ++--
ruby/tests/tc_210_setvalue.rb | 20 ++++++++++----------
4 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/ruby/tests/tc_120_rlenvalue.rb b/ruby/tests/tc_120_rlenvalue.rb
index 6c03f43..6a2fb72 100644
--- a/ruby/tests/tc_120_rlenvalue.rb
+++ b/ruby/tests/tc_120_rlenvalue.rb
@@ -37,7 +37,7 @@ class TestRLenValue < MiniTest::Unit::TestCase
moderate_value_value = h.node_get_value(moderate_value_node, "33Bytes")
r = h.value_data_cell_offset(moderate_value_value)
- assert_equal(r[:len], 37)
- assert_equal(r[:off], 8712)
+ assert_equal(37, r[:len])
+ assert_equal(8712, r[:off])
end
end
diff --git a/ruby/tests/tc_130_special.rb b/ruby/tests/tc_130_special.rb
index 282b288..7570824 100644
--- a/ruby/tests/tc_130_special.rb
+++ b/ruby/tests/tc_130_special.rb
@@ -13,17 +13,17 @@ class TestRLenValue < MiniTest::Unit::TestCase
nodes = h.node_children (root)
node = nodes.find { |n| h.node_name(n) == "abcd_äöüß" }
- assert node != nil
+ refute_nil(node)
value = h.node_values(node).find { |v| h.value_key(v) == "abcd_äöüß" }
- assert value != nil
+ refute_nil(value)
node = nodes.find { |n| h.node_name(n) == "zero\0key" }
- assert node != nil
+ refute_nil(node)
value = h.node_values(node).find { |v| h.value_key(v) == "zero\0val" }
- assert value != nil
+ refute_nil(value)
node = nodes.find { |n| h.node_name(n) == "weird™" }
- assert node != nil
+ refute_nil(node)
value = h.node_values(node).find { |v| h.value_key(v) == "symbols $£₤₧€"
}
- assert value != nil
+ refute_nil(value)
end
end
diff --git a/ruby/tests/tc_200_write.rb b/ruby/tests/tc_200_write.rb
index 327d0a8..463283e 100644
--- a/ruby/tests/tc_200_write.rb
+++ b/ruby/tests/tc_200_write.rb
@@ -23,12 +23,12 @@ class TestWrite < MiniTest::Unit::TestCase
refute_nil (h)
root = h.root()
- assert (root)
+ refute_nil (root)
h.node_add_child(root, "A")
h.node_add_child(root, "B")
b = h.node_get_child(root, "B")
- assert (b)
+ refute_nil (b)
values = [
{ :key => "Key1", :type => 3, :value => "ABC"
},
diff --git a/ruby/tests/tc_210_setvalue.rb b/ruby/tests/tc_210_setvalue.rb
index 62ffd99..736b073 100644
--- a/ruby/tests/tc_210_setvalue.rb
+++ b/ruby/tests/tc_210_setvalue.rb
@@ -23,7 +23,7 @@ class TestSetValue < MiniTest::Unit::TestCase
refute_nil (h)
root = h.root()
- assert (root)
+ refute_nil (root)
h.node_add_child(root, "B")
b = h.node_get_child(root, "B")
@@ -42,21 +42,21 @@ class TestSetValue < MiniTest::Unit::TestCase
val = h.node_get_value(b, "Key1")
hash = h.value_value(val)
- assert (hash[:type] == 3)
- assert (hash[:value] == "JKL")
- assert (hash[:len] == 3)
+ assert_equal(3, hash[:type])
+ assert_equal("JKL", hash[:value])
+ assert_equal(3, hash[:len])
val = h.node_get_value(b, "Key2")
hash = h.value_value(val)
- assert (hash[:type] == 2)
- assert (hash[:value] == "DEF")
- assert (hash[:len] == 3)
+ assert_equal(2, hash[:type])
+ assert_equal("DEF", hash[:value])
+ assert_equal(3, hash[:len])
val = h.node_get_value(b, "Key3")
hash = h.value_value(val)
- assert (hash[:type] == 3)
- assert (hash[:value] == "GHI")
- assert (hash[:len] == 3)
+ assert_equal(3, hash[:type])
+ assert_equal("GHI", hash[:value])
+ assert_equal(3, hash[:len])
# Don't actually commit here because that would overwrite
# the original file.
ACK
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW