osheet 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -3
- data/Gemfile +2 -0
- data/Gemfile.lock +13 -37
- data/Rakefile +3 -3
- data/lib/osheet/format/numeric.rb +0 -2
- data/lib/osheet/instance.rb +1 -3
- data/lib/osheet/version.rb +2 -2
- data/osheet.gemspec +3 -9
- data/test/cell_test.rb +96 -104
- data/test/column_test.rb +90 -97
- data/test/format/accounting_test.rb +115 -128
- data/test/format/currency_test.rb +115 -128
- data/test/format/custom_test.rb +13 -13
- data/test/format/datetime_test.rb +13 -13
- data/test/format/fraction_test.rb +63 -63
- data/test/format/general_test.rb +11 -11
- data/test/format/number_test.rb +67 -69
- data/test/format/percentage_test.rb +89 -91
- data/test/format/scientific_test.rb +89 -91
- data/test/format/special_test.rb +35 -35
- data/test/format/text_test.rb +9 -9
- data/test/format_test.rb +24 -24
- data/test/helper.rb +42 -47
- data/test/irb.rb +9 -0
- data/test/mixin_test.rb +55 -59
- data/test/osheet_test.rb +7 -10
- data/test/partial_set_test.rb +41 -61
- data/test/partial_test.rb +44 -46
- data/test/row_test.rb +92 -99
- data/test/style_set_test.rb +34 -37
- data/test/style_test.rb +72 -97
- data/test/template_set_test.rb +52 -73
- data/test/template_test.rb +31 -49
- data/test/workbook_test.rb +186 -199
- data/test/worksheet_test.rb +99 -103
- data/test/xmlss_writer/base_test.rb +72 -73
- data/test/xmlss_writer/elements_test.rb +141 -140
- data/test/xmlss_writer/styles_test.rb +197 -208
- metadata +27 -247
- data/.bundle/config +0 -2
- data/test/app_helper.rb +0 -66
- data/test/env.rb +0 -10
- data/test/rails/three/.gitignore +0 -4
- data/test/rails/three/Gemfile +0 -5
- data/test/rails/three/Gemfile.lock +0 -88
- data/test/rails/three/app/controllers/application_controller.rb +0 -3
- data/test/rails/three/app/controllers/things_controller.rb +0 -10
- data/test/rails/three/app/helpers/application_helper.rb +0 -2
- data/test/rails/three/app/views/layouts/application.html.erb +0 -14
- data/test/rails/three/app/views/things/index.xls.osheet +0 -13
- data/test/rails/three/config/application.rb +0 -42
- data/test/rails/three/config/boot.rb +0 -13
- data/test/rails/three/config/database.yml +0 -22
- data/test/rails/three/config/environment.rb +0 -5
- data/test/rails/three/config/environments/development.rb +0 -26
- data/test/rails/three/config/environments/production.rb +0 -49
- data/test/rails/three/config/environments/test.rb +0 -35
- data/test/rails/three/config/initializers/app.rb +0 -0
- data/test/rails/three/config/initializers/backtrace_silencers.rb +0 -7
- data/test/rails/three/config/initializers/inflections.rb +0 -10
- data/test/rails/three/config/initializers/mime_types.rb +0 -5
- data/test/rails/three/config/initializers/secret_token.rb +0 -7
- data/test/rails/three/config/initializers/session_store.rb +0 -8
- data/test/rails/three/config/locales/en.yml +0 -5
- data/test/rails/three/config/routes.rb +0 -3
- data/test/rails/three/config.ru +0 -4
- data/test/rails/three/db/seeds.rb +0 -7
- data/test/rails/three/doc/README_FOR_APP +0 -2
- data/test/rails/three/lib/tasks/.gitkeep +0 -0
- data/test/rails/three/script/rails +0 -6
- data/test/rails/two/.bundle/config +0 -2
- data/test/rails/two/Booting +0 -0
- data/test/rails/two/Gemfile +0 -5
- data/test/rails/two/Gemfile.lock +0 -45
- data/test/rails/two/Rails +0 -0
- data/test/rails/two/app/controllers/application_controller.rb +0 -20
- data/test/rails/two/app/controllers/things_controller.rb +0 -10
- data/test/rails/two/app/helpers/application_helper.rb +0 -3
- data/test/rails/two/app/views/things/index.xls.osheet +0 -15
- data/test/rails/two/config/boot.rb +0 -128
- data/test/rails/two/config/database.yml +0 -22
- data/test/rails/two/config/environment.rb +0 -41
- data/test/rails/two/config/environments/development.rb +0 -17
- data/test/rails/two/config/environments/production.rb +0 -28
- data/test/rails/two/config/environments/test.rb +0 -28
- data/test/rails/two/config/initializers/app.rb +0 -2
- data/test/rails/two/config/initializers/backtrace_silencers.rb +0 -7
- data/test/rails/two/config/initializers/cookie_verification_secret.rb +0 -7
- data/test/rails/two/config/initializers/inflections.rb +0 -10
- data/test/rails/two/config/initializers/mime_types.rb +0 -5
- data/test/rails/two/config/initializers/new_rails_defaults.rb +0 -21
- data/test/rails/two/config/initializers/session_store.rb +0 -15
- data/test/rails/two/config/locales/en.yml +0 -5
- data/test/rails/two/config/routes.rb +0 -3
- data/test/rails/two/db/development.sqlite3 +0 -0
- data/test/rails/two/db/seeds.rb +0 -7
- data/test/rails/two/script/about +0 -4
- data/test/rails/two/script/console +0 -3
- data/test/rails/two/script/dbconsole +0 -3
- data/test/rails/two/script/destroy +0 -3
- data/test/rails/two/script/generate +0 -3
- data/test/rails/two/script/performance/benchmarker +0 -3
- data/test/rails/two/script/performance/profiler +0 -3
- data/test/rails/two/script/plugin +0 -3
- data/test/rails/two/script/runner +0 -3
- data/test/rails/two/script/server +0 -3
- data/test/rails/two/tmp/pids/server.pid +0 -1
- data/test/rails_test.rb +0 -38
- data/test/sinatra/app.rb +0 -16
- data/test/sinatra/views/index.osheet +0 -13
- data/test/sinatra_test.rb +0 -19
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "assert"
|
|
2
2
|
require 'osheet/format/fraction'
|
|
3
3
|
|
|
4
4
|
module Osheet::Format
|
|
5
5
|
|
|
6
|
-
class FractionTest <
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
class FractionTest < Assert::Context
|
|
7
|
+
desc "Fraction format"
|
|
8
|
+
before { @f = Fraction.new }
|
|
9
|
+
subject { @f }
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
should have_accessors :type
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
should "set default values" do
|
|
23
|
-
assert_equal '??/??', subject.type
|
|
24
|
-
assert_equal :two_digits, subject.type_key
|
|
13
|
+
should "provide options for type" do
|
|
14
|
+
assert_equal 9, Fraction.type_set.size
|
|
15
|
+
[ :one_digit, :two_digits, :three_digits,
|
|
16
|
+
:halves, :quarters, :eighths, :sixteenths,
|
|
17
|
+
:tenths, :hundredths
|
|
18
|
+
].each do |a|
|
|
19
|
+
assert Fraction.type_set.include?(a)
|
|
25
20
|
end
|
|
21
|
+
end
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
end
|
|
23
|
+
should "set default values" do
|
|
24
|
+
assert_equal '??/??', subject.type
|
|
25
|
+
assert_equal :two_digits, subject.type_key
|
|
26
|
+
end
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
should "generate a one_digit type style strings and key" do
|
|
29
|
+
f = Fraction.new(:type => :one_digit)
|
|
30
|
+
assert_equal "#\ ?/?", f.style
|
|
31
|
+
assert_equal "fraction_onedigit", f.key
|
|
32
|
+
end
|
|
38
33
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
should "generate a two_digit type style strings and key" do
|
|
35
|
+
f = Fraction.new(:type => :two_digits)
|
|
36
|
+
assert_equal "#\ ??/??", f.style
|
|
37
|
+
assert_equal "fraction_twodigits", f.key
|
|
38
|
+
end
|
|
44
39
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
should "generate a three_digit type style strings and key" do
|
|
41
|
+
f = Fraction.new(:type => :three_digits)
|
|
42
|
+
assert_equal "#\ ???/???", f.style
|
|
43
|
+
assert_equal "fraction_threedigits", f.key
|
|
44
|
+
end
|
|
50
45
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
should "generate a halves type style strings and key" do
|
|
47
|
+
f = Fraction.new(:type => :halves)
|
|
48
|
+
assert_equal "#\ ?/2", f.style
|
|
49
|
+
assert_equal "fraction_halves", f.key
|
|
50
|
+
end
|
|
56
51
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
should "generate a quarters type style strings and key" do
|
|
53
|
+
f = Fraction.new(:type => :quarters)
|
|
54
|
+
assert_equal "#\ ?/4", f.style
|
|
55
|
+
assert_equal "fraction_quarters", f.key
|
|
56
|
+
end
|
|
62
57
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
should "generate a eighths type style strings and key" do
|
|
59
|
+
f = Fraction.new(:type => :eighths)
|
|
60
|
+
assert_equal "#\ ?/8", f.style
|
|
61
|
+
assert_equal "fraction_eighths", f.key
|
|
62
|
+
end
|
|
68
63
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
should "generate a sixteenths type style strings and key" do
|
|
65
|
+
f = Fraction.new(:type => :sixteenths)
|
|
66
|
+
assert_equal "#\ ??/16", f.style
|
|
67
|
+
assert_equal "fraction_sixteenths", f.key
|
|
68
|
+
end
|
|
74
69
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
should "generate a tenths type style strings and key" do
|
|
71
|
+
f = Fraction.new(:type => :tenths)
|
|
72
|
+
assert_equal "#\ ?/10", f.style
|
|
73
|
+
assert_equal "fraction_tenths", f.key
|
|
74
|
+
end
|
|
80
75
|
|
|
76
|
+
should "generate a hundredths type style strings and key" do
|
|
77
|
+
f = Fraction.new(:type => :hundredths)
|
|
78
|
+
assert_equal "#\ ??/100", f.style
|
|
79
|
+
assert_equal "fraction_hundredths", f.key
|
|
81
80
|
end
|
|
81
|
+
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
end
|
data/test/format/general_test.rb
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "assert"
|
|
2
2
|
require 'osheet/format/general'
|
|
3
3
|
|
|
4
4
|
module Osheet::Format
|
|
5
5
|
|
|
6
|
-
class GeneralTest <
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
class GeneralTest < Assert::Context
|
|
7
|
+
desc "General format"
|
|
8
|
+
before { @f = General.new }
|
|
9
|
+
subject { @f }
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
should "always provide and empty format key" do
|
|
15
|
-
assert_equal '', subject.key
|
|
16
|
-
end
|
|
11
|
+
should "always provide a nil style string" do
|
|
12
|
+
assert_equal nil, subject.style
|
|
13
|
+
end
|
|
17
14
|
|
|
15
|
+
should "always provide and empty format key" do
|
|
16
|
+
assert_equal '', subject.key
|
|
18
17
|
end
|
|
18
|
+
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
end
|
data/test/format/number_test.rb
CHANGED
|
@@ -1,93 +1,91 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "assert"
|
|
2
2
|
require 'osheet/format/number'
|
|
3
3
|
|
|
4
4
|
module Osheet::Format
|
|
5
5
|
|
|
6
|
-
class NumberTest <
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
class NumberTest < Assert::Context
|
|
7
|
+
desc "Number format"
|
|
8
|
+
before { @n = Number.new }
|
|
9
|
+
subject { @n }
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
should have_accessors :decimal_places, :comma_separator, :negative_numbers
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
end
|
|
13
|
+
should "provide options for negative numbers" do
|
|
14
|
+
assert_equal 4, Number.negative_numbers_set.size
|
|
15
|
+
[:black, :black_parenth, :red, :red_parenth].each do |a|
|
|
16
|
+
assert Number.negative_numbers_set.include?(a)
|
|
17
17
|
end
|
|
18
|
+
end
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
should "set default values" do
|
|
21
|
+
assert_equal 0, subject.decimal_places
|
|
22
|
+
assert_equal false, subject.comma_separator
|
|
23
|
+
assert_equal :black, subject.negative_numbers
|
|
24
|
+
end
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
end
|
|
29
|
-
assert_raises ArgumentError do
|
|
30
|
-
Number.new({:decimal_places => 31})
|
|
31
|
-
end
|
|
32
|
-
assert_raises ArgumentError do
|
|
33
|
-
Number.new({:decimal_places => 'poo'})
|
|
34
|
-
end
|
|
35
|
-
assert_nothing_raised do
|
|
36
|
-
Number.new({:decimal_places => 1})
|
|
37
|
-
end
|
|
26
|
+
should "only allow Fixnum decimal places between 0 and 30" do
|
|
27
|
+
assert_raises ArgumentError do
|
|
28
|
+
Number.new({:decimal_places => -1})
|
|
38
29
|
end
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
assert_equal "0", Number.new({:decimal_places => 0}).style
|
|
42
|
-
(1..5).each do |n|
|
|
43
|
-
assert_equal "0.#{'0'*n}", Number.new({:decimal_places => n}).style
|
|
44
|
-
end
|
|
30
|
+
assert_raises ArgumentError do
|
|
31
|
+
Number.new({:decimal_places => 31})
|
|
45
32
|
end
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
assert_equal "0", Number.new({:comma_separator => false}).style
|
|
49
|
-
assert_equal "#,##0", Number.new({:comma_separator => true}).style
|
|
33
|
+
assert_raises ArgumentError do
|
|
34
|
+
Number.new({:decimal_places => 'poo'})
|
|
50
35
|
end
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
assert_equal "0", Number.new({:negative_numbers => :black}).style
|
|
54
|
-
assert_equal "0_);\(0\)", Number.new({:negative_numbers => :black_parenth}).style
|
|
36
|
+
assert_nothing_raised do
|
|
37
|
+
Number.new({:decimal_places => 1})
|
|
55
38
|
end
|
|
39
|
+
end
|
|
56
40
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
41
|
+
should "generate decimal place style strings" do
|
|
42
|
+
assert_equal "0", Number.new({:decimal_places => 0}).style
|
|
43
|
+
(1..5).each do |n|
|
|
44
|
+
assert_equal "0.#{'0'*n}", Number.new({:decimal_places => n}).style
|
|
60
45
|
end
|
|
46
|
+
end
|
|
61
47
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
:comma_separator => false
|
|
67
|
-
}).style)
|
|
68
|
-
assert_equal("#,##0.0000_);[Red]\(#,##0.0000\)", Number.new({
|
|
69
|
-
:decimal_places => 4,
|
|
70
|
-
:negative_numbers => :red_parenth,
|
|
71
|
-
:comma_separator => true
|
|
72
|
-
}).style)
|
|
73
|
-
end
|
|
48
|
+
should "generate comma separator style strings" do
|
|
49
|
+
assert_equal "0", Number.new({:comma_separator => false}).style
|
|
50
|
+
assert_equal "#,##0", Number.new({:comma_separator => true}).style
|
|
51
|
+
end
|
|
74
52
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
:comma_separator => false
|
|
80
|
-
}).key)
|
|
81
|
-
assert_equal("number_none_4_comma_redparenth", Number.new({
|
|
82
|
-
:decimal_places => 4,
|
|
83
|
-
:negative_numbers => :red_parenth,
|
|
84
|
-
:comma_separator => true
|
|
85
|
-
}).key)
|
|
86
|
-
end
|
|
53
|
+
should "generate parenth negative numbers style strings" do
|
|
54
|
+
assert_equal "0", Number.new({:negative_numbers => :black}).style
|
|
55
|
+
assert_equal "0_);\(0\)", Number.new({:negative_numbers => :black_parenth}).style
|
|
56
|
+
end
|
|
87
57
|
|
|
58
|
+
should "generate red negative numbers style strings" do
|
|
59
|
+
assert_equal "0;[Red]0", Number.new({:negative_numbers => :red}).style
|
|
60
|
+
assert_equal "0_);[Red]\(0\)", Number.new({:negative_numbers => :red_parenth}).style
|
|
61
|
+
end
|
|
88
62
|
|
|
63
|
+
should "generate complex style string" do
|
|
64
|
+
assert_equal("0.00_);\(0.00\)", Number.new({
|
|
65
|
+
:decimal_places => 2,
|
|
66
|
+
:negative_numbers => :black_parenth,
|
|
67
|
+
:comma_separator => false
|
|
68
|
+
}).style)
|
|
69
|
+
assert_equal("#,##0.0000_);[Red]\(#,##0.0000\)", Number.new({
|
|
70
|
+
:decimal_places => 4,
|
|
71
|
+
:negative_numbers => :red_parenth,
|
|
72
|
+
:comma_separator => true
|
|
73
|
+
}).style)
|
|
74
|
+
end
|
|
89
75
|
|
|
76
|
+
should "provide unique format keys" do
|
|
77
|
+
assert_equal("number_none_2_nocomma_blackparenth", Number.new({
|
|
78
|
+
:decimal_places => 2,
|
|
79
|
+
:negative_numbers => :black_parenth,
|
|
80
|
+
:comma_separator => false
|
|
81
|
+
}).key)
|
|
82
|
+
assert_equal("number_none_4_comma_redparenth", Number.new({
|
|
83
|
+
:decimal_places => 4,
|
|
84
|
+
:negative_numbers => :red_parenth,
|
|
85
|
+
:comma_separator => true
|
|
86
|
+
}).key)
|
|
90
87
|
end
|
|
88
|
+
|
|
91
89
|
end
|
|
92
90
|
|
|
93
91
|
end
|
|
@@ -1,116 +1,114 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "assert"
|
|
2
2
|
require 'osheet/format/percentage'
|
|
3
3
|
|
|
4
4
|
module Osheet::Format
|
|
5
5
|
|
|
6
|
-
class PercentageTest <
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
class PercentageTest < Assert::Context
|
|
7
|
+
desc "Percentage format"
|
|
8
|
+
before { @p = Percentage.new }
|
|
9
|
+
subject { @p }
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
should have_accessors :decimal_places, :symbol, :comma_separator, :negative_numbers
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
end
|
|
13
|
+
should "provide negative numbers options" do
|
|
14
|
+
assert_equal 4, Percentage.negative_numbers_set.size
|
|
15
|
+
[:black, :black_parenth, :red, :red_parenth].each do |a|
|
|
16
|
+
assert Percentage.negative_numbers_set.include?(a)
|
|
17
17
|
end
|
|
18
|
+
end
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
should "set default values" do
|
|
21
|
+
assert_equal 2, subject.decimal_places
|
|
22
|
+
assert_equal false, subject.comma_separator
|
|
23
|
+
assert_equal :black, subject.negative_numbers
|
|
24
|
+
end
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
end
|
|
29
|
-
assert_raises ArgumentError do
|
|
30
|
-
Percentage.new({:decimal_places => 31})
|
|
31
|
-
end
|
|
32
|
-
assert_raises ArgumentError do
|
|
33
|
-
Percentage.new({:decimal_places => 'poo'})
|
|
34
|
-
end
|
|
35
|
-
assert_nothing_raised do
|
|
36
|
-
Percentage.new({:decimal_places => 1})
|
|
37
|
-
end
|
|
26
|
+
should "only allow Fixnum decimal places between 0 and 30" do
|
|
27
|
+
assert_raises ArgumentError do
|
|
28
|
+
Percentage.new({:decimal_places => -1})
|
|
38
29
|
end
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
assert_equal "0%", Percentage.new({
|
|
42
|
-
:decimal_places => 0
|
|
43
|
-
}).style
|
|
44
|
-
(1..5).each do |n|
|
|
45
|
-
assert_equal "0.#{'0'*n}%", Percentage.new({
|
|
46
|
-
:decimal_places => n
|
|
47
|
-
}).style
|
|
48
|
-
end
|
|
30
|
+
assert_raises ArgumentError do
|
|
31
|
+
Percentage.new({:decimal_places => 31})
|
|
49
32
|
end
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
assert_equal "0%", Percentage.new({
|
|
53
|
-
:comma_separator => false,
|
|
54
|
-
:decimal_places => 0
|
|
55
|
-
}).style
|
|
56
|
-
assert_equal "#,##0%", Percentage.new({
|
|
57
|
-
:comma_separator => true,
|
|
58
|
-
:decimal_places => 0
|
|
59
|
-
}).style
|
|
33
|
+
assert_raises ArgumentError do
|
|
34
|
+
Percentage.new({:decimal_places => 'poo'})
|
|
60
35
|
end
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
assert_equal "0%", Percentage.new({
|
|
64
|
-
:negative_numbers => :black,
|
|
65
|
-
:decimal_places => 0
|
|
66
|
-
}).style
|
|
67
|
-
assert_equal "0%_);\(0%\)", Percentage.new({
|
|
68
|
-
:negative_numbers => :black_parenth,
|
|
69
|
-
:decimal_places => 0
|
|
70
|
-
}).style
|
|
36
|
+
assert_nothing_raised do
|
|
37
|
+
Percentage.new({:decimal_places => 1})
|
|
71
38
|
end
|
|
39
|
+
end
|
|
72
40
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
assert_equal "0%
|
|
79
|
-
:
|
|
80
|
-
:decimal_places => 0
|
|
41
|
+
should "generate decimal place style strings" do
|
|
42
|
+
assert_equal "0%", Percentage.new({
|
|
43
|
+
:decimal_places => 0
|
|
44
|
+
}).style
|
|
45
|
+
(1..5).each do |n|
|
|
46
|
+
assert_equal "0.#{'0'*n}%", Percentage.new({
|
|
47
|
+
:decimal_places => n
|
|
81
48
|
}).style
|
|
82
49
|
end
|
|
50
|
+
end
|
|
83
51
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}).style)
|
|
95
|
-
end
|
|
52
|
+
should "generate comma separator style strings" do
|
|
53
|
+
assert_equal "0%", Percentage.new({
|
|
54
|
+
:comma_separator => false,
|
|
55
|
+
:decimal_places => 0
|
|
56
|
+
}).style
|
|
57
|
+
assert_equal "#,##0%", Percentage.new({
|
|
58
|
+
:comma_separator => true,
|
|
59
|
+
:decimal_places => 0
|
|
60
|
+
}).style
|
|
61
|
+
end
|
|
96
62
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
:comma_separator => true
|
|
108
|
-
}).key)
|
|
109
|
-
end
|
|
63
|
+
should "generate parenth negative numbers style strings" do
|
|
64
|
+
assert_equal "0%", Percentage.new({
|
|
65
|
+
:negative_numbers => :black,
|
|
66
|
+
:decimal_places => 0
|
|
67
|
+
}).style
|
|
68
|
+
assert_equal "0%_);\(0%\)", Percentage.new({
|
|
69
|
+
:negative_numbers => :black_parenth,
|
|
70
|
+
:decimal_places => 0
|
|
71
|
+
}).style
|
|
72
|
+
end
|
|
110
73
|
|
|
74
|
+
should "generate red negative numbers style strings" do
|
|
75
|
+
assert_equal "0%;[Red]0%", Percentage.new({
|
|
76
|
+
:negative_numbers => :red,
|
|
77
|
+
:decimal_places => 0
|
|
78
|
+
}).style
|
|
79
|
+
assert_equal "0%_);[Red]\(0%\)", Percentage.new({
|
|
80
|
+
:negative_numbers => :red_parenth,
|
|
81
|
+
:decimal_places => 0
|
|
82
|
+
}).style
|
|
83
|
+
end
|
|
111
84
|
|
|
85
|
+
should "generate complex style string" do
|
|
86
|
+
assert_equal("0.00%_);\(0.00%\)", Percentage.new({
|
|
87
|
+
:decimal_places => 2,
|
|
88
|
+
:negative_numbers => :black_parenth,
|
|
89
|
+
:comma_separator => false
|
|
90
|
+
}).style)
|
|
91
|
+
assert_equal("#,##0.0000%_);[Red]\(#,##0.0000%\)", Percentage.new({
|
|
92
|
+
:decimal_places => 4,
|
|
93
|
+
:negative_numbers => :red_parenth,
|
|
94
|
+
:comma_separator => true
|
|
95
|
+
}).style)
|
|
96
|
+
end
|
|
112
97
|
|
|
98
|
+
should "provide unique format keys" do
|
|
99
|
+
assert_equal("percentage_none_2_nocomma_blackparenth", Percentage.new({
|
|
100
|
+
:decimal_places => 2,
|
|
101
|
+
:negative_numbers => :black_parenth,
|
|
102
|
+
:comma_separator => false
|
|
103
|
+
}).key)
|
|
104
|
+
assert_equal("percentage_none_4_comma_redparenth", Percentage.new({
|
|
105
|
+
:symbol => :none,
|
|
106
|
+
:decimal_places => 4,
|
|
107
|
+
:negative_numbers => :red_parenth,
|
|
108
|
+
:comma_separator => true
|
|
109
|
+
}).key)
|
|
113
110
|
end
|
|
111
|
+
|
|
114
112
|
end
|
|
115
113
|
|
|
116
114
|
end
|