binToDec 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb0cea99b17b8f5a045dcee20c9a31bcf9a8656d
4
- data.tar.gz: 3eff5e9a8a89aece803d6784712f909bd56a01ba
3
+ metadata.gz: a51651cd7f62b2e423961e82c36a5c8cd5a796ef
4
+ data.tar.gz: fd354f842b69a530f9c1b312c4a4637622141ab2
5
5
  SHA512:
6
- metadata.gz: 5bd0bc42e71e306c092c958439b4cb1ef764bcfd39610cd3b3a37a5f2328f26ba5e920539922363d41ff25c0a10cf338fe0b9c54d88e2b0705317b584660832c
7
- data.tar.gz: 00e0336d4f79843830ceceaae9a3c7a984a2b6e48edc62704cc67d9fd79c9fc6fe1c0664860bb1fdd84af977625a9b514978da694bd30f2fd29141688088c9fa
6
+ metadata.gz: 7bf49af41382fae8994266b0a93724912d58914a3f2139b6e57c245442f2c6c82c49e8474f959d6fe5da47ce1f1fdab3673444caaa5e8e5c18c9ef5e020bc36e
7
+ data.tar.gz: b626d9c48c613b5a0d6d89f51387e98bf3da8eaf1d8af9b1f0195a6c40b88098fe62fb1a49a059ee60a2f9df9170e6cb1e8bcddf3994e989b6e529ebab8f0cd3
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  **binToDec** is written in Ruby, and converts a binary number to a decimal only if
5
5
  the argument is binary.
6
-
6
+ If the argument is not binary, an exception is raised.
7
7
  It should be considered an experimental gem.
8
8
 
9
9
  ## Installation
@@ -32,7 +32,7 @@ The program uses the following test to determine if the input is binary:
32
32
  `arg1.to_s.split(//).map { |i| i.to_i }.find_all { |value| value > 0 }.inject(:*)`
33
33
 
34
34
 
35
- The program uses the following code to convert the input (arg1) to binary.
35
+ If the test passes, the program uses the following code to convert the input (arg1) to binary.
36
36
 
37
37
  `arg1.to_s.split(//).map { |i| i.to_i }.inject(0) { |accumulator, value| (accumulator + value) * 2 }`
38
38
 
@@ -13,7 +13,7 @@ module Converter
13
13
  #The above result will be double what it should be, so need to divide by 2
14
14
  return result/2
15
15
  else
16
- raise "!Not binary: #{arg1}"
16
+ raise "!Not binary: #{arg1}"
17
17
  end
18
18
  end
19
19
  end
@@ -14,18 +14,20 @@ class BinaryTest < Test::Unit::TestCase
14
14
  Converter.binToDec(1000)
15
15
  end
16
16
 
17
- # Test if a invalid binary number gives correct error message
18
-
19
- def test_non_binary_true
20
- assert_equal "!Not binary: 2222",
21
- Converter.binToDec(2222)
17
+ # Test if an invalid binary number raises an exception
18
+ def test_non_binary_true
19
+
20
+ assert_raise RuntimeError do
21
+ Converter.binToDec(2222)
22
+ end
22
23
  end
23
24
 
24
- # Test if a invalid binary number gives correct error message
25
-
26
- def test_non_binary_false
27
- assert_not_equal "On the Rails, Matz, and off the Rails. Such is life",
28
- Converter.binToDec(2222)
25
+ # Test if an valid binary number does not raise an exception
26
+ def test_non_binary_false
27
+
28
+ assert_nothing_raised RuntimeError do
29
+ Converter.binToDec(1000)
30
+ end
29
31
  end
30
32
 
31
33
  end # End of Class
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: binToDec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - tomgdow