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,158 +1,145 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "assert"
|
|
2
2
|
require 'osheet/format/accounting'
|
|
3
3
|
|
|
4
4
|
module Osheet::Format
|
|
5
5
|
|
|
6
|
-
class AccountingTest <
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
class AccountingTest < Assert::Context
|
|
7
|
+
desc "Accounting format"
|
|
8
|
+
before { @f = Accounting.new }
|
|
9
|
+
subject { @f }
|
|
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 symbol options" do
|
|
14
|
+
assert_equal 3, Accounting.symbol_set.size
|
|
15
|
+
[:none, :dollar, :euro].each do |a|
|
|
16
|
+
assert Accounting.symbol_set.include?(a)
|
|
17
17
|
end
|
|
18
|
+
end
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
end
|
|
20
|
+
should "provide negative numbers options" do
|
|
21
|
+
assert_equal 4, Accounting.negative_numbers_set.size
|
|
22
|
+
[:black, :black_parenth, :red, :red_parenth].each do |a|
|
|
23
|
+
assert Accounting.negative_numbers_set.include?(a)
|
|
24
24
|
end
|
|
25
|
+
end
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
should "set default values" do
|
|
28
|
+
assert_equal 2, subject.decimal_places
|
|
29
|
+
assert_equal :dollar, subject.symbol
|
|
30
|
+
assert_equal true, subject.comma_separator
|
|
31
|
+
assert_equal :black, subject.negative_numbers
|
|
32
|
+
end
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
end
|
|
37
|
-
assert_raises ArgumentError do
|
|
38
|
-
Accounting.new({:decimal_places => 31})
|
|
39
|
-
end
|
|
40
|
-
assert_raises ArgumentError do
|
|
41
|
-
Accounting.new({:decimal_places => 'poo'})
|
|
42
|
-
end
|
|
43
|
-
assert_nothing_raised do
|
|
44
|
-
Accounting.new({:decimal_places => 1})
|
|
45
|
-
end
|
|
34
|
+
should "only allow Fixnum decimal places between 0 and 30" do
|
|
35
|
+
assert_raises ArgumentError do
|
|
36
|
+
Accounting.new({:decimal_places => -1})
|
|
46
37
|
end
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
assert_equal "0", Accounting.new({
|
|
50
|
-
:decimal_places => 0,
|
|
51
|
-
:comma_separator => false,
|
|
52
|
-
:symbol => :none
|
|
53
|
-
}).style
|
|
54
|
-
(1..5).each do |n|
|
|
55
|
-
assert_equal "0.#{'0'*n}", Accounting.new({
|
|
56
|
-
:decimal_places => n,
|
|
57
|
-
:comma_separator => false,
|
|
58
|
-
:symbol => :none
|
|
59
|
-
}).style
|
|
60
|
-
end
|
|
38
|
+
assert_raises ArgumentError do
|
|
39
|
+
Accounting.new({:decimal_places => 31})
|
|
61
40
|
end
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
assert_equal "0", Accounting.new({
|
|
65
|
-
:comma_separator => false,
|
|
66
|
-
:decimal_places => 0,
|
|
67
|
-
:symbol => :none
|
|
68
|
-
}).style
|
|
69
|
-
assert_equal "#,##0", Accounting.new({
|
|
70
|
-
:comma_separator => true,
|
|
71
|
-
:decimal_places => 0,
|
|
72
|
-
:symbol => :none
|
|
73
|
-
}).style
|
|
41
|
+
assert_raises ArgumentError do
|
|
42
|
+
Accounting.new({:decimal_places => 'poo'})
|
|
74
43
|
end
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
assert_equal "0", Accounting.new({
|
|
78
|
-
:negative_numbers => :black,
|
|
79
|
-
:decimal_places => 0,
|
|
80
|
-
:comma_separator => false,
|
|
81
|
-
:symbol => :none
|
|
82
|
-
}).style
|
|
83
|
-
assert_equal "0_);\(0\)", Accounting.new({
|
|
84
|
-
:negative_numbers => :black_parenth,
|
|
85
|
-
:decimal_places => 0,
|
|
86
|
-
:comma_separator => false,
|
|
87
|
-
:symbol => :none
|
|
88
|
-
}).style
|
|
44
|
+
assert_nothing_raised do
|
|
45
|
+
Accounting.new({:decimal_places => 1})
|
|
89
46
|
end
|
|
47
|
+
end
|
|
90
48
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
assert_equal "
|
|
99
|
-
:
|
|
100
|
-
:decimal_places => 0,
|
|
49
|
+
should "generate decimal place style strings" do
|
|
50
|
+
assert_equal "0", Accounting.new({
|
|
51
|
+
:decimal_places => 0,
|
|
52
|
+
:comma_separator => false,
|
|
53
|
+
:symbol => :none
|
|
54
|
+
}).style
|
|
55
|
+
(1..5).each do |n|
|
|
56
|
+
assert_equal "0.#{'0'*n}", Accounting.new({
|
|
57
|
+
:decimal_places => n,
|
|
101
58
|
:comma_separator => false,
|
|
102
59
|
:symbol => :none
|
|
103
60
|
}).style
|
|
104
61
|
end
|
|
62
|
+
end
|
|
105
63
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
:decimal_places => 0,
|
|
119
|
-
:comma_separator => false,
|
|
120
|
-
:symbol => :euro
|
|
121
|
-
}).style
|
|
122
|
-
end
|
|
64
|
+
should "generate comma separator style strings" do
|
|
65
|
+
assert_equal "0", Accounting.new({
|
|
66
|
+
:comma_separator => false,
|
|
67
|
+
:decimal_places => 0,
|
|
68
|
+
:symbol => :none
|
|
69
|
+
}).style
|
|
70
|
+
assert_equal "#,##0", Accounting.new({
|
|
71
|
+
:comma_separator => true,
|
|
72
|
+
:decimal_places => 0,
|
|
73
|
+
:symbol => :none
|
|
74
|
+
}).style
|
|
75
|
+
end
|
|
123
76
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
77
|
+
should "generate parenth negative numbers style strings" do
|
|
78
|
+
assert_equal "0", Accounting.new({
|
|
79
|
+
:negative_numbers => :black,
|
|
80
|
+
:decimal_places => 0,
|
|
81
|
+
:comma_separator => false,
|
|
82
|
+
:symbol => :none
|
|
83
|
+
}).style
|
|
84
|
+
assert_equal "0_);\(0\)", Accounting.new({
|
|
85
|
+
:negative_numbers => :black_parenth,
|
|
86
|
+
:decimal_places => 0,
|
|
87
|
+
:comma_separator => false,
|
|
88
|
+
:symbol => :none
|
|
89
|
+
}).style
|
|
90
|
+
end
|
|
138
91
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
92
|
+
should "generate red negative numbers style strings" do
|
|
93
|
+
assert_equal "0;[Red]0", Accounting.new({
|
|
94
|
+
:negative_numbers => :red,
|
|
95
|
+
:decimal_places => 0,
|
|
96
|
+
:comma_separator => false,
|
|
97
|
+
:symbol => :none
|
|
98
|
+
}).style
|
|
99
|
+
assert_equal "0_);[Red]\(0\)", Accounting.new({
|
|
100
|
+
:negative_numbers => :red_parenth,
|
|
101
|
+
:decimal_places => 0,
|
|
102
|
+
:comma_separator => false,
|
|
103
|
+
:symbol => :none
|
|
104
|
+
}).style
|
|
105
|
+
end
|
|
152
106
|
|
|
107
|
+
should "generate symbol style strings" do
|
|
108
|
+
assert_equal "0", Accounting.new({
|
|
109
|
+
:decimal_places => 0,
|
|
110
|
+
:comma_separator => false,
|
|
111
|
+
:symbol => :none
|
|
112
|
+
}).style
|
|
113
|
+
assert_equal "\"$\"* 0", Accounting.new({
|
|
114
|
+
:decimal_places => 0,
|
|
115
|
+
:comma_separator => false,
|
|
116
|
+
:symbol => :dollar
|
|
117
|
+
}).style
|
|
118
|
+
end
|
|
153
119
|
|
|
120
|
+
should "generate complex style string" do
|
|
121
|
+
assert_equal("\"$\"* 0.00_);\(\"$\"* 0.00\)", Accounting.new({
|
|
122
|
+
:symbol => :dollar,
|
|
123
|
+
:decimal_places => 2,
|
|
124
|
+
:negative_numbers => :black_parenth,
|
|
125
|
+
:comma_separator => false
|
|
126
|
+
}).style)
|
|
127
|
+
end
|
|
154
128
|
|
|
129
|
+
should "provide unique format keys" do
|
|
130
|
+
assert_equal("accounting_dollar_2_nocomma_blackparenth", Accounting.new({
|
|
131
|
+
:decimal_places => 2,
|
|
132
|
+
:negative_numbers => :black_parenth,
|
|
133
|
+
:comma_separator => false
|
|
134
|
+
}).key)
|
|
135
|
+
assert_equal("accounting_none_4_comma_redparenth", Accounting.new({
|
|
136
|
+
:symbol => :none,
|
|
137
|
+
:decimal_places => 4,
|
|
138
|
+
:negative_numbers => :red_parenth,
|
|
139
|
+
:comma_separator => true
|
|
140
|
+
}).key)
|
|
155
141
|
end
|
|
142
|
+
|
|
156
143
|
end
|
|
157
144
|
|
|
158
145
|
end
|
|
@@ -1,158 +1,145 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "assert"
|
|
2
2
|
require 'osheet/format/currency'
|
|
3
3
|
|
|
4
4
|
module Osheet::Format
|
|
5
5
|
|
|
6
|
-
class CurrencyTest <
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
class CurrencyTest < Assert::Context
|
|
7
|
+
desc "Currency format"
|
|
8
|
+
before { @f = Currency.new }
|
|
9
|
+
subject { @f }
|
|
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 symbol options" do
|
|
14
|
+
assert_equal 3, Currency.symbol_set.size
|
|
15
|
+
[:none, :dollar, :euro].each do |a|
|
|
16
|
+
assert Currency.symbol_set.include?(a)
|
|
17
17
|
end
|
|
18
|
+
end
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
end
|
|
20
|
+
should "provide negative numbers options" do
|
|
21
|
+
assert_equal 4, Currency.negative_numbers_set.size
|
|
22
|
+
[:black, :black_parenth, :red, :red_parenth].each do |a|
|
|
23
|
+
assert Currency.negative_numbers_set.include?(a)
|
|
24
24
|
end
|
|
25
|
+
end
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
should "set default values" do
|
|
28
|
+
assert_equal 2, subject.decimal_places
|
|
29
|
+
assert_equal :dollar, subject.symbol
|
|
30
|
+
assert_equal true, subject.comma_separator
|
|
31
|
+
assert_equal :black, subject.negative_numbers
|
|
32
|
+
end
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
end
|
|
37
|
-
assert_raises ArgumentError do
|
|
38
|
-
Currency.new({:decimal_places => 31})
|
|
39
|
-
end
|
|
40
|
-
assert_raises ArgumentError do
|
|
41
|
-
Currency.new({:decimal_places => 'poo'})
|
|
42
|
-
end
|
|
43
|
-
assert_nothing_raised do
|
|
44
|
-
Currency.new({:decimal_places => 1})
|
|
45
|
-
end
|
|
34
|
+
should "only allow Fixnum decimal places between 0 and 30" do
|
|
35
|
+
assert_raises ArgumentError do
|
|
36
|
+
Currency.new({:decimal_places => -1})
|
|
46
37
|
end
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
assert_equal "0", Currency.new({
|
|
50
|
-
:decimal_places => 0,
|
|
51
|
-
:comma_separator => false,
|
|
52
|
-
:symbol => :none
|
|
53
|
-
}).style
|
|
54
|
-
(1..5).each do |n|
|
|
55
|
-
assert_equal "0.#{'0'*n}", Currency.new({
|
|
56
|
-
:decimal_places => n,
|
|
57
|
-
:comma_separator => false,
|
|
58
|
-
:symbol => :none
|
|
59
|
-
}).style
|
|
60
|
-
end
|
|
38
|
+
assert_raises ArgumentError do
|
|
39
|
+
Currency.new({:decimal_places => 31})
|
|
61
40
|
end
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
assert_equal "0", Currency.new({
|
|
65
|
-
:comma_separator => false,
|
|
66
|
-
:decimal_places => 0,
|
|
67
|
-
:symbol => :none
|
|
68
|
-
}).style
|
|
69
|
-
assert_equal "#,##0", Currency.new({
|
|
70
|
-
:comma_separator => true,
|
|
71
|
-
:decimal_places => 0,
|
|
72
|
-
:symbol => :none
|
|
73
|
-
}).style
|
|
41
|
+
assert_raises ArgumentError do
|
|
42
|
+
Currency.new({:decimal_places => 'poo'})
|
|
74
43
|
end
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
assert_equal "0", Currency.new({
|
|
78
|
-
:negative_numbers => :black,
|
|
79
|
-
:decimal_places => 0,
|
|
80
|
-
:comma_separator => false,
|
|
81
|
-
:symbol => :none
|
|
82
|
-
}).style
|
|
83
|
-
assert_equal "0_);\(0\)", Currency.new({
|
|
84
|
-
:negative_numbers => :black_parenth,
|
|
85
|
-
:decimal_places => 0,
|
|
86
|
-
:comma_separator => false,
|
|
87
|
-
:symbol => :none
|
|
88
|
-
}).style
|
|
44
|
+
assert_nothing_raised do
|
|
45
|
+
Currency.new({:decimal_places => 1})
|
|
89
46
|
end
|
|
47
|
+
end
|
|
90
48
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
assert_equal "
|
|
99
|
-
:
|
|
100
|
-
:decimal_places => 0,
|
|
49
|
+
should "generate decimal place style strings" do
|
|
50
|
+
assert_equal "0", Currency.new({
|
|
51
|
+
:decimal_places => 0,
|
|
52
|
+
:comma_separator => false,
|
|
53
|
+
:symbol => :none
|
|
54
|
+
}).style
|
|
55
|
+
(1..5).each do |n|
|
|
56
|
+
assert_equal "0.#{'0'*n}", Currency.new({
|
|
57
|
+
:decimal_places => n,
|
|
101
58
|
:comma_separator => false,
|
|
102
59
|
:symbol => :none
|
|
103
60
|
}).style
|
|
104
61
|
end
|
|
62
|
+
end
|
|
105
63
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
:decimal_places => 0,
|
|
119
|
-
:comma_separator => false,
|
|
120
|
-
:symbol => :euro
|
|
121
|
-
}).style
|
|
122
|
-
end
|
|
64
|
+
should "generate comma separator style strings" do
|
|
65
|
+
assert_equal "0", Currency.new({
|
|
66
|
+
:comma_separator => false,
|
|
67
|
+
:decimal_places => 0,
|
|
68
|
+
:symbol => :none
|
|
69
|
+
}).style
|
|
70
|
+
assert_equal "#,##0", Currency.new({
|
|
71
|
+
:comma_separator => true,
|
|
72
|
+
:decimal_places => 0,
|
|
73
|
+
:symbol => :none
|
|
74
|
+
}).style
|
|
75
|
+
end
|
|
123
76
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
77
|
+
should "generate parenth negative numbers style strings" do
|
|
78
|
+
assert_equal "0", Currency.new({
|
|
79
|
+
:negative_numbers => :black,
|
|
80
|
+
:decimal_places => 0,
|
|
81
|
+
:comma_separator => false,
|
|
82
|
+
:symbol => :none
|
|
83
|
+
}).style
|
|
84
|
+
assert_equal "0_);\(0\)", Currency.new({
|
|
85
|
+
:negative_numbers => :black_parenth,
|
|
86
|
+
:decimal_places => 0,
|
|
87
|
+
:comma_separator => false,
|
|
88
|
+
:symbol => :none
|
|
89
|
+
}).style
|
|
90
|
+
end
|
|
138
91
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
92
|
+
should "generate red negative numbers style strings" do
|
|
93
|
+
assert_equal "0;[Red]0", Currency.new({
|
|
94
|
+
:negative_numbers => :red,
|
|
95
|
+
:decimal_places => 0,
|
|
96
|
+
:comma_separator => false,
|
|
97
|
+
:symbol => :none
|
|
98
|
+
}).style
|
|
99
|
+
assert_equal "0_);[Red]\(0\)", Currency.new({
|
|
100
|
+
:negative_numbers => :red_parenth,
|
|
101
|
+
:decimal_places => 0,
|
|
102
|
+
:comma_separator => false,
|
|
103
|
+
:symbol => :none
|
|
104
|
+
}).style
|
|
105
|
+
end
|
|
152
106
|
|
|
107
|
+
should "generate symbol style strings" do
|
|
108
|
+
assert_equal "0", Currency.new({
|
|
109
|
+
:decimal_places => 0,
|
|
110
|
+
:comma_separator => false,
|
|
111
|
+
:symbol => :none
|
|
112
|
+
}).style
|
|
113
|
+
assert_equal "\"$\"0", Currency.new({
|
|
114
|
+
:decimal_places => 0,
|
|
115
|
+
:comma_separator => false,
|
|
116
|
+
:symbol => :dollar
|
|
117
|
+
}).style
|
|
118
|
+
end
|
|
153
119
|
|
|
120
|
+
should "generate complex style string" do
|
|
121
|
+
assert_equal("\"$\"0.00_);\(\"$\"0.00\)", Currency.new({
|
|
122
|
+
:symbol => :dollar,
|
|
123
|
+
:decimal_places => 2,
|
|
124
|
+
:negative_numbers => :black_parenth,
|
|
125
|
+
:comma_separator => false
|
|
126
|
+
}).style)
|
|
127
|
+
end
|
|
154
128
|
|
|
129
|
+
should "provide unique format keys" do
|
|
130
|
+
assert_equal("currency_dollar_2_nocomma_blackparenth", Currency.new({
|
|
131
|
+
:decimal_places => 2,
|
|
132
|
+
:negative_numbers => :black_parenth,
|
|
133
|
+
:comma_separator => false
|
|
134
|
+
}).key)
|
|
135
|
+
assert_equal("currency_none_4_comma_redparenth", Currency.new({
|
|
136
|
+
:symbol => :none,
|
|
137
|
+
:decimal_places => 4,
|
|
138
|
+
:negative_numbers => :red_parenth,
|
|
139
|
+
:comma_separator => true
|
|
140
|
+
}).key)
|
|
155
141
|
end
|
|
142
|
+
|
|
156
143
|
end
|
|
157
144
|
|
|
158
145
|
end
|
data/test/format/custom_test.rb
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "assert"
|
|
2
2
|
require 'osheet/format/custom'
|
|
3
3
|
|
|
4
4
|
module Osheet::Format
|
|
5
5
|
|
|
6
|
-
class CustomTest <
|
|
7
|
-
|
|
8
|
-
should "generate a basic style string and key" do
|
|
9
|
-
f = Custom.new '@'
|
|
10
|
-
assert_equal "@", f.style
|
|
11
|
-
assert_equal "custom_@", f.key
|
|
12
|
-
end
|
|
6
|
+
class CustomTest < Assert::Context
|
|
7
|
+
desc "Custom format"
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
should "generate a basic style string and key" do
|
|
10
|
+
f = Custom.new '@'
|
|
11
|
+
assert_equal "@", f.style
|
|
12
|
+
assert_equal "custom_@", f.key
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
should "generate a more complex style string and key" do
|
|
16
|
+
f = Custom.new 'm/d/yy'
|
|
17
|
+
assert_equal 'm/d/yy', f.style
|
|
18
|
+
assert_equal "custom_m/d/yy", f.key
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "assert"
|
|
2
2
|
require 'osheet/format/datetime'
|
|
3
3
|
|
|
4
4
|
module Osheet::Format
|
|
5
5
|
|
|
6
|
-
class DatetimeTest <
|
|
7
|
-
|
|
8
|
-
should "generate a basic style string and key" do
|
|
9
|
-
f = Datetime.new 'mm/dd/yyyy'
|
|
10
|
-
assert_equal "mm/dd/yyyy", f.style
|
|
11
|
-
assert_equal "datetime_mm/dd/yyyy", f.key
|
|
12
|
-
end
|
|
6
|
+
class DatetimeTest < Assert::Context
|
|
7
|
+
desc "Datetime format"
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
should "generate a basic style string and key" do
|
|
10
|
+
f = Datetime.new 'mm/dd/yyyy'
|
|
11
|
+
assert_equal "mm/dd/yyyy", f.style
|
|
12
|
+
assert_equal "datetime_mm/dd/yyyy", f.key
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
should "generate a more complex style string and key" do
|
|
16
|
+
f = Datetime.new 'yy-m'
|
|
17
|
+
assert_equal 'yy-m', f.style
|
|
18
|
+
assert_equal "datetime_yy-m", f.key
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|