Skip to content

Instantly share code, notes, and snippets.

@kat-perreira
Last active August 20, 2018 21:16
Show Gist options
  • Save kat-perreira/7803544cfe8ef54fbaaf82aab3ed3cdd to your computer and use it in GitHub Desktop.
Save kat-perreira/7803544cfe8ef54fbaaf82aab3ed3cdd to your computer and use it in GitHub Desktop.
fourbit_value_specs.rb
require 'minitest/autorun'
require 'minitest/reporters'
require_relative '../lib/fourbit_values.rb'
# [Optional] Write a program to print all possible values that can be represented using 4 bits. e.g. 0000, 0001, 0010, 0011, 0100 ... and so on.
describe 'four_bit to value' do
it "0 value for 0000" do
# Arrange
fourbits = [0000]
# Act
expected = [0]
# Assert
fourbit_to_value(fourbits).must_equal expected
end
it "1 value for 0001" do
fourbits = [0001]
expeted = [1]
fourbit_to_value(fourbits)[1]
end
it "5 value for 0101" do
fourbits = [0101]
expectied = [5]
fourbit_to_value(fourbits)[5]
end
it "2 value for 0010" do
fourbits = [0010]
expected = [2]
fourbit_to_value(fourbits).must_equal expected
end
it "14 value for 01111" do
fourbits = [01111]
expected = [15]
fourbit_to_value(fourbits).must_equal expected
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment