xqsr3 0.39.1 → 0.39.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/examples/count_word_frequencies.rb +2 -0
  3. data/lib/xqsr3/array_utilities/join_with_or.rb +50 -53
  4. data/lib/xqsr3/command_line_utilities/map_option_string.rb +66 -69
  5. data/lib/xqsr3/containers/frequency_map.rb +408 -394
  6. data/lib/xqsr3/containers/multi_map.rb +464 -446
  7. data/lib/xqsr3/conversion/bool_parser.rb +49 -54
  8. data/lib/xqsr3/conversion/integer_parser.rb +84 -89
  9. data/lib/xqsr3/diagnostics/exception_utilities.rb +127 -132
  10. data/lib/xqsr3/diagnostics/exceptions/with_cause.rb +98 -102
  11. data/lib/xqsr3/diagnostics/inspect_builder.rb +83 -84
  12. data/lib/xqsr3/extensions/array/join_with_or.rb +2 -1
  13. data/lib/xqsr3/extensions/enumerable/collect_with_index.rb +1 -4
  14. data/lib/xqsr3/extensions/enumerable/unique.rb +1 -4
  15. data/lib/xqsr3/extensions/hash/deep_transform.rb +1 -0
  16. data/lib/xqsr3/extensions/hash/except.rb +1 -1
  17. data/lib/xqsr3/extensions/hash/has_match.rb +3 -2
  18. data/lib/xqsr3/extensions/hash/match.rb +3 -2
  19. data/lib/xqsr3/extensions/integer/to_s_grp.rb +1 -4
  20. data/lib/xqsr3/extensions/io/writelines.rb +4 -7
  21. data/lib/xqsr3/extensions/kernel/integer.rb +7 -9
  22. data/lib/xqsr3/extensions/kernel/raise_with_options.rb +1 -3
  23. data/lib/xqsr3/extensions/string/ends_with.rb +1 -0
  24. data/lib/xqsr3/extensions/string/map_option_string.rb +1 -0
  25. data/lib/xqsr3/extensions/string/nil_if_empty.rb +1 -0
  26. data/lib/xqsr3/extensions/string/nil_if_whitespace.rb +1 -0
  27. data/lib/xqsr3/extensions/string/quote_if.rb +1 -0
  28. data/lib/xqsr3/extensions/string/starts_with.rb +1 -0
  29. data/lib/xqsr3/extensions/string/to_bool.rb +1 -0
  30. data/lib/xqsr3/extensions/string/to_symbol.rb +1 -0
  31. data/lib/xqsr3/extensions/string/truncate.rb +1 -0
  32. data/lib/xqsr3/extensions/test/unit/assert_eql.rb +11 -9
  33. data/lib/xqsr3/extensions/test/unit/assert_false.rb +10 -8
  34. data/lib/xqsr3/extensions/test/unit/assert_not.rb +10 -8
  35. data/lib/xqsr3/extensions/test/unit/assert_not_eql.rb +11 -9
  36. data/lib/xqsr3/extensions/test/unit/assert_raise_with_message.rb +58 -55
  37. data/lib/xqsr3/extensions/test/unit/assert_subclass_of.rb +11 -9
  38. data/lib/xqsr3/extensions/test/unit/assert_superclass_of.rb +11 -9
  39. data/lib/xqsr3/extensions/test/unit/assert_true.rb +10 -8
  40. data/lib/xqsr3/extensions/test/unit/assert_type_has_instance_methods.rb +39 -37
  41. data/lib/xqsr3/hash_utilities/deep_transform.rb +63 -67
  42. data/lib/xqsr3/hash_utilities/key_matching.rb +72 -76
  43. data/lib/xqsr3/internal_/test_unit_version_.rb +10 -8
  44. data/lib/xqsr3/io/writelines.rb +12 -12
  45. data/lib/xqsr3/quality/parameter_checking.rb +406 -411
  46. data/lib/xqsr3/string_utilities/ends_with.rb +60 -64
  47. data/lib/xqsr3/string_utilities/nil_if_empty.rb +31 -35
  48. data/lib/xqsr3/string_utilities/nil_if_whitespace.rb +32 -36
  49. data/lib/xqsr3/string_utilities/quote_if.rb +48 -57
  50. data/lib/xqsr3/string_utilities/starts_with.rb +60 -64
  51. data/lib/xqsr3/string_utilities/to_symbol.rb +77 -81
  52. data/lib/xqsr3/string_utilities/truncate.rb +56 -60
  53. data/lib/xqsr3/version.rb +2 -2
  54. data/test/performance/frequency_map.rb +3 -0
  55. data/test/scratch/test_assert_raise_with_message.rb +2 -0
  56. data/test/unit/array_utilities/tc_join_with_or.rb +3 -1
  57. data/test/unit/command_line_utilities/tc_map_option_string.rb +3 -0
  58. data/test/unit/containers/tc_frequency_map.rb +5 -2
  59. data/test/unit/containers/tc_multi_map.rb +3 -0
  60. data/test/unit/conversion/tc_integer_parser.rb +18 -17
  61. data/test/unit/conversion/tc_to_bool.rb +2 -0
  62. data/test/unit/diagnostics/exceptions/tc_with_cause.rb +7 -5
  63. data/test/unit/diagnostics/tc_exception_utilities.rb +2 -0
  64. data/test/unit/extensions/enumerable/tc_collect_with_index.rb +2 -0
  65. data/test/unit/extensions/enumerable/tc_detect_map.rb +3 -2
  66. data/test/unit/extensions/enumerable/tc_unique.rb +2 -0
  67. data/test/unit/extensions/hash/tc_deep_transform.rb +2 -0
  68. data/test/unit/extensions/hash/tc_except.rb +3 -1
  69. data/test/unit/extensions/hash/tc_hash.rb +1 -0
  70. data/test/unit/extensions/hash/tc_slice.rb +2 -0
  71. data/test/unit/extensions/integer/tc_to_s_grp.rb +2 -0
  72. data/test/unit/extensions/io/tc_writelines.rb +86 -0
  73. data/test/unit/extensions/kernel/tc_integer.rb +10 -9
  74. data/test/unit/extensions/kernel/tc_raise_with_options.rb +2 -0
  75. data/test/unit/extensions/object/tc_inspect.rb +15 -13
  76. data/test/unit/extensions/string/tc_bool.tb +2 -0
  77. data/test/unit/extensions/string/tc_ends_with.rb +2 -0
  78. data/test/unit/extensions/string/tc_map_option_string.rb +2 -0
  79. data/test/unit/extensions/string/tc_nil_if_empty.rb +2 -0
  80. data/test/unit/extensions/string/tc_nil_if_whitespace.rb +2 -0
  81. data/test/unit/extensions/string/tc_quote_if.rb +2 -0
  82. data/test/unit/extensions/string/tc_starts_with.rb +2 -0
  83. data/test/unit/extensions/string/tc_to_symbol.rb +2 -0
  84. data/test/unit/extensions/string/tc_truncate.rb +2 -0
  85. data/test/unit/extensions/test/unit/tc_assert_raise_with_message.rb +2 -0
  86. data/test/unit/extensions/test/unit/tc_assert_subclass_of.rb +2 -0
  87. data/test/unit/extensions/test/unit/tc_assert_superclass_of.rb +2 -0
  88. data/test/unit/hash_utilities/tc_has_match.rb +1 -0
  89. data/test/unit/hash_utilities/tc_match.rb +1 -0
  90. data/test/unit/io/tc_writelines.rb +63 -0
  91. data/test/unit/quality/tc_parameter_checking.rb +1 -0
  92. data/test/unit/string_utilities/tc_truncate.rb +2 -0
  93. data/test/unit/tc_version.rb +2 -0
  94. metadata +3 -3
@@ -2,12 +2,13 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/enumerable/detect_map'
6
7
 
7
8
  require 'xqsr3/extensions/test/unit'
8
-
9
9
  require 'test/unit'
10
10
 
11
+
11
12
  class Test_Enumerable_detect_map < Test::Unit::TestCase
12
13
 
13
14
  def test_with_array
@@ -19,7 +20,7 @@ class Test_Enumerable_detect_map < Test::Unit::TestCase
19
20
  assert_not_nil [ 1, 2, 3, 4, 5 ].detect_map { |v| :nil }
20
21
 
21
22
  assert_nil [].detect_map { |v| return -2 * v }
22
- assert_equal -2, [ 1, 2, 3, 4, 5 ].detect_map { |v| -2 * v }
23
+ assert_equal(-2, [ 1, 2, 3, 4, 5 ].detect_map { |v| -2 * v })
23
24
  assert_equal(-4, [ 1, 2, 3, 4, 5 ].detect_map { |v| -2 * v if 2 == v })
24
25
  end
25
26
 
@@ -2,10 +2,12 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/enumerable/unique'
6
7
 
7
8
  require 'test/unit'
8
9
 
10
+
9
11
  class Test_Enumerable_unique_test < Test::Unit::TestCase
10
12
 
11
13
  def test_empty
@@ -2,6 +2,7 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/hash/deep_transform'
6
7
 
7
8
  require 'xqsr3/extensions/test/unit'
@@ -9,6 +10,7 @@ require 'test/unit'
9
10
 
10
11
  require 'stringio'
11
12
 
13
+
12
14
  class Test_Hash_deep_transform < Test::Unit::TestCase
13
15
 
14
16
  def test_Hash_has_method
@@ -2,6 +2,7 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/hash/except'
6
7
 
7
8
  require 'xqsr3/extensions/test/unit'
@@ -9,6 +10,7 @@ require 'test/unit'
9
10
 
10
11
  require 'stringio'
11
12
 
13
+
12
14
  class Test_Hash_except < Test::Unit::TestCase
13
15
 
14
16
  def test_no_pairs_empty_keys
@@ -19,7 +21,7 @@ class Test_Hash_except < Test::Unit::TestCase
19
21
 
20
22
  i = {}
21
23
 
22
- i.except! *[]
24
+ i.except!(*[])
23
25
 
24
26
  assert_equal h, i
25
27
  end
@@ -2,5 +2,6 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/hash'
6
7
 
@@ -2,8 +2,10 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/hash/slice'
6
7
 
8
+
7
9
  class Test_Hash_slice < Test::Unit::TestCase
8
10
 
9
11
  def test_empty
@@ -2,10 +2,12 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/integer/to_s_grp'
6
7
 
7
8
  require 'test/unit'
8
9
 
10
+
9
11
  class Test_X_Integer_to_s_grp < Test::Unit::TestCase
10
12
 
11
13
  def test_no_args
@@ -2,12 +2,14 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/io/writelines'
6
7
 
7
8
  require 'test/unit'
8
9
 
9
10
  require 'stringio'
10
11
 
12
+
11
13
  class Test_IO_writelines < Test::Unit::TestCase
12
14
 
13
15
  def test_single_string
@@ -118,6 +120,90 @@ class Test_IO_writelines < Test::Unit::TestCase
118
120
  assert_equal "abc\ndef", s.string
119
121
  end
120
122
 
123
+ def test_two_strings_in_hash_with_col_sep
124
+
125
+ input = { 'ab' => 'c', 'de' => 'f' }
126
+
127
+ s = StringIO.new '', 'a'
128
+
129
+ r = ::IO.writelines s, input, column_separator: "\t"
130
+
131
+ assert_equal 2, r
132
+ assert_equal "ab\tc\nde\tf\n", s.string
133
+ end
134
+
135
+ def test_two_strings_in_hash_with_line_sep
136
+
137
+ input = { 'ab' => 'c', 'de' => 'f' }
138
+
139
+ s = StringIO.new '', 'a'
140
+
141
+ r = ::IO.writelines s, input, line_separator: '+'
142
+
143
+ assert_equal 2, r
144
+ assert_equal "abc+def+", s.string
145
+ end
146
+
147
+ def test_two_strings_in_hash_with_line_sep_and_col_sep
148
+
149
+ input = { 'ab' => 'c', 'de' => 'f' }
150
+
151
+ s = StringIO.new '', 'a'
152
+
153
+ r = ::IO.writelines s, input, line_separator: '+', column_separator: "\t"
154
+
155
+ assert_equal 2, r
156
+ assert_equal "ab\tc+de\tf+", s.string
157
+ end
158
+
159
+ def test_two_strings_in_hash_with_line_sep_and_col_sep_and_nolasteol
160
+
161
+ input = { 'ab' => 'c', 'de' => 'f' }
162
+
163
+ s = StringIO.new '', 'a'
164
+
165
+ r = ::IO.writelines s, input, line_separator: '+', column_separator: "\t", no_last_eol: true
166
+
167
+ assert_equal 2, r
168
+ assert_equal "ab\tc+de\tf", s.string
169
+ end
170
+
171
+ def test_two_strings_in_hash_with_arguments_of_line_sep
172
+
173
+ input = { 'ab' => 'c', 'de' => 'f' }
174
+
175
+ s = StringIO.new '', 'a'
176
+
177
+ r = ::IO.writelines s, input, '+'
178
+
179
+ assert_equal 2, r
180
+ assert_equal "abc+def+", s.string
181
+ end
182
+
183
+ def test_two_strings_in_hash_with_arguments_of_line_sep_and_col_sep
184
+
185
+ input = { 'ab' => 'c', 'de' => 'f' }
186
+
187
+ s = StringIO.new '', 'a'
188
+
189
+ r = ::IO.writelines s, input, '+', '-'
190
+
191
+ assert_equal 2, r
192
+ assert_equal "ab-c+de-f+", s.string
193
+ end
194
+
195
+ # def test_two_strings_in_hash_with_arguments_of_col_sep
196
+
197
+ # input = { 'ab' => 'c', 'de' => 'f' }
198
+
199
+ # s = StringIO.new '', 'a'
200
+
201
+ # r = ::IO.writelines s, input, "\t"
202
+
203
+ # assert_equal 2, r
204
+ # assert_equal "ab\tc\nde\tf\n", s.string
205
+ # end
206
+
121
207
  def test_ten_strings_in_array
122
208
 
123
209
  input = (0...10).map { |i| i.to_s }
@@ -2,27 +2,28 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/kernel/integer'
6
7
 
7
8
  require 'xqsr3/extensions/test/unit'
8
-
9
9
  require 'test/unit'
10
10
 
11
+
11
12
  class Test_X_Kernel_Integer < Test::Unit::TestCase
12
13
 
13
14
  class SomeRandomException < Exception; end
14
15
 
15
16
  def test_Integer_with_valid_values
16
17
 
17
- assert_equal 0, Integer(0)
18
- assert_equal +1, Integer(1)
19
- assert_equal +1, Integer(+1)
20
- assert_equal -1, Integer(-1)
18
+ assert_equal(0, Integer(0))
19
+ assert_equal(+1, Integer(1))
20
+ assert_equal(+1, Integer(+1))
21
+ assert_equal(-1, Integer(-1))
21
22
 
22
- assert_equal 0, Integer('0')
23
- assert_equal +1, Integer('1')
24
- assert_equal +1, Integer('+1')
25
- assert_equal -1, Integer('-1')
23
+ assert_equal(0, Integer('0'))
24
+ assert_equal(+1, Integer('1'))
25
+ assert_equal(+1, Integer('+1'))
26
+ assert_equal(-1, Integer('-1'))
26
27
  end
27
28
 
28
29
  def test_Integer_with_invalid_values
@@ -2,10 +2,12 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/kernel/raise_with_options'
6
7
 
7
8
  require 'test/unit'
8
9
 
10
+
9
11
  class Test_X_Kernel_raise_with_options < Test::Unit::TestCase
10
12
 
11
13
  OS_IS_WINDOWS = (RUBY_PLATFORM =~ /(mswin|mingw|bccwin|wince)/i) ? true : false
@@ -2,11 +2,13 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/diagnostics/inspect_builder'
6
7
 
7
8
  require 'xqsr3/extensions/test/unit'
8
9
  require 'test/unit'
9
10
 
11
+
10
12
  class Test_X_Object_inspect < Test::Unit::TestCase
11
13
 
12
14
  class Example1
@@ -22,7 +24,7 @@ class Test_X_Object_inspect < Test::Unit::TestCase
22
24
 
23
25
  def inspect
24
26
 
25
- make_inspect **@inspect_options
27
+ make_inspect(**@inspect_options)
26
28
  end
27
29
  end
28
30
 
@@ -35,66 +37,66 @@ class Test_X_Object_inspect < Test::Unit::TestCase
35
37
 
36
38
  ex = Example1.new
37
39
 
38
- assert_match /\A#<Test_X_Object_inspect::Example1:0x\d+>\z/, ex.inspect
40
+ assert_match(/\A#<Test_X_Object_inspect::Example1:0x\d+>\z/, ex.inspect)
39
41
 
40
42
  ex2 = ExampleWithHiddenFields.new
41
43
 
42
- assert_match /\A#<Test_X_Object_inspect::ExampleWithHiddenFields:0x\d+>\z/, ex2.inspect
44
+ assert_match(/\A#<Test_X_Object_inspect::ExampleWithHiddenFields:0x\d+>\z/, ex2.inspect)
43
45
  end
44
46
 
45
47
  def test_no_class
46
48
 
47
49
  ex = Example1.new(no_class: true)
48
50
 
49
- assert_match /\A#<0x\d+>\z/, ex.inspect
51
+ assert_match(/\A#<0x\d+>\z/, ex.inspect)
50
52
 
51
53
  ex2 = ExampleWithHiddenFields.new(no_class: true)
52
54
 
53
- assert_match /\A#<0x\d+>\z/, ex2.inspect
55
+ assert_match(/\A#<0x\d+>\z/, ex2.inspect)
54
56
  end
55
57
 
56
58
  def test_no_object_id
57
59
 
58
60
  ex = Example1.new(no_object_id: true)
59
61
 
60
- assert_match /\A#<Test_X_Object_inspect::Example1>\z/, ex.inspect
62
+ assert_match(/\A#<Test_X_Object_inspect::Example1>\z/, ex.inspect)
61
63
 
62
64
  ex2 = ExampleWithHiddenFields.new(no_object_id: true)
63
65
 
64
- assert_match /\A#<Test_X_Object_inspect::ExampleWithHiddenFields>\z/, ex2.inspect
66
+ assert_match(/\A#<Test_X_Object_inspect::ExampleWithHiddenFields>\z/, ex2.inspect)
65
67
  end
66
68
 
67
69
  def test_show_fields
68
70
 
69
71
  ex = Example1.new(show_fields: true)
70
72
 
71
- assert_match /\A#<Test_X_Object_inspect::Example1:0x\d+:\s*@alphabet\(String\)='abcdefghijklmnopqrstuvwxyz';\s*@inspect_options.*;\s*@letters.*>\z/, ex.inspect
73
+ assert_match(/\A#<Test_X_Object_inspect::Example1:0x\d+:\s*@alphabet\(String\)='abcdefghijklmnopqrstuvwxyz';\s*@inspect_options.*;\s*@letters.*>\z/, ex.inspect)
72
74
 
73
75
  ex2 = ExampleWithHiddenFields.new(show_fields: true)
74
76
 
75
- assert_match /\A#<Test_X_Object_inspect::ExampleWithHiddenFields:0x\d+:\s*@alphabet\(String\)='abcdefghijklmnopqrstuvwxyz';\s*@inspect_options\(.+\)=[^;]+>\z/, ex2.inspect
77
+ assert_match(/\A#<Test_X_Object_inspect::ExampleWithHiddenFields:0x\d+:\s*@alphabet\(String\)='abcdefghijklmnopqrstuvwxyz';\s*@inspect_options\(.+\)=[^;]+>\z/, ex2.inspect)
76
78
  end
77
79
 
78
80
  def test_show_fields_hidden
79
81
 
80
82
  ex = Example1.new(show_fields: true, hidden_fields: [ 'inspect_options' ])
81
83
 
82
- assert_match /\A#<Test_X_Object_inspect::Example1:0x\d+:\s*@alphabet\(String\)='abcdefghijklmnopqrstuvwxyz';\s*@letters.*>\z/, ex.inspect
84
+ assert_match(/\A#<Test_X_Object_inspect::Example1:0x\d+:\s*@alphabet\(String\)='abcdefghijklmnopqrstuvwxyz';\s*@letters.*>\z/, ex.inspect)
83
85
 
84
86
  ex2 = ExampleWithHiddenFields.new(show_fields: true, hidden_fields: [ 'inspect_options' ])
85
87
 
86
- assert_match /\A#<Test_X_Object_inspect::ExampleWithHiddenFields:0x\d+:\s*@alphabet\(String\)='abcdefghijklmnopqrstuvwxyz'>\z/, ex2.inspect
88
+ assert_match(/\A#<Test_X_Object_inspect::ExampleWithHiddenFields:0x\d+:\s*@alphabet\(String\)='abcdefghijklmnopqrstuvwxyz'>\z/, ex2.inspect)
87
89
  end
88
90
 
89
91
  def test_show_fields_truncated
90
92
 
91
93
  ex = Example1.new(show_fields: true, truncate_width: 10)
92
94
 
93
- assert_match /\A#<Test_X_Object_inspect::Example1:0x\d+:\s*@alphabet\(String\)='abcdefg...';\s*@inspect_options.*;\s*@letters.*>\z/, ex.inspect
95
+ assert_match(/\A#<Test_X_Object_inspect::Example1:0x\d+:\s*@alphabet\(String\)='abcdefg...';\s*@inspect_options.*;\s*@letters.*>\z/, ex.inspect)
94
96
 
95
97
  ex2 = ExampleWithHiddenFields.new(show_fields: true, truncate_width: 10)
96
98
 
97
- assert_match /\A#<Test_X_Object_inspect::ExampleWithHiddenFields:0x\d+:\s*@alphabet\(String\)='abcdefg...';\s*@inspect_options.*>\z/, ex2.inspect
99
+ assert_match(/\A#<Test_X_Object_inspect::ExampleWithHiddenFields:0x\d+:\s*@alphabet\(String\)='abcdefg...';\s*@inspect_options.*>\z/, ex2.inspect)
98
100
  end
99
101
  end
100
102
 
@@ -2,11 +2,13 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/string/to_bool'
6
7
 
7
8
  require 'xqsr3/extensions/test/unit'
8
9
  require 'test/unit'
9
10
 
11
+
10
12
  class Test_String_to_bool < Test::Unit::TestCase
11
13
 
12
14
  def test_parse_normal
@@ -2,6 +2,7 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/string/ends_with'
6
7
 
7
8
  require 'xqsr3/extensions/test/unit'
@@ -9,6 +10,7 @@ require 'test/unit'
9
10
 
10
11
  require 'stringio'
11
12
 
13
+
12
14
  class Test_String_ends_with < Test::Unit::TestCase
13
15
 
14
16
  def test_String_has_method
@@ -2,11 +2,13 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/string/map_option_string'
6
7
 
7
8
  require 'xqsr3/extensions/test/unit'
8
9
  require 'test/unit'
9
10
 
11
+
10
12
  class Test_String_map_option_string < Test::Unit::TestCase
11
13
 
12
14
  def test_simple_uses
@@ -2,6 +2,7 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/string/nil_if_empty'
6
7
 
7
8
  require 'xqsr3/extensions/test/unit'
@@ -9,6 +10,7 @@ require 'test/unit'
9
10
 
10
11
  require 'stringio'
11
12
 
13
+
12
14
  class Test_String_nil_if_empty < Test::Unit::TestCase
13
15
 
14
16
  def test_String_has_method
@@ -2,6 +2,7 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/string/nil_if_whitespace'
6
7
 
7
8
  require 'xqsr3/extensions/test/unit'
@@ -9,6 +10,7 @@ require 'test/unit'
9
10
 
10
11
  require 'stringio'
11
12
 
13
+
12
14
  class Test_String_nil_if_whitespace < Test::Unit::TestCase
13
15
 
14
16
  def test_String_has_method
@@ -2,6 +2,7 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/string/quote_if'
6
7
 
7
8
  require 'xqsr3/extensions/test/unit'
@@ -9,6 +10,7 @@ require 'test/unit'
9
10
 
10
11
  require 'stringio'
11
12
 
13
+
12
14
  class Test_String_quote_if < Test::Unit::TestCase
13
15
 
14
16
  def test_String_has_method
@@ -2,6 +2,7 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/string/starts_with'
6
7
 
7
8
  require 'xqsr3/extensions/test/unit'
@@ -9,6 +10,7 @@ require 'test/unit'
9
10
 
10
11
  require 'stringio'
11
12
 
13
+
12
14
  class Test_String_starts_with < Test::Unit::TestCase
13
15
 
14
16
  def test_String_has_method
@@ -2,11 +2,13 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/string/to_symbol'
6
7
 
7
8
  require 'xqsr3/extensions/test/unit'
8
9
  require 'test/unit'
9
10
 
11
+
10
12
  class Test_String_to_symbol < Test::Unit::TestCase
11
13
 
12
14
  def test_empty_string
@@ -2,11 +2,13 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/string/truncate'
6
7
 
7
8
  require 'xqsr3/extensions/test/unit'
8
9
  require 'test/unit'
9
10
 
11
+
10
12
  class Test_String_truncate < Test::Unit::TestCase
11
13
 
12
14
  def test_empty_string
@@ -2,10 +2,12 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), *(['..']*5), 'lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/test/unit/assert_raise_with_message'
6
7
 
7
8
  require 'test/unit'
8
9
 
10
+
9
11
  class Test_assert_raise_with_message < Test::Unit::TestCase
10
12
 
11
13
  def test_no_class_and_specific_message
@@ -2,10 +2,12 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), *(['..']*5), 'lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/test/unit/assert_subclass_of'
6
7
 
7
8
  require 'test/unit'
8
9
 
10
+
9
11
  class Test_assert_subclass_of < Test::Unit::TestCase
10
12
 
11
13
  class Grandparent; end
@@ -2,10 +2,12 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), *(['..']*5), 'lib')
4
4
 
5
+
5
6
  require 'xqsr3/extensions/test/unit/assert_superclass_of'
6
7
 
7
8
  require 'test/unit'
8
9
 
10
+
9
11
  class Test_assert_superclass_of < Test::Unit::TestCase
10
12
 
11
13
  class Grandparent; end
@@ -2,6 +2,7 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/hash_utilities/key_matching'
6
7
 
7
8
  require 'xqsr3/extensions/test/unit'
@@ -2,6 +2,7 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/hash_utilities/key_matching'
6
7
 
7
8
  require 'xqsr3/extensions/test/unit'
@@ -2,13 +2,16 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../lib')
4
4
 
5
+
5
6
  require 'xqsr3/io/writelines'
6
7
 
7
8
  require 'test/unit'
8
9
  require 'stringio'
9
10
 
11
+
10
12
  include ::Xqsr3::IO
11
13
 
14
+
12
15
  class Test_Xqsr3_IO_writelines < Test::Unit::TestCase
13
16
 
14
17
  def test_single_string
@@ -83,6 +86,18 @@ class Test_Xqsr3_IO_writelines < Test::Unit::TestCase
83
86
  assert_equal "abc\ndef\n", s.string
84
87
  end
85
88
 
89
+ def test_two_strings_in_hash_nolasteol
90
+
91
+ input = { 'ab' => 'c', 'de' => 'f' }
92
+
93
+ s = StringIO.new '', 'a'
94
+
95
+ r = ::Xqsr3::IO.writelines s, input, no_last_eol: true
96
+
97
+ assert_equal 2, r
98
+ assert_equal "abc\ndef", s.string
99
+ end
100
+
86
101
  def test_two_strings_in_hash_with_col_sep
87
102
 
88
103
  input = { 'ab' => 'c', 'de' => 'f' }
@@ -95,6 +110,54 @@ class Test_Xqsr3_IO_writelines < Test::Unit::TestCase
95
110
  assert_equal "ab\tc\nde\tf\n", s.string
96
111
  end
97
112
 
113
+ def test_two_strings_in_hash_with_line_sep
114
+
115
+ input = { 'ab' => 'c', 'de' => 'f' }
116
+
117
+ s = StringIO.new '', 'a'
118
+
119
+ r = ::Xqsr3::IO.writelines s, input, line_separator: '+'
120
+
121
+ assert_equal 2, r
122
+ assert_equal "abc+def+", s.string
123
+ end
124
+
125
+ def test_two_strings_in_hash_with_line_sep_and_col_sep
126
+
127
+ input = { 'ab' => 'c', 'de' => 'f' }
128
+
129
+ s = StringIO.new '', 'a'
130
+
131
+ r = ::Xqsr3::IO.writelines s, input, line_separator: '+', column_separator: "\t"
132
+
133
+ assert_equal 2, r
134
+ assert_equal "ab\tc+de\tf+", s.string
135
+ end
136
+
137
+ def test_two_strings_in_hash_with_line_sep_and_col_sep_and_nolasteol
138
+
139
+ input = { 'ab' => 'c', 'de' => 'f' }
140
+
141
+ s = StringIO.new '', 'a'
142
+
143
+ r = ::Xqsr3::IO.writelines s, input, line_separator: '+', column_separator: "\t", no_last_eol: true
144
+
145
+ assert_equal 2, r
146
+ assert_equal "ab\tc+de\tf", s.string
147
+ end
148
+
149
+ def test_two_entries_in_hash_with_line_sep_and_col_sep
150
+
151
+ input = { 'ab' => 'c', 'de' => 'f' }
152
+
153
+ s = StringIO.new '', 'a'
154
+
155
+ r = ::Xqsr3::IO.writelines s, input, line_separator: '+', column_separator: '-'
156
+
157
+ assert_equal 2, r
158
+ assert_equal "ab-c+de-f+", s.string
159
+ end
160
+
98
161
  def test_ten_strings_in_array
99
162
 
100
163
  input = (0...10).map { |i| i.to_s }
@@ -2,6 +2,7 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '../../../..', 'lib')
4
4
 
5
+
5
6
  require 'xqsr3/quality/parameter_checking'
6
7
 
7
8
  require 'xqsr3/extensions/test/unit'