Sha256: 61d835552aad6239842f58284b46b30fdf63e7e8d65434c70d523232ece5bfa7

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

require File.dirname(__FILE__) + '/test_helper'

class ExtTest < Test::Unit::TestCase
  def setup
    reset_defaults
  end
  
  def test_conversions
    assert_in_delta 1.609344, 1.convert(:miles, :kilometres), DELTA
    assert_in_delta 1.609344, 1.0.convert(:miles, :kilometres), DELTA
    assert_in_delta 0.45359237, 1.convert(:pounds, :kilograms), DELTA
    assert_in_delta 0.00110231131092439, 1.convert(:kilograms, :tons), DELTA
    assert_in_delta 2.20462262184878, 1.convert(:kilograms, :pounds), DELTA
    assert_in_delta 1, ( 1.convert(:kilograms, :pounds) * 1.convert(:pounds, :kilograms) ), DELTA
    assert_in_delta 1.609344, 1.miles.to(:kilometres), DELTA
    assert_in_delta 1.609344, 1.0.miles.to(:kilometres), DELTA
    assert_in_delta 0.45359237, 1.pounds.to(:kilograms), DELTA
    assert_in_delta 0.00110231131092439, 1.kilograms.to(:tons), DELTA
    assert_in_delta 2.20462262184878, 1.kilograms.to(:pounds), DELTA
    assert_in_delta 1, ( 1.kilograms.to(:pounds) * 1.pounds.to(:kilograms) ), DELTA
  end
  
  def test_register
    Conversions.register(:dollars, :cents, 100.0)
    assert_in_delta 1000.0, 10.convert(:dollars, :cents), DELTA
    assert_in_delta 1000.0, 10.dollars.to(:cents), DELTA
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
seamusabshere-conversions-0.1.0 test/ext_test.rb
seamusabshere-conversions-1.4.0 test/ext_test.rb
seamusabshere-conversions-1.4.1 test/ext_test.rb
seamusabshere-conversions-1.4.2 test/ext_test.rb
conversions-1.4.6 test/ext_test.rb
conversions-1.4.5 test/ext_test.rb
conversions-1.4.4 test/ext_test.rb
conversions-1.4.3 test/ext_test.rb