osheet 1.0.0.rc.4 → 1.0.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 +17 -6
- data/Gemfile +3 -4
- data/LICENSE.txt +22 -0
- data/README.md +129 -0
- data/Rakefile +1 -7
- data/lib/osheet/cell.rb +0 -1
- data/lib/osheet/column.rb +3 -2
- data/lib/osheet/format.rb +9 -9
- data/lib/osheet/format/accounting.rb +0 -1
- data/lib/osheet/format/currency.rb +1 -1
- data/lib/osheet/format/custom.rb +0 -1
- data/lib/osheet/format/datetime.rb +0 -1
- data/lib/osheet/format/fraction.rb +0 -1
- data/lib/osheet/format/general.rb +2 -2
- data/lib/osheet/format/number.rb +0 -1
- data/lib/osheet/format/numeric.rb +2 -1
- data/lib/osheet/format/percentage.rb +2 -1
- data/lib/osheet/format/scientific.rb +2 -1
- data/lib/osheet/format/special.rb +0 -1
- data/lib/osheet/format/text.rb +0 -1
- data/lib/osheet/mixin.rb +1 -0
- data/lib/osheet/row.rb +0 -1
- data/lib/osheet/style.rb +1 -0
- data/lib/osheet/styled_element.rb +1 -0
- data/lib/osheet/version.rb +1 -1
- data/lib/osheet/workbook.rb +0 -4
- data/lib/osheet/workbook_element.rb +0 -10
- data/osheet.gemspec +18 -16
- data/test/helper.rb +6 -2
- data/test/{fixtures → support}/mixins.rb +0 -0
- data/test/{fixtures → support}/test_writer.rb +0 -0
- data/test/{cell_test.rb → unit/cell_tests.rb} +15 -12
- data/test/{column_test.rb → unit/column_tests.rb} +10 -9
- data/test/{format/accounting_test.rb → unit/format/accounting_tests.rb} +35 -26
- data/test/{format/currency_test.rb → unit/format/currency_tests.rb} +35 -26
- data/test/{format/custom_test.rb → unit/format/custom_tests.rb} +6 -5
- data/test/{format/datetime_test.rb → unit/format/datetime_tests.rb} +6 -5
- data/test/{format/fraction_test.rb → unit/format/fraction_tests.rb} +16 -16
- data/test/{format/general_test.rb → unit/format/general_tests.rb} +5 -5
- data/test/unit/format/number_tests.rb +96 -0
- data/test/{format/percentage_test.rb → unit/format/percentage_tests.rb} +32 -23
- data/test/{format/scientific_test.rb → unit/format/scientific_tests.rb} +31 -23
- data/test/{format/special_test.rb → unit/format/special_tests.rb} +11 -11
- data/test/{format/text_test.rb → unit/format/text_tests.rb} +4 -4
- data/test/{format_test.rb → unit/format_tests.rb} +8 -7
- data/test/{mixin_test.rb → unit/mixin_tests.rb} +11 -10
- data/test/{partial_test.rb → unit/partial_tests.rb} +13 -10
- data/test/{row_test.rb → unit/row_tests.rb} +11 -10
- data/test/{style_test.rb → unit/style_tests.rb} +13 -14
- data/test/{template_test.rb → unit/template_tests.rb} +15 -12
- data/test/{workbook_element_test.rb → unit/workbook_element_tests.rb} +48 -54
- data/test/{workbook_test.rb → unit/workbook_tests.rb} +34 -30
- data/test/{worksheet_test.rb → unit/worksheet_tests.rb} +13 -13
- metadata +70 -76
- data/Gemfile.lock +0 -27
- data/README.rdoc +0 -133
- data/test/format/number_test.rb +0 -91
- data/test/irb.rb +0 -9
@@ -1,22 +1,23 @@
|
|
1
1
|
require "assert"
|
2
2
|
require 'osheet/format/custom'
|
3
3
|
|
4
|
-
|
4
|
+
class Osheet::Format::Custom
|
5
5
|
|
6
|
-
class
|
7
|
-
desc "Custom format"
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Osheet::Format::Custom format"
|
8
8
|
|
9
9
|
should "generate a basic style string and key" do
|
10
|
-
f = Custom.new '@'
|
10
|
+
f = Osheet::Format::Custom.new '@'
|
11
11
|
assert_equal "@", f.style
|
12
12
|
assert_equal "custom_@", f.key
|
13
13
|
end
|
14
14
|
|
15
15
|
should "generate a more complex style string and key" do
|
16
|
-
f = Custom.new 'm/d/yy'
|
16
|
+
f = Osheet::Format::Custom.new 'm/d/yy'
|
17
17
|
assert_equal 'm/d/yy', f.style
|
18
18
|
assert_equal "custom_m/d/yy", f.key
|
19
19
|
end
|
20
|
+
|
20
21
|
end
|
21
22
|
|
22
23
|
end
|
@@ -1,22 +1,23 @@
|
|
1
1
|
require "assert"
|
2
2
|
require 'osheet/format/datetime'
|
3
3
|
|
4
|
-
|
4
|
+
class Osheet::Format::Datetime
|
5
5
|
|
6
|
-
class
|
7
|
-
desc "Datetime format"
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Osheet::Format::Datetime format"
|
8
8
|
|
9
9
|
should "generate a basic style string and key" do
|
10
|
-
f = Datetime.new 'mm/dd/yyyy'
|
10
|
+
f = Osheet::Format::Datetime.new 'mm/dd/yyyy'
|
11
11
|
assert_equal "mm/dd/yyyy", f.style
|
12
12
|
assert_equal "datetime_mm/dd/yyyy", f.key
|
13
13
|
end
|
14
14
|
|
15
15
|
should "generate a more complex style string and key" do
|
16
|
-
f = Datetime.new 'yy-m'
|
16
|
+
f = Osheet::Format::Datetime.new 'yy-m'
|
17
17
|
assert_equal 'yy-m', f.style
|
18
18
|
assert_equal "datetime_yy-m", f.key
|
19
19
|
end
|
20
|
+
|
20
21
|
end
|
21
22
|
|
22
23
|
end
|
@@ -1,22 +1,22 @@
|
|
1
1
|
require "assert"
|
2
2
|
require 'osheet/format/fraction'
|
3
3
|
|
4
|
-
|
4
|
+
class Osheet::Format::Fraction
|
5
5
|
|
6
|
-
class
|
7
|
-
desc "Fraction format"
|
8
|
-
before
|
9
|
-
subject
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Osheet::Format::Fraction format"
|
8
|
+
before{ @f = Osheet::Format::Fraction.new }
|
9
|
+
subject{ @f }
|
10
10
|
|
11
11
|
should have_accessors :type
|
12
12
|
|
13
13
|
should "provide options for type" do
|
14
|
-
assert_equal 9, Fraction.type_set.size
|
14
|
+
assert_equal 9, Osheet::Format::Fraction.type_set.size
|
15
15
|
[ :one_digit, :two_digits, :three_digits,
|
16
16
|
:halves, :quarters, :eighths, :sixteenths,
|
17
17
|
:tenths, :hundredths
|
18
18
|
].each do |a|
|
19
|
-
assert Fraction.type_set.include?(a)
|
19
|
+
assert Osheet::Format::Fraction.type_set.include?(a)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -26,55 +26,55 @@ module Osheet::Format
|
|
26
26
|
end
|
27
27
|
|
28
28
|
should "generate a one_digit type style strings and key" do
|
29
|
-
f = Fraction.new(:type => :one_digit)
|
29
|
+
f = Osheet::Format::Fraction.new(:type => :one_digit)
|
30
30
|
assert_equal "#\ ?/?", f.style
|
31
31
|
assert_equal "fraction_onedigit", f.key
|
32
32
|
end
|
33
33
|
|
34
34
|
should "generate a two_digit type style strings and key" do
|
35
|
-
f = Fraction.new(:type => :two_digits)
|
35
|
+
f = Osheet::Format::Fraction.new(:type => :two_digits)
|
36
36
|
assert_equal "#\ ??/??", f.style
|
37
37
|
assert_equal "fraction_twodigits", f.key
|
38
38
|
end
|
39
39
|
|
40
40
|
should "generate a three_digit type style strings and key" do
|
41
|
-
f = Fraction.new(:type => :three_digits)
|
41
|
+
f = Osheet::Format::Fraction.new(:type => :three_digits)
|
42
42
|
assert_equal "#\ ???/???", f.style
|
43
43
|
assert_equal "fraction_threedigits", f.key
|
44
44
|
end
|
45
45
|
|
46
46
|
should "generate a halves type style strings and key" do
|
47
|
-
f = Fraction.new(:type => :halves)
|
47
|
+
f = Osheet::Format::Fraction.new(:type => :halves)
|
48
48
|
assert_equal "#\ ?/2", f.style
|
49
49
|
assert_equal "fraction_halves", f.key
|
50
50
|
end
|
51
51
|
|
52
52
|
should "generate a quarters type style strings and key" do
|
53
|
-
f = Fraction.new(:type => :quarters)
|
53
|
+
f = Osheet::Format::Fraction.new(:type => :quarters)
|
54
54
|
assert_equal "#\ ?/4", f.style
|
55
55
|
assert_equal "fraction_quarters", f.key
|
56
56
|
end
|
57
57
|
|
58
58
|
should "generate a eighths type style strings and key" do
|
59
|
-
f = Fraction.new(:type => :eighths)
|
59
|
+
f = Osheet::Format::Fraction.new(:type => :eighths)
|
60
60
|
assert_equal "#\ ?/8", f.style
|
61
61
|
assert_equal "fraction_eighths", f.key
|
62
62
|
end
|
63
63
|
|
64
64
|
should "generate a sixteenths type style strings and key" do
|
65
|
-
f = Fraction.new(:type => :sixteenths)
|
65
|
+
f = Osheet::Format::Fraction.new(:type => :sixteenths)
|
66
66
|
assert_equal "#\ ??/16", f.style
|
67
67
|
assert_equal "fraction_sixteenths", f.key
|
68
68
|
end
|
69
69
|
|
70
70
|
should "generate a tenths type style strings and key" do
|
71
|
-
f = Fraction.new(:type => :tenths)
|
71
|
+
f = Osheet::Format::Fraction.new(:type => :tenths)
|
72
72
|
assert_equal "#\ ?/10", f.style
|
73
73
|
assert_equal "fraction_tenths", f.key
|
74
74
|
end
|
75
75
|
|
76
76
|
should "generate a hundredths type style strings and key" do
|
77
|
-
f = Fraction.new(:type => :hundredths)
|
77
|
+
f = Osheet::Format::Fraction.new(:type => :hundredths)
|
78
78
|
assert_equal "#\ ??/100", f.style
|
79
79
|
assert_equal "fraction_hundredths", f.key
|
80
80
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require "assert"
|
2
2
|
require 'osheet/format/general'
|
3
3
|
|
4
|
-
|
4
|
+
class Osheet::Format::General
|
5
5
|
|
6
|
-
class
|
7
|
-
desc "General format"
|
8
|
-
before
|
9
|
-
subject
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Osheet::Format::General format"
|
8
|
+
before{ @f = Osheet::Format::General.new }
|
9
|
+
subject{ @f }
|
10
10
|
|
11
11
|
should "always provide a nil style string" do
|
12
12
|
assert_equal nil, subject.style
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require "assert"
|
2
|
+
require 'osheet/format/number'
|
3
|
+
|
4
|
+
class Osheet::Format::Number
|
5
|
+
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Osheet::Format::Number format"
|
8
|
+
before{ @n = Osheet::Format::Number.new }
|
9
|
+
subject{ @n }
|
10
|
+
|
11
|
+
should have_accessors :decimal_places, :comma_separator, :negative_numbers
|
12
|
+
|
13
|
+
should "provide options for negative numbers" do
|
14
|
+
assert_equal 4, Osheet::Format::Number.negative_numbers_set.size
|
15
|
+
[:black, :black_parenth, :red, :red_parenth].each do |a|
|
16
|
+
assert Osheet::Format::Number.negative_numbers_set.include?(a)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
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
|
25
|
+
|
26
|
+
should "only allow Fixnum decimal places between 0 and 30" do
|
27
|
+
assert_raises ArgumentError do
|
28
|
+
Osheet::Format::Number.new({:decimal_places => -1})
|
29
|
+
end
|
30
|
+
|
31
|
+
assert_raises ArgumentError do
|
32
|
+
Osheet::Format::Number.new({:decimal_places => 31})
|
33
|
+
end
|
34
|
+
|
35
|
+
assert_raises ArgumentError do
|
36
|
+
Osheet::Format::Number.new({:decimal_places => 'poo'})
|
37
|
+
end
|
38
|
+
|
39
|
+
assert_nothing_raised do
|
40
|
+
Osheet::Format::Number.new({:decimal_places => 1})
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
should "generate decimal place style strings" do
|
45
|
+
assert_equal "0", Osheet::Format::Number.new({:decimal_places => 0}).style
|
46
|
+
(1..5).each do |n|
|
47
|
+
assert_equal "0.#{'0'*n}", Osheet::Format::Number.new({:decimal_places => n}).style
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
should "generate comma separator style strings" do
|
52
|
+
assert_equal "0", Osheet::Format::Number.new({:comma_separator => false}).style
|
53
|
+
assert_equal "#,##0", Osheet::Format::Number.new({:comma_separator => true}).style
|
54
|
+
end
|
55
|
+
|
56
|
+
should "generate parenth negative numbers style strings" do
|
57
|
+
assert_equal "0", Osheet::Format::Number.new({:negative_numbers => :black}).style
|
58
|
+
assert_equal "0_);\(0\)", Osheet::Format::Number.new({:negative_numbers => :black_parenth}).style
|
59
|
+
end
|
60
|
+
|
61
|
+
should "generate red negative numbers style strings" do
|
62
|
+
assert_equal "0;[Red]0", Osheet::Format::Number.new({:negative_numbers => :red}).style
|
63
|
+
assert_equal "0_);[Red]\(0\)", Osheet::Format::Number.new({:negative_numbers => :red_parenth}).style
|
64
|
+
end
|
65
|
+
|
66
|
+
should "generate complex style string" do
|
67
|
+
assert_equal("0.00_);\(0.00\)", Osheet::Format::Number.new({
|
68
|
+
:decimal_places => 2,
|
69
|
+
:negative_numbers => :black_parenth,
|
70
|
+
:comma_separator => false
|
71
|
+
}).style)
|
72
|
+
|
73
|
+
assert_equal("#,##0.0000_);[Red]\(#,##0.0000\)", Osheet::Format::Number.new({
|
74
|
+
:decimal_places => 4,
|
75
|
+
:negative_numbers => :red_parenth,
|
76
|
+
:comma_separator => true
|
77
|
+
}).style)
|
78
|
+
end
|
79
|
+
|
80
|
+
should "provide unique format keys" do
|
81
|
+
assert_equal("number_none_2_nocomma_blackparenth", Osheet::Format::Number.new({
|
82
|
+
:decimal_places => 2,
|
83
|
+
:negative_numbers => :black_parenth,
|
84
|
+
:comma_separator => false
|
85
|
+
}).key)
|
86
|
+
|
87
|
+
assert_equal("number_none_4_comma_redparenth", Osheet::Format::Number.new({
|
88
|
+
:decimal_places => 4,
|
89
|
+
:negative_numbers => :red_parenth,
|
90
|
+
:comma_separator => true
|
91
|
+
}).key)
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
require "assert"
|
2
2
|
require 'osheet/format/percentage'
|
3
3
|
|
4
|
-
|
4
|
+
class Osheet::Format::Percentage
|
5
5
|
|
6
|
-
class
|
7
|
-
desc "Percentage format"
|
8
|
-
before
|
9
|
-
subject
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Osheet::Format::Percentage format"
|
8
|
+
before{ @p = Osheet::Format::Percentage.new }
|
9
|
+
subject{ @p }
|
10
10
|
|
11
11
|
should have_accessors :decimal_places, :symbol, :comma_separator, :negative_numbers
|
12
12
|
|
13
13
|
should "provide negative numbers options" do
|
14
|
-
assert_equal 4, Percentage.negative_numbers_set.size
|
14
|
+
assert_equal 4, Osheet::Format::Percentage.negative_numbers_set.size
|
15
15
|
[:black, :black_parenth, :red, :red_parenth].each do |a|
|
16
|
-
assert Percentage.negative_numbers_set.include?(a)
|
16
|
+
assert Osheet::Format::Percentage.negative_numbers_set.include?(a)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -25,70 +25,78 @@ module Osheet::Format
|
|
25
25
|
|
26
26
|
should "only allow Fixnum decimal places between 0 and 30" do
|
27
27
|
assert_raises ArgumentError do
|
28
|
-
Percentage.new({:decimal_places => -1})
|
28
|
+
Osheet::Format::Percentage.new({:decimal_places => -1})
|
29
29
|
end
|
30
|
+
|
30
31
|
assert_raises ArgumentError do
|
31
|
-
Percentage.new({:decimal_places => 31})
|
32
|
+
Osheet::Format::Percentage.new({:decimal_places => 31})
|
32
33
|
end
|
34
|
+
|
33
35
|
assert_raises ArgumentError do
|
34
|
-
Percentage.new({:decimal_places => 'poo'})
|
36
|
+
Osheet::Format::Percentage.new({:decimal_places => 'poo'})
|
35
37
|
end
|
38
|
+
|
36
39
|
assert_nothing_raised do
|
37
|
-
Percentage.new({:decimal_places => 1})
|
40
|
+
Osheet::Format::Percentage.new({:decimal_places => 1})
|
38
41
|
end
|
39
42
|
end
|
40
43
|
|
41
44
|
should "generate decimal place style strings" do
|
42
|
-
assert_equal "0%", Percentage.new({
|
45
|
+
assert_equal "0%", Osheet::Format::Percentage.new({
|
43
46
|
:decimal_places => 0
|
44
47
|
}).style
|
48
|
+
|
45
49
|
(1..5).each do |n|
|
46
|
-
assert_equal "0.#{'0'*n}%", Percentage.new({
|
50
|
+
assert_equal "0.#{'0'*n}%", Osheet::Format::Percentage.new({
|
47
51
|
:decimal_places => n
|
48
52
|
}).style
|
49
53
|
end
|
50
54
|
end
|
51
55
|
|
52
56
|
should "generate comma separator style strings" do
|
53
|
-
assert_equal "0%", Percentage.new({
|
57
|
+
assert_equal "0%", Osheet::Format::Percentage.new({
|
54
58
|
:comma_separator => false,
|
55
59
|
:decimal_places => 0
|
56
60
|
}).style
|
57
|
-
|
61
|
+
|
62
|
+
assert_equal "#,##0%", Osheet::Format::Percentage.new({
|
58
63
|
:comma_separator => true,
|
59
64
|
:decimal_places => 0
|
60
65
|
}).style
|
61
66
|
end
|
62
67
|
|
63
68
|
should "generate parenth negative numbers style strings" do
|
64
|
-
assert_equal "0%", Percentage.new({
|
69
|
+
assert_equal "0%", Osheet::Format::Percentage.new({
|
65
70
|
:negative_numbers => :black,
|
66
71
|
:decimal_places => 0
|
67
72
|
}).style
|
68
|
-
|
73
|
+
|
74
|
+
assert_equal "0%_);\(0%\)", Osheet::Format::Percentage.new({
|
69
75
|
:negative_numbers => :black_parenth,
|
70
76
|
:decimal_places => 0
|
71
77
|
}).style
|
72
78
|
end
|
73
79
|
|
74
80
|
should "generate red negative numbers style strings" do
|
75
|
-
assert_equal "0%;[Red]0%", Percentage.new({
|
81
|
+
assert_equal "0%;[Red]0%", Osheet::Format::Percentage.new({
|
76
82
|
:negative_numbers => :red,
|
77
83
|
:decimal_places => 0
|
78
84
|
}).style
|
79
|
-
|
85
|
+
|
86
|
+
assert_equal "0%_);[Red]\(0%\)", Osheet::Format::Percentage.new({
|
80
87
|
:negative_numbers => :red_parenth,
|
81
88
|
:decimal_places => 0
|
82
89
|
}).style
|
83
90
|
end
|
84
91
|
|
85
92
|
should "generate complex style string" do
|
86
|
-
assert_equal("0.00%_);\(0.00%\)", Percentage.new({
|
93
|
+
assert_equal("0.00%_);\(0.00%\)", Osheet::Format::Percentage.new({
|
87
94
|
:decimal_places => 2,
|
88
95
|
:negative_numbers => :black_parenth,
|
89
96
|
:comma_separator => false
|
90
97
|
}).style)
|
91
|
-
|
98
|
+
|
99
|
+
assert_equal("#,##0.0000%_);[Red]\(#,##0.0000%\)", Osheet::Format::Percentage.new({
|
92
100
|
:decimal_places => 4,
|
93
101
|
:negative_numbers => :red_parenth,
|
94
102
|
:comma_separator => true
|
@@ -96,12 +104,13 @@ module Osheet::Format
|
|
96
104
|
end
|
97
105
|
|
98
106
|
should "provide unique format keys" do
|
99
|
-
assert_equal("percentage_none_2_nocomma_blackparenth", Percentage.new({
|
107
|
+
assert_equal("percentage_none_2_nocomma_blackparenth", Osheet::Format::Percentage.new({
|
100
108
|
:decimal_places => 2,
|
101
109
|
:negative_numbers => :black_parenth,
|
102
110
|
:comma_separator => false
|
103
111
|
}).key)
|
104
|
-
|
112
|
+
|
113
|
+
assert_equal("percentage_none_4_comma_redparenth", Osheet::Format::Percentage.new({
|
105
114
|
:symbol => :none,
|
106
115
|
:decimal_places => 4,
|
107
116
|
:negative_numbers => :red_parenth,
|
@@ -1,19 +1,19 @@
|
|
1
1
|
require "assert"
|
2
2
|
require 'osheet/format/scientific'
|
3
3
|
|
4
|
-
|
4
|
+
class Osheet::Format::Scientific
|
5
5
|
|
6
|
-
class
|
7
|
-
desc "Scientific format"
|
8
|
-
before
|
9
|
-
subject
|
6
|
+
class UnitTests < Assert::Context
|
7
|
+
desc "Osheet::Format::Scientific format"
|
8
|
+
before{ @sc = Osheet::Format::Scientific.new }
|
9
|
+
subject{ @sc }
|
10
10
|
|
11
11
|
should have_accessors :decimal_places, :symbol, :comma_separator, :negative_numbers
|
12
12
|
|
13
13
|
should "provide negative numbers options" do
|
14
|
-
assert_equal 4, Scientific.negative_numbers_set.size
|
14
|
+
assert_equal 4, Osheet::Format::Scientific.negative_numbers_set.size
|
15
15
|
[:black, :black_parenth, :red, :red_parenth].each do |a|
|
16
|
-
assert Scientific.negative_numbers_set.include?(a)
|
16
|
+
assert Osheet::Format::Scientific.negative_numbers_set.include?(a)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -25,70 +25,77 @@ module Osheet::Format
|
|
25
25
|
|
26
26
|
should "only allow Fixnum decimal places between 0 and 30" do
|
27
27
|
assert_raises ArgumentError do
|
28
|
-
Scientific.new({:decimal_places => -1})
|
28
|
+
Osheet::Format::Scientific.new({:decimal_places => -1})
|
29
29
|
end
|
30
|
+
|
30
31
|
assert_raises ArgumentError do
|
31
|
-
Scientific.new({:decimal_places => 31})
|
32
|
+
Osheet::Format::Scientific.new({:decimal_places => 31})
|
32
33
|
end
|
34
|
+
|
33
35
|
assert_raises ArgumentError do
|
34
|
-
Scientific.new({:decimal_places => 'poo'})
|
36
|
+
Osheet::Format::Scientific.new({:decimal_places => 'poo'})
|
35
37
|
end
|
38
|
+
|
36
39
|
assert_nothing_raised do
|
37
|
-
Scientific.new({:decimal_places => 1})
|
40
|
+
Osheet::Format::Scientific.new({:decimal_places => 1})
|
38
41
|
end
|
39
42
|
end
|
40
43
|
|
41
44
|
should "generate decimal place style strings" do
|
42
|
-
assert_equal "0E+00", Scientific.new({
|
45
|
+
assert_equal "0E+00", Osheet::Format::Scientific.new({
|
43
46
|
:decimal_places => 0
|
44
47
|
}).style
|
45
48
|
(1..5).each do |n|
|
46
|
-
assert_equal "0.#{'0'*n}E+00", Scientific.new({
|
49
|
+
assert_equal "0.#{'0'*n}E+00", Osheet::Format::Scientific.new({
|
47
50
|
:decimal_places => n
|
48
51
|
}).style
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
52
55
|
should "generate comma separator style strings" do
|
53
|
-
assert_equal "0E+00", Scientific.new({
|
56
|
+
assert_equal "0E+00", Osheet::Format::Scientific.new({
|
54
57
|
:comma_separator => false,
|
55
58
|
:decimal_places => 0
|
56
59
|
}).style
|
57
|
-
|
60
|
+
|
61
|
+
assert_equal "#,##0E+00", Osheet::Format::Scientific.new({
|
58
62
|
:comma_separator => true,
|
59
63
|
:decimal_places => 0
|
60
64
|
}).style
|
61
65
|
end
|
62
66
|
|
63
67
|
should "generate parenth negative numbers style strings" do
|
64
|
-
assert_equal "0E+00", Scientific.new({
|
68
|
+
assert_equal "0E+00", Osheet::Format::Scientific.new({
|
65
69
|
:negative_numbers => :black,
|
66
70
|
:decimal_places => 0
|
67
71
|
}).style
|
68
|
-
|
72
|
+
|
73
|
+
assert_equal "0E+00_);\(0E+00\)", Osheet::Format::Scientific.new({
|
69
74
|
:negative_numbers => :black_parenth,
|
70
75
|
:decimal_places => 0
|
71
76
|
}).style
|
72
77
|
end
|
73
78
|
|
74
79
|
should "generate red negative numbers style strings" do
|
75
|
-
assert_equal "0E+00;[Red]0E+00", Scientific.new({
|
80
|
+
assert_equal "0E+00;[Red]0E+00", Osheet::Format::Scientific.new({
|
76
81
|
:negative_numbers => :red,
|
77
82
|
:decimal_places => 0
|
78
83
|
}).style
|
79
|
-
|
84
|
+
|
85
|
+
assert_equal "0E+00_);[Red]\(0E+00\)", Osheet::Format::Scientific.new({
|
80
86
|
:negative_numbers => :red_parenth,
|
81
87
|
:decimal_places => 0
|
82
88
|
}).style
|
83
89
|
end
|
84
90
|
|
85
91
|
should "generate complex style string" do
|
86
|
-
assert_equal("0.00E+00_);\(0.00E+00\)", Scientific.new({
|
92
|
+
assert_equal("0.00E+00_);\(0.00E+00\)", Osheet::Format::Scientific.new({
|
87
93
|
:decimal_places => 2,
|
88
94
|
:negative_numbers => :black_parenth,
|
89
95
|
:comma_separator => false
|
90
96
|
}).style)
|
91
|
-
|
97
|
+
|
98
|
+
assert_equal("#,##0.0000E+00_);[Red]\(#,##0.0000E+00\)", Osheet::Format::Scientific.new({
|
92
99
|
:decimal_places => 4,
|
93
100
|
:negative_numbers => :red_parenth,
|
94
101
|
:comma_separator => true
|
@@ -96,12 +103,13 @@ module Osheet::Format
|
|
96
103
|
end
|
97
104
|
|
98
105
|
should "provide unique format keys" do
|
99
|
-
assert_equal("scientific_none_2_nocomma_blackparenth", Scientific.new({
|
106
|
+
assert_equal("scientific_none_2_nocomma_blackparenth", Osheet::Format::Scientific.new({
|
100
107
|
:decimal_places => 2,
|
101
108
|
:negative_numbers => :black_parenth,
|
102
109
|
:comma_separator => false
|
103
110
|
}).key)
|
104
|
-
|
111
|
+
|
112
|
+
assert_equal("scientific_none_4_comma_redparenth", Osheet::Format::Scientific.new({
|
105
113
|
:symbol => :none,
|
106
114
|
:decimal_places => 4,
|
107
115
|
:negative_numbers => :red_parenth,
|