friendly_extensions 0.0.8 → 0.0.61

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,94 +0,0 @@
1
- require "test/unit"
2
- require "numbers"
3
-
4
-
5
- class NumericTest < Test::Unit::TestCase
6
-
7
-
8
- def test_number_to_euro
9
- #assert_equal 0.29.to_euro, "0,29"
10
- end
11
-
12
- # Test Math Functions
13
- def test_math_infla_defla
14
-
15
- [2, 3.3].each do |f|
16
- [40,250].each do |n|
17
- i = 500
18
- r_inf = r_def = i
19
-
20
- n.times do |i|
21
- r_inf = r_inf*(1+f/100.0)
22
- r_def = r_def*(1-f/100.0)
23
- end
24
-
25
- assert_equal i.infla(n,f).round(5), r_inf.round(5)
26
- assert_equal i.defla(n,f).round(5), r_def.round(5)
27
- end
28
- end
29
-
30
- end
31
-
32
- def test_number_should_get_closest
33
- # Test for wrong limit mode:
34
- assert_raise ArgumentError do
35
- 1.get_closest([3,4], :zonk)
36
- end
37
-
38
- # Check to find closest
39
- assert_equal 2.get_closest([0,3,4], :ceil), 3
40
- assert_equal 2.get_closest([0,3,4], :floor), 3
41
- assert_equal -2.88.get_closest([0,3,4], :floor), 0
42
-
43
- # Check to find closest with :floor
44
- assert_equal 1.get_closest([0,2], :floor), 0
45
- assert_equal 5.5.get_closest([4.5,6.5], :floor), 4.5
46
-
47
- # Check to find closest with :ceil
48
- assert_equal 1.get_closest([0,2], :ceil), 2
49
- assert_equal 5.5.get_closest([4.5,6.5], :ceil), 6.5
50
-
51
- end
52
-
53
-
54
- def test_numbers_min_and_max
55
- assert_equal 1, 1.min(3)
56
- assert_equal 3, 1.max(3)
57
- assert_equal 2, 2.min_max(1,3)
58
- assert_equal 1, -1.min_max(1,3)
59
- assert_equal 3, 4.min_max(1,3)
60
- end
61
-
62
- def test_float_dividor
63
- assert !1.fdiv(1).is_a?(Integer)
64
- end
65
-
66
- def test_to_q_faktor
67
- assert_equal 2.to_q, 1.02
68
- end
69
-
70
- def test_time_should_be_calc_correct
71
- assert_equal 23.to_time, "00:00:23"
72
- assert_equal 64.to_time, "00:01:04"
73
-
74
- assert_equal 17.to_time(:discard_hour => true), "00:17"
75
- assert_equal 73.to_time(:discard_hour => true), "01:13"
76
-
77
- assert_equal 3672.to_time, "01:01:12"
78
- <<<<<<< HEAD
79
- end
80
-
81
- def test_prime_factors
82
-
83
- [16,234,4568,34950,183649].each do |nr|
84
- primes = nr.prime_factors
85
- puts "#{nr} => #{primes.inspect}"
86
- assert_equal nr, eval(primes.join("*"))
87
- end
88
-
89
- end
90
- =======
91
- end
92
- >>>>>>> ad58e345c5de2638e34e44d69bb19b0ebebcd41e
93
-
94
- end