Created
October 27, 2009 17:40
-
-
Save subbu/219766 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
class TestSalesTaxApp < Test::Unit::TestCase | |
def setup | |
# load the inputs | |
require 'sales_tax.rb' | |
end | |
def test_rounding_off | |
assert_equal(78.9, 78.876.round_to(1)) | |
assert_equal(78.88, 78.876.round_to(2)) | |
assert_equal(0.23, 0.233.round_to(2)) | |
assert_equal(0.11, 0.110.round_to(2)) | |
assert_equal(0.0, 0.01.round_to(1)) | |
end | |
def test_exempted | |
assert(Item.new(:item => 'pickaxe book').exempted?) | |
assert(Item.new(:item => 'pickaxe BOOK').exempted?) | |
end | |
def test_imported | |
assert(Item.new(:item => 'imported perfume').imported?) | |
assert(Item.new(:item => 'IMPORTED perfume').imported?) | |
end | |
def test_tax_calculations | |
i = Item.new(:item => 'imported book', :price => 100) | |
assert_equal(5, i.sales_tax) | |
i = Item.new(:item => 'fever pills', :price => 10) | |
assert_equal(0, i.sales_tax) | |
i = Item.new(:item => 'IMPORTED fever pills', :price => 10) | |
assert_equal(0.5, i.sales_tax) | |
end | |
def test_price | |
i = Item.new(:item => 'imported book', :price => 107.897628) | |
assert_equal(113.29, i.price) | |
end | |
def test_bad_input | |
end | |
def test_0_values | |
assert_raises(ArgumentError) {Item.new()} | |
assert_nothing_raised {Item.new(:item => "")} # Replace it with something useful | |
end | |
def test_null_values | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment