m9t 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,111 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path( 'test_helper', File.dirname( __FILE__ ) )
4
-
5
- class TestM9tTemperature < Test::Unit::TestCase
6
-
7
- def setup
8
- I18n.locale = :en
9
- M9t::Temperature.reset_options!
10
- end
11
-
12
- # Basic use
13
- def test_new
14
- assert_equal(45, M9t::Temperature.new(45).value)
15
- end
16
-
17
- # Class methods
18
-
19
- # Base class
20
-
21
- def test_measurement_name
22
- assert_equal('temperature', M9t::Temperature.measurement_name)
23
- end
24
-
25
- # conversion constants
26
-
27
- def test_kelvin_offset
28
- assert_in_delta(-273.15, M9t::Temperature::ABSOLUTE_ZERO, 0.0001)
29
- end
30
-
31
- # input conversions
32
-
33
- def test_class_kelvin
34
- assert_in_delta(-273.15, M9t::Temperature.kelvin(0).value, 0.0001)
35
- end
36
-
37
- def test_class_fahrenheit
38
- assert_in_delta(-17.7777, M9t::Temperature.fahrenheit(0).value, 0.0001)
39
- end
40
-
41
- # output conversions
42
-
43
- def test_class_to_kelvin
44
- assert_in_delta(273.15, M9t::Temperature.to_kelvin(0), 0.0001)
45
- end
46
-
47
- def test_class_to_fahrenheit
48
- assert_in_delta(32, M9t::Temperature.to_fahrenheit(0), 0.0001)
49
- end
50
-
51
- def test_class_kelvin_to_degrees
52
- assert_in_delta(-273.15, M9t::Temperature.kelvin_to_degrees(0), 0.0001)
53
- end
54
-
55
- # Instance methods
56
-
57
- # new
58
-
59
- def test_unknown_units
60
- temperature = M9t::Temperature.new( 1 )
61
-
62
- assert_raises( M9t::UnitError ) do
63
- temperature.to_s( :units => :foos )
64
- end
65
- end
66
-
67
- # output conversions
68
-
69
- def test_to_kelvin
70
- assert_equal(373.15, M9t::Temperature.new(100).to_kelvin)
71
- end
72
-
73
- def test_to_fahrenheit
74
- assert_equal(212, M9t::Temperature.new(100).to_fahrenheit)
75
- end
76
-
77
- # to_s
78
-
79
- def test_to_s
80
- assert_equal '100.00000 degrees', M9t::Temperature.new(100).to_s
81
- I18n.locale = :it
82
- assert_equal '100,00000 gradi', M9t::Temperature.new(100).to_s
83
- end
84
-
85
- def test_to_s_precision
86
- temperature = M9t::Temperature.new( 135 )
87
-
88
- assert_equal '135 degrees', temperature.to_s( :precision => 0 )
89
- end
90
-
91
- def test_to_s_abbreviated
92
- temperature = M9t::Temperature.new( 135 )
93
-
94
- assert_equal '135°C', temperature.to_s( :abbreviated => true,
95
- :precision => 0 )
96
- assert_equal '408.15K', temperature.to_s( :units => :kelvin,
97
- :abbreviated => true,
98
- :precision => 2 )
99
- end
100
-
101
- def test_to_s_kelvin
102
- temperature = M9t::Temperature.new( 100 )
103
-
104
- assert_equal '373.15 kelvin', temperature.to_s( :units => :kelvin,
105
- :precision => 2 )
106
- I18n.locale = :it
107
- assert_equal '373,15 kelvin', temperature.to_s( :units => :kelvin,
108
- :precision => 2 )
109
- end
110
-
111
- end
@@ -1,17 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems' if RUBY_VERSION < '1.9'
4
- require 'test/unit'
5
-
6
- if RUBY_VERSION > '1.9'
7
- require 'simplecov'
8
- if ENV[ 'COVERAGE' ]
9
- SimpleCov.start do
10
- add_filter "/test/"
11
- end
12
- end
13
- end
14
-
15
- $:.unshift( File.expand_path( '../lib', File.dirname(__FILE__) ) )
16
-
17
- require 'm9t'