barby 0.6.8 → 0.7.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.
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'test_helper'
3
2
  require 'barby/barcode/code_128'
4
3
 
@@ -14,23 +13,25 @@ class Code128Test < Barby::TestCase
14
13
  end
15
14
 
16
15
  it "should have the expected stop encoding (including termination bar 11)" do
17
- @code.send(:stop_encoding).must_equal '1100011101011'
16
+ assert_equal '1100011101011', @code.send(:stop_encoding)
18
17
  end
19
18
 
20
19
  it "should find the right class for a character A, B or C" do
21
- @code.send(:class_for, 'A').must_equal Code128A
22
- @code.send(:class_for, 'B').must_equal Code128B
23
- @code.send(:class_for, 'C').must_equal Code128C
20
+ assert_equal Code128A, @code.send(:class_for, 'A')
21
+ assert_equal Code128B, @code.send(:class_for, 'B')
22
+ assert_equal Code128C, @code.send(:class_for, 'C')
24
23
  end
25
24
 
26
25
  it "should find the right change code for a class" do
27
- @code.send(:change_code_for_class, Code128A).must_equal Code128::CODEA
28
- @code.send(:change_code_for_class, Code128B).must_equal Code128::CODEB
29
- @code.send(:change_code_for_class, Code128C).must_equal Code128::CODEC
26
+ assert_equal Code128::CODEA, @code.send(:change_code_for_class, Code128A)
27
+ assert_equal Code128::CODEB, @code.send(:change_code_for_class, Code128B)
28
+ assert_equal Code128::CODEC, @code.send(:change_code_for_class, Code128C)
30
29
  end
31
30
 
32
31
  it "should not allow empty data" do
33
- lambda{ Code128B.new("") }.must_raise(ArgumentError)
32
+ assert_raises ArgumentError do
33
+ Code128B.new("")
34
+ end
34
35
  end
35
36
 
36
37
  describe "single encoding" do
@@ -41,13 +42,13 @@ class Code128Test < Barby::TestCase
41
42
  end
42
43
 
43
44
  it "should have the same data as when initialized" do
44
- @code.data.must_equal @data
45
+ assert_equal @data, @code.data
45
46
  end
46
47
 
47
48
  it "should be able to change its data" do
48
49
  @code.data = '123ABC'
49
- @code.data.must_equal '123ABC'
50
- @code.data.wont_equal @data
50
+ assert_equal '123ABC', @code.data
51
+ refute_equal @data, @code.data
51
52
  end
52
53
 
53
54
  it "should not have an extra" do
@@ -55,15 +56,15 @@ class Code128Test < Barby::TestCase
55
56
  end
56
57
 
57
58
  it "should have empty extra encoding" do
58
- @code.extra_encoding.must_equal ''
59
+ assert_equal '', @code.extra_encoding
59
60
  end
60
61
 
61
62
  it "should have the correct checksum" do
62
- @code.checksum.must_equal 66
63
+ assert_equal 66, @code.checksum
63
64
  end
64
65
 
65
66
  it "should return all data for to_s" do
66
- @code.to_s.must_equal @data
67
+ assert_equal @data, @code.to_s
67
68
  end
68
69
 
69
70
  end
@@ -76,32 +77,32 @@ class Code128Test < Barby::TestCase
76
77
  end
77
78
 
78
79
  it "should be able to return full_data which includes the entire extra chain excluding charset change characters" do
79
- @code.full_data.must_equal "ABC123def4567"
80
+ assert_equal "ABC123def4567", @code.full_data
80
81
  end
81
82
 
82
83
  it "should be able to return full_data_with_change_codes which includes the entire extra chain including charset change characters" do
83
- @code.full_data_with_change_codes.must_equal @data
84
+ assert_equal @data, @code.full_data_with_change_codes
84
85
  end
85
86
 
86
87
  it "should not matter if extras were added separately" do
87
88
  code = Code128B.new("ABC")
88
89
  code.extra = binary_encode("\3071234")
89
- code.full_data.must_equal "ABC1234"
90
- code.full_data_with_change_codes.must_equal binary_encode("ABC\3071234")
90
+ assert_equal "ABC1234", code.full_data
91
+ assert_equal binary_encode("ABC\3071234"), code.full_data_with_change_codes
91
92
  code.extra.extra = binary_encode("\306abc")
92
- code.full_data.must_equal "ABC1234abc"
93
- code.full_data_with_change_codes.must_equal binary_encode("ABC\3071234\306abc")
93
+ assert_equal "ABC1234abc", code.full_data
94
+ assert_equal binary_encode("ABC\3071234\306abc"), code.full_data_with_change_codes
94
95
  code.extra.extra.data = binary_encode("abc\305DEF")
95
- code.full_data.must_equal "ABC1234abcDEF"
96
- code.full_data_with_change_codes.must_equal binary_encode("ABC\3071234\306abc\305DEF")
97
- code.extra.extra.full_data.must_equal "abcDEF"
98
- code.extra.extra.full_data_with_change_codes.must_equal binary_encode("abc\305DEF")
99
- code.extra.full_data.must_equal "1234abcDEF"
100
- code.extra.full_data_with_change_codes.must_equal binary_encode("1234\306abc\305DEF")
96
+ assert_equal "ABC1234abcDEF", code.full_data
97
+ assert_equal binary_encode("ABC\3071234\306abc\305DEF"), code.full_data_with_change_codes
98
+ assert_equal "abcDEF", code.extra.extra.full_data
99
+ assert_equal binary_encode("abc\305DEF"), code.extra.extra.full_data_with_change_codes
100
+ assert_equal "1234abcDEF", code.extra.full_data
101
+ assert_equal binary_encode("1234\306abc\305DEF"), code.extra.full_data_with_change_codes
101
102
  end
102
103
 
103
104
  it "should have a Code B extra" do
104
- @code.extra.must_be_instance_of(Code128B)
105
+ assert @code.extra.is_a?(Code128B)
105
106
  end
106
107
 
107
108
  it "should have a valid extra" do
@@ -109,7 +110,7 @@ class Code128Test < Barby::TestCase
109
110
  end
110
111
 
111
112
  it "the extra should also have an extra of type C" do
112
- @code.extra.extra.must_be_instance_of(Code128C)
113
+ assert @code.extra.extra.is_a?(Code128C)
113
114
  end
114
115
 
115
116
  it "the extra's extra should be valid" do
@@ -122,55 +123,58 @@ class Code128Test < Barby::TestCase
122
123
 
123
124
  it "should split extra data from string on data assignment" do
124
125
  @code.data = binary_encode("123\306abc")
125
- @code.data.must_equal '123'
126
- @code.extra.must_be_instance_of(Code128B)
127
- @code.extra.data.must_equal 'abc'
126
+ assert_equal '123', @code.data
127
+ assert @code.extra.is_a?(Code128B)
128
+ assert_equal 'abc', @code.extra.data
128
129
  end
129
130
 
130
131
  it "should be be able to change its extra" do
131
132
  @code.extra = binary_encode("\3071234")
132
- @code.extra.must_be_instance_of(Code128C)
133
- @code.extra.data.must_equal '1234'
133
+ assert @code.extra.is_a?(Code128C)
134
+ assert_equal '1234', @code.extra.data
134
135
  end
135
136
 
136
137
  it "should split extra data from string on extra assignment" do
137
138
  @code.extra = binary_encode("\306123\3074567")
138
- @code.extra.must_be_instance_of(Code128B)
139
- @code.extra.data.must_equal '123'
140
- @code.extra.extra.must_be_instance_of(Code128C)
141
- @code.extra.extra.data.must_equal '4567'
139
+ assert @code.extra.is_a?(Code128B)
140
+ assert_equal '123', @code.extra.data
141
+ assert @code.extra.extra.is_a?(Code128C)
142
+ assert_equal '4567', @code.extra.extra.data
142
143
  end
143
144
 
144
145
  it "should not fail on newlines in extras" do
145
146
  code = Code128B.new(binary_encode("ABC\305\n"))
146
- code.data.must_equal "ABC"
147
- code.extra.must_be_instance_of(Code128A)
148
- code.extra.data.must_equal "\n"
147
+ assert_equal "ABC", code.data
148
+ assert code.extra.is_a?(Code128A)
149
+ assert_equal "\n", code.extra.data
149
150
  code.extra.extra = binary_encode("\305\n\n\n\n\n\nVALID")
150
- code.extra.extra.data.must_equal "\n\n\n\n\n\nVALID"
151
+ assert_equal "\n\n\n\n\n\nVALID", code.extra.extra.data
151
152
  end
152
153
 
153
154
  it "should raise an exception when extra string doesn't start with the special code character" do
154
- lambda{ @code.extra = '123' }.must_raise ArgumentError
155
+ assert_raises ArgumentError do
156
+ @code.extra = '123'
157
+ end
155
158
  end
156
159
 
157
160
  it "should have the correct checksum" do
158
- @code.checksum.must_equal 84
161
+ assert_equal 84, @code.checksum
159
162
  end
160
163
 
161
164
  it "should have the expected encoding" do
162
- #STARTA A B C 1 2 3
163
- @code.encoding.must_equal '11010000100101000110001000101100010001000110100111001101100111001011001011100'+
164
- #CODEB d e f
165
- '10111101110100001001101011001000010110000100'+
166
- #CODEC 45 67
167
- '101110111101011101100010000101100'+
168
- #CHECK=84 STOP
169
- '100111101001100011101011'
165
+ #STARTA A B C 1 2 3
166
+ expected = '11010000100101000110001000101100010001000110100111001101100111001011001011100'+
167
+ #CODEB d e f
168
+ '10111101110100001001101011001000010110000100'+
169
+ #CODEC 45 67
170
+ '101110111101011101100010000101100'+
171
+ #CHECK=84 STOP
172
+ '100111101001100011101011'
173
+ assert_equal expected, @code.encoding
170
174
  end
171
175
 
172
176
  it "should return all data including extras, except change codes for to_s" do
173
- @code.to_s.must_equal "ABC123def4567"
177
+ assert_equal "ABC123def4567", @code.to_s
174
178
  end
175
179
 
176
180
  end
@@ -192,23 +196,23 @@ class Code128Test < Barby::TestCase
192
196
  end
193
197
 
194
198
  it "should have the expected characters" do
195
- @code.characters.must_equal %w(A B C 1 2 3)
199
+ assert_equal %w(A B C 1 2 3), @code.characters
196
200
  end
197
201
 
198
202
  it "should have the expected start encoding" do
199
- @code.start_encoding.must_equal '11010000100'
203
+ assert_equal '11010000100', @code.start_encoding
200
204
  end
201
205
 
202
206
  it "should have the expected data encoding" do
203
- @code.data_encoding.must_equal '101000110001000101100010001000110100111001101100111001011001011100'
207
+ assert_equal '101000110001000101100010001000110100111001101100111001011001011100', @code.data_encoding
204
208
  end
205
209
 
206
210
  it "should have the expected encoding" do
207
- @code.encoding.must_equal '11010000100101000110001000101100010001000110100111001101100111001011001011100100100001101100011101011'
211
+ assert_equal '11010000100101000110001000101100010001000110100111001101100111001011001011100100100001101100011101011', @code.encoding
208
212
  end
209
213
 
210
214
  it "should have the expected checksum encoding" do
211
- @code.checksum_encoding.must_equal '10010000110'
215
+ assert_equal '10010000110', @code.checksum_encoding
212
216
  end
213
217
 
214
218
  end
@@ -230,23 +234,23 @@ class Code128Test < Barby::TestCase
230
234
  end
231
235
 
232
236
  it "should have the expected characters" do
233
- @code.characters.must_equal %w(a b c 1 2 3)
237
+ assert_equal %w(a b c 1 2 3), @code.characters
234
238
  end
235
239
 
236
240
  it "should have the expected start encoding" do
237
- @code.start_encoding.must_equal '11010010000'
241
+ assert_equal '11010010000', @code.start_encoding
238
242
  end
239
243
 
240
244
  it "should have the expected data encoding" do
241
- @code.data_encoding.must_equal '100101100001001000011010000101100100111001101100111001011001011100'
245
+ assert_equal '100101100001001000011010000101100100111001101100111001011001011100', @code.data_encoding
242
246
  end
243
247
 
244
248
  it "should have the expected encoding" do
245
- @code.encoding.must_equal '11010010000100101100001001000011010000101100100111001101100111001011001011100110111011101100011101011'
249
+ assert_equal '11010010000100101100001001000011010000101100100111001101100111001011001011100110111011101100011101011', @code.encoding
246
250
  end
247
251
 
248
252
  it "should have the expected checksum encoding" do
249
- @code.checksum_encoding.must_equal '11011101110'
253
+ assert_equal '11011101110', @code.checksum_encoding
250
254
  end
251
255
 
252
256
  end
@@ -270,23 +274,23 @@ class Code128Test < Barby::TestCase
270
274
  end
271
275
 
272
276
  it "should have the expected characters" do
273
- @code.characters.must_equal %w(12 34 56)
277
+ assert_equal %w(12 34 56), @code.characters
274
278
  end
275
279
 
276
280
  it "should have the expected start encoding" do
277
- @code.start_encoding.must_equal '11010011100'
281
+ assert_equal '11010011100', @code.start_encoding
278
282
  end
279
283
 
280
284
  it "should have the expected data encoding" do
281
- @code.data_encoding.must_equal '101100111001000101100011100010110'
285
+ assert_equal '101100111001000101100011100010110', @code.data_encoding
282
286
  end
283
287
 
284
288
  it "should have the expected encoding" do
285
- @code.encoding.must_equal '11010011100101100111001000101100011100010110100011011101100011101011'
289
+ assert_equal '11010011100101100111001000101100011100010110100011011101100011101011', @code.encoding
286
290
  end
287
291
 
288
292
  it "should have the expected checksum encoding" do
289
- @code.checksum_encoding.must_equal '10001101110'
293
+ assert_equal '10001101110', @code.checksum_encoding
290
294
  end
291
295
 
292
296
  end
@@ -294,29 +298,29 @@ class Code128Test < Barby::TestCase
294
298
  describe "Function characters" do
295
299
 
296
300
  it "should retain the special symbols in the data accessor" do
297
- Code128A.new(binary_encode("\301ABC\301DEF")).data.must_equal binary_encode("\301ABC\301DEF")
298
- Code128B.new(binary_encode("\301ABC\302DEF")).data.must_equal binary_encode("\301ABC\302DEF")
299
- Code128C.new(binary_encode("\301123456")).data.must_equal binary_encode("\301123456")
300
- Code128C.new(binary_encode("12\30134\30156")).data.must_equal binary_encode("12\30134\30156")
301
+ assert_equal binary_encode("\301ABC\301DEF"), Code128A.new(binary_encode("\301ABC\301DEF")).data
302
+ assert_equal binary_encode("\301ABC\302DEF"), Code128B.new(binary_encode("\301ABC\302DEF")).data
303
+ assert_equal binary_encode("\301123456"), Code128C.new(binary_encode("\301123456")).data
304
+ assert_equal binary_encode("12\30134\30156"), Code128C.new(binary_encode("12\30134\30156")).data
301
305
  end
302
306
 
303
307
  it "should keep the special symbols as characters" do
304
- Code128A.new(binary_encode("\301ABC\301DEF")).characters.must_equal binary_encode_array(%W(\301 A B C \301 D E F))
305
- Code128B.new(binary_encode("\301ABC\302DEF")).characters.must_equal binary_encode_array(%W(\301 A B C \302 D E F))
306
- Code128C.new(binary_encode("\301123456")).characters.must_equal binary_encode_array(%W(\301 12 34 56))
307
- Code128C.new(binary_encode("12\30134\30156")).characters.must_equal binary_encode_array(%W(12 \301 34 \301 56))
308
+ assert_equal binary_encode_array(%W(\301 A B C \301 D E F)), Code128A.new(binary_encode("\301ABC\301DEF")).characters
309
+ assert_equal binary_encode_array(%W(\301 A B C \302 D E F)), Code128B.new(binary_encode("\301ABC\302DEF")).characters
310
+ assert_equal binary_encode_array(%W(\301 12 34 56)), Code128C.new(binary_encode("\301123456")).characters
311
+ assert_equal binary_encode_array(%W(12 \301 34 \301 56)), Code128C.new(binary_encode("12\30134\30156")).characters
308
312
  end
309
313
 
310
314
  it "should not allow FNC > 1 for Code C" do
311
- lambda{ Code128C.new("12\302") }.must_raise ArgumentError
312
- lambda{ Code128C.new("\30312") }.must_raise ArgumentError
313
- lambda{ Code128C.new("12\304") }.must_raise ArgumentError
315
+ assert_raises(ArgumentError){ Code128C.new("12\302") }
316
+ assert_raises(ArgumentError){ Code128C.new("\30312") }
317
+ assert_raises(ArgumentError){ Code128C.new("12\304") }
314
318
  end
315
319
 
316
320
  it "should be included in the encoding" do
317
321
  a = Code128A.new(binary_encode("\301AB"))
318
- a.data_encoding.must_equal '111101011101010001100010001011000'
319
- a.encoding.must_equal '11010000100111101011101010001100010001011000101000011001100011101011'
322
+ assert_equal '111101011101010001100010001011000', a.data_encoding
323
+ assert_equal '11010000100111101011101010001100010001011000101000011001100011101011', a.encoding
320
324
  end
321
325
 
322
326
  end
@@ -328,7 +332,9 @@ class Code128Test < Barby::TestCase
328
332
  #end
329
333
 
330
334
  it "should raise an exception when given a non-existent type" do
331
- lambda{ Code128.new('abc', 'F') }.must_raise(ArgumentError)
335
+ assert_raises ArgumentError do
336
+ Code128.new('abc', 'F')
337
+ end
332
338
  end
333
339
 
334
340
  it "should not fail on frozen type" do
@@ -338,17 +344,17 @@ class Code128Test < Barby::TestCase
338
344
 
339
345
  it "should give the right encoding for type A" do
340
346
  code = Code128.new('ABC123', 'A')
341
- code.encoding.must_equal '11010000100101000110001000101100010001000110100111001101100111001011001011100100100001101100011101011'
347
+ assert_equal '11010000100101000110001000101100010001000110100111001101100111001011001011100100100001101100011101011', code.encoding
342
348
  end
343
349
 
344
350
  it "should give the right encoding for type B" do
345
351
  code = Code128.new('abc123', 'B')
346
- code.encoding.must_equal '11010010000100101100001001000011010000101100100111001101100111001011001011100110111011101100011101011'
352
+ assert_equal '11010010000100101100001001000011010000101100100111001101100111001011001011100110111011101100011101011', code.encoding
347
353
  end
348
354
 
349
355
  it "should give the right encoding for type B" do
350
356
  code = Code128.new('123456', 'C')
351
- code.encoding.must_equal '11010011100101100111001000101100011100010110100011011101100011101011'
357
+ assert_equal '11010011100101100111001000101100011100010110100011011101100011101011', code.encoding
352
358
  end
353
359
 
354
360
  end
@@ -385,72 +391,72 @@ class Code128Test < Barby::TestCase
385
391
  =end
386
392
  it "should minimize symbol length according to GS1-128 guidelines" do
387
393
  # Determine the Start Character.
388
- Code128.apply_shortest_encoding_for_data("#{FNC1}10").must_equal "#{CODEC}#{FNC1}10"
389
- Code128.apply_shortest_encoding_for_data("#{FNC1}101234").must_equal "#{CODEC}#{FNC1}101234"
390
- Code128.apply_shortest_encoding_for_data("10\001LOT").must_equal "#{CODEA}10\001LOT"
391
- Code128.apply_shortest_encoding_for_data("lot1").must_equal "#{CODEB}lot1"
394
+ assert_equal "#{CODEC}#{FNC1}10", Code128.apply_shortest_encoding_for_data("#{FNC1}10")
395
+ assert_equal "#{CODEC}#{FNC1}101234", Code128.apply_shortest_encoding_for_data("#{FNC1}101234")
396
+ assert_equal "#{CODEA}10\001LOT", Code128.apply_shortest_encoding_for_data("10\001LOT")
397
+ assert_equal "#{CODEB}lot1", Code128.apply_shortest_encoding_for_data("lot1")
392
398
 
393
399
  # Switching to codeset B from codeset C
394
- Code128.apply_shortest_encoding_for_data("#{FNC1}101").must_equal "#{CODEC}#{FNC1}10#{CODEB}1"
400
+ assert_equal "#{CODEC}#{FNC1}10#{CODEB}1", Code128.apply_shortest_encoding_for_data("#{FNC1}101")
395
401
  # Switching to codeset A from codeset C
396
- Code128.apply_shortest_encoding_for_data("#{FNC1}10\001a").must_equal "#{CODEC}#{FNC1}10#{CODEA}\001#{CODEB}a"
402
+ assert_equal "#{CODEC}#{FNC1}10#{CODEA}\001#{CODEB}a", Code128.apply_shortest_encoding_for_data("#{FNC1}10\001a")
397
403
 
398
404
  # Switching to codeset C from codeset A
399
- Code128.apply_shortest_encoding_for_data("#{FNC1}10\001LOT1234").must_equal "#{CODEC}#{FNC1}10#{CODEA}\001LOT#{CODEC}1234"
400
- Code128.apply_shortest_encoding_for_data("#{FNC1}10\001LOT12345").must_equal "#{CODEC}#{FNC1}10#{CODEA}\001LOT1#{CODEC}2345"
405
+ assert_equal "#{CODEC}#{FNC1}10#{CODEA}\001LOT#{CODEC}1234", Code128.apply_shortest_encoding_for_data("#{FNC1}10\001LOT1234")
406
+ assert_equal "#{CODEC}#{FNC1}10#{CODEA}\001LOT1#{CODEC}2345", Code128.apply_shortest_encoding_for_data("#{FNC1}10\001LOT12345")
401
407
 
402
408
  # Switching to codeset C from codeset B
403
- Code128.apply_shortest_encoding_for_data("#{FNC1}10LOT1234").must_equal "#{CODEC}#{FNC1}10#{CODEB}LOT#{CODEC}1234"
404
- Code128.apply_shortest_encoding_for_data("#{FNC1}10LOT12345").must_equal "#{CODEC}#{FNC1}10#{CODEB}LOT1#{CODEC}2345"
409
+ assert_equal "#{CODEC}#{FNC1}10#{CODEB}LOT#{CODEC}1234", Code128.apply_shortest_encoding_for_data("#{FNC1}10LOT1234")
410
+ assert_equal "#{CODEC}#{FNC1}10#{CODEB}LOT1#{CODEC}2345", Code128.apply_shortest_encoding_for_data("#{FNC1}10LOT12345")
405
411
 
406
412
  # Switching to codeset A from codeset B
407
- Code128.apply_shortest_encoding_for_data("#{FNC1}10lot\001a").must_equal "#{CODEC}#{FNC1}10#{CODEB}lot#{SHIFT}\001a"
408
- Code128.apply_shortest_encoding_for_data("#{FNC1}10lot\001\001").must_equal "#{CODEC}#{FNC1}10#{CODEB}lot#{CODEA}\001\001"
413
+ assert_equal "#{CODEC}#{FNC1}10#{CODEB}lot#{SHIFT}\001a", Code128.apply_shortest_encoding_for_data("#{FNC1}10lot\001a")
414
+ assert_equal "#{CODEC}#{FNC1}10#{CODEB}lot#{CODEA}\001\001", Code128.apply_shortest_encoding_for_data("#{FNC1}10lot\001\001")
409
415
 
410
416
  # Switching to codeset B from codeset A
411
- Code128.apply_shortest_encoding_for_data("#{FNC1}10\001l\001").must_equal "#{CODEC}#{FNC1}10#{CODEA}\001#{SHIFT}l\001"
412
- Code128.apply_shortest_encoding_for_data("#{FNC1}10\001ll").must_equal "#{CODEC}#{FNC1}10#{CODEA}\001#{CODEB}ll"
417
+ assert_equal "#{CODEC}#{FNC1}10#{CODEA}\001#{SHIFT}l\001", Code128.apply_shortest_encoding_for_data("#{FNC1}10\001l\001")
418
+ assert_equal "#{CODEC}#{FNC1}10#{CODEA}\001#{CODEB}ll", Code128.apply_shortest_encoding_for_data("#{FNC1}10\001ll")
413
419
 
414
420
  # testing "Note 2" from the GS1 specification
415
- Code128.apply_shortest_encoding_for_data("#{FNC1}10LOT#{FNC1}0101").must_equal "#{CODEC}#{FNC1}10#{CODEB}LOT#{CODEC}#{FNC1}0101"
416
- Code128.apply_shortest_encoding_for_data("#{FNC1}10LOT#{FNC1}01010").must_equal "#{CODEC}#{FNC1}10#{CODEB}LOT#{FNC1}0#{CODEC}1010"
417
- Code128.apply_shortest_encoding_for_data("#{FNC1}10LOT01#{FNC1}0101").must_equal "#{CODEC}#{FNC1}10#{CODEB}LOT#{CODEC}01#{FNC1}0101"
421
+ assert_equal "#{CODEC}#{FNC1}10#{CODEB}LOT#{CODEC}#{FNC1}0101", Code128.apply_shortest_encoding_for_data("#{FNC1}10LOT#{FNC1}0101")
422
+ assert_equal "#{CODEC}#{FNC1}10#{CODEB}LOT#{FNC1}0#{CODEC}1010", Code128.apply_shortest_encoding_for_data("#{FNC1}10LOT#{FNC1}01010")
423
+ assert_equal "#{CODEC}#{FNC1}10#{CODEB}LOT#{CODEC}01#{FNC1}0101", Code128.apply_shortest_encoding_for_data("#{FNC1}10LOT01#{FNC1}0101")
418
424
  end
419
425
 
420
426
  it "should know how to extract CODEC segments properly from a data string" do
421
- Code128.send(:extract_codec, "1234abcd5678\r\n\r\n").must_equal ["1234", "abcd", "5678", "\r\n\r\n"]
422
- Code128.send(:extract_codec, "12345abc6").must_equal ["1234", "5abc6"]
423
- Code128.send(:extract_codec, "abcdef").must_equal ["abcdef"]
424
- Code128.send(:extract_codec, "123abcdef45678").must_equal ["123abcdef4", "5678"]
425
- Code128.send(:extract_codec, "abcd12345").must_equal ["abcd1", "2345"]
426
- Code128.send(:extract_codec, "abcd12345efg").must_equal ["abcd1", "2345", "efg"]
427
- Code128.send(:extract_codec, "12345").must_equal ["1234", "5"]
428
- Code128.send(:extract_codec, "12345abc").must_equal ["1234", "5abc"]
429
- Code128.send(:extract_codec, "abcdef1234567").must_equal ["abcdef1", "234567"]
427
+ assert_equal ["1234", "abcd", "5678", "\r\n\r\n"], Code128.send(:extract_codec, "1234abcd5678\r\n\r\n")
428
+ assert_equal ["1234", "5abc6"], Code128.send(:extract_codec, "12345abc6")
429
+ assert_equal ["abcdef"], Code128.send(:extract_codec, "abcdef")
430
+ assert_equal ["123abcdef4", "5678"], Code128.send(:extract_codec, "123abcdef45678")
431
+ assert_equal ["abcd1", "2345"], Code128.send(:extract_codec, "abcd12345")
432
+ assert_equal ["abcd1", "2345", "efg"], Code128.send(:extract_codec, "abcd12345efg")
433
+ assert_equal ["1234", "5"], Code128.send(:extract_codec, "12345")
434
+ assert_equal ["1234", "5abc"], Code128.send(:extract_codec, "12345abc")
435
+ assert_equal ["abcdef1", "234567"], Code128.send(:extract_codec, "abcdef1234567")
430
436
  end
431
437
 
432
438
  it "should know how to most efficiently apply different encodings to a data string" do
433
- Code128.apply_shortest_encoding_for_data("123456").must_equal "#{CODEC}123456"
434
- Code128.apply_shortest_encoding_for_data("abcdef").must_equal "#{CODEB}abcdef"
435
- Code128.apply_shortest_encoding_for_data("ABCDEF").must_equal "#{CODEB}ABCDEF"
436
- Code128.apply_shortest_encoding_for_data("\n\t\r").must_equal "#{CODEA}\n\t\r"
437
- Code128.apply_shortest_encoding_for_data("123456abcdef").must_equal "#{CODEC}123456#{CODEB}abcdef"
438
- Code128.apply_shortest_encoding_for_data("abcdef123456").must_equal "#{CODEB}abcdef#{CODEC}123456"
439
- Code128.apply_shortest_encoding_for_data("1234567").must_equal "#{CODEC}123456#{CODEB}7"
440
- Code128.apply_shortest_encoding_for_data("123b456").must_equal "#{CODEB}123b456"
441
- Code128.apply_shortest_encoding_for_data("abc123def45678gh").must_equal "#{CODEB}abc123def4#{CODEC}5678#{CODEB}gh"
442
- Code128.apply_shortest_encoding_for_data("12345AB\nEEasdgr12EE\r\n").must_equal "#{CODEC}1234#{CODEA}5AB\nEE#{CODEB}asdgr12EE#{CODEA}\r\n"
443
- Code128.apply_shortest_encoding_for_data("123456QWERTY\r\n\tAAbbcc12XX34567").must_equal "#{CODEC}123456#{CODEA}QWERTY\r\n\tAA#{CODEB}bbcc12XX3#{CODEC}4567"
444
-
445
- Code128.apply_shortest_encoding_for_data("ABCdef\rGHIjkl").must_equal "#{CODEB}ABCdef#{SHIFT}\rGHIjkl"
446
- Code128.apply_shortest_encoding_for_data("ABC\rb\nDEF12gHI3456").must_equal "#{CODEA}ABC\r#{SHIFT}b\nDEF12#{CODEB}gHI#{CODEC}3456"
447
- Code128.apply_shortest_encoding_for_data("ABCdef\rGHIjkl\tMNop\nqRs").must_equal "#{CODEB}ABCdef#{SHIFT}\rGHIjkl#{SHIFT}\tMNop#{SHIFT}\nqRs"
439
+ assert_equal "#{CODEC}123456", Code128.apply_shortest_encoding_for_data("123456")
440
+ assert_equal "#{CODEB}abcdef", Code128.apply_shortest_encoding_for_data("abcdef")
441
+ assert_equal "#{CODEB}ABCDEF", Code128.apply_shortest_encoding_for_data("ABCDEF")
442
+ assert_equal "#{CODEA}\n\t\r", Code128.apply_shortest_encoding_for_data("\n\t\r")
443
+ assert_equal "#{CODEC}123456#{CODEB}abcdef", Code128.apply_shortest_encoding_for_data("123456abcdef")
444
+ assert_equal "#{CODEB}abcdef#{CODEC}123456", Code128.apply_shortest_encoding_for_data("abcdef123456")
445
+ assert_equal "#{CODEC}123456#{CODEB}7", Code128.apply_shortest_encoding_for_data("1234567")
446
+ assert_equal "#{CODEB}123b456", Code128.apply_shortest_encoding_for_data("123b456")
447
+ assert_equal "#{CODEB}abc123def4#{CODEC}5678#{CODEB}gh", Code128.apply_shortest_encoding_for_data("abc123def45678gh")
448
+ assert_equal "#{CODEC}1234#{CODEA}5AB\nEE#{CODEB}asdgr12EE#{CODEA}\r\n", Code128.apply_shortest_encoding_for_data("12345AB\nEEasdgr12EE\r\n")
449
+ assert_equal "#{CODEC}123456#{CODEA}QWERTY\r\n\tAA#{CODEB}bbcc12XX3#{CODEC}4567", Code128.apply_shortest_encoding_for_data("123456QWERTY\r\n\tAAbbcc12XX34567")
450
+
451
+ assert_equal "#{CODEB}ABCdef#{SHIFT}\rGHIjkl", Code128.apply_shortest_encoding_for_data("ABCdef\rGHIjkl")
452
+ assert_equal "#{CODEA}ABC\r#{SHIFT}b\nDEF12#{CODEB}gHI#{CODEC}3456", Code128.apply_shortest_encoding_for_data("ABC\rb\nDEF12gHI3456")
453
+ assert_equal "#{CODEB}ABCdef#{SHIFT}\rGHIjkl#{SHIFT}\tMNop#{SHIFT}\nqRs", Code128.apply_shortest_encoding_for_data("ABCdef\rGHIjkl\tMNop\nqRs")
448
454
  end
449
455
 
450
456
  it "should apply automatic charset when no charset is given" do
451
457
  b = Code128.new("123456QWERTY\r\n\tAAbbcc12XX34567")
452
- b.type.must_equal 'C'
453
- b.full_data_with_change_codes.must_equal "123456#{CODEA}QWERTY\r\n\tAA#{CODEB}bbcc12XX3#{CODEC}4567"
458
+ assert_equal 'C', b.type
459
+ assert_equal "123456#{CODEA}QWERTY\r\n\tAA#{CODEB}bbcc12XX3#{CODEC}4567", b.full_data_with_change_codes
454
460
  end
455
461
 
456
462
  end
@@ -9,11 +9,11 @@ class Code25IATATest < Barby::TestCase
9
9
  end
10
10
 
11
11
  it "should have the expected start_encoding" do
12
- @code.start_encoding.must_equal '1010'
12
+ assert_equal '1010', @code.start_encoding
13
13
  end
14
14
 
15
15
  it "should have the expected stop_encoding" do
16
- @code.stop_encoding.must_equal '11101'
16
+ assert_equal '11101', @code.stop_encoding
17
17
  end
18
18
 
19
19
  end
@@ -9,27 +9,27 @@ class Code25InterleavedTest < Barby::TestCase
9
9
  end
10
10
 
11
11
  it "should have the expected digit_pairs" do
12
- @code.digit_pairs.must_equal [[1,2],[3,4],[5,6],[7,0]]
12
+ assert_equal [[1,2],[3,4],[5,6],[7,0]], @code.digit_pairs
13
13
  end
14
14
 
15
15
  it "should have the expected digit_encodings" do
16
- @code.digit_encodings.must_equal %w(111010001010111000 111011101000101000 111010001110001010 101010001110001110)
16
+ assert_equal %w(111010001010111000 111011101000101000 111010001110001010 101010001110001110), @code.digit_encodings
17
17
  end
18
18
 
19
19
  it "should have the expected start_encoding" do
20
- @code.start_encoding.must_equal '1010'
20
+ assert_equal '1010', @code.start_encoding
21
21
  end
22
22
 
23
23
  it "should have the expected stop_encoding" do
24
- @code.stop_encoding.must_equal '11101'
24
+ assert_equal '11101', @code.stop_encoding
25
25
  end
26
26
 
27
27
  it "should have the expected data_encoding" do
28
- @code.data_encoding.must_equal "111010001010111000111011101000101000111010001110001010101010001110001110"
28
+ assert_equal "111010001010111000111011101000101000111010001110001010101010001110001110", @code.data_encoding
29
29
  end
30
30
 
31
31
  it "should have the expected encoding" do
32
- @code.encoding.must_equal "101011101000101011100011101110100010100011101000111000101010101000111000111011101"
32
+ assert_equal "101011101000101011100011101110100010100011101000111000101010101000111000111011101", @code.encoding
33
33
  end
34
34
 
35
35
  it "should be valid" do
@@ -40,16 +40,16 @@ class Code25InterleavedTest < Barby::TestCase
40
40
  w, n = Code25Interleaved::WIDE, Code25Interleaved::NARROW
41
41
  # 1 2 1 2 1 2 1 2 1 2 digits 1 and 2
42
42
  # B S B S B S B S B S bars and spaces
43
- @code.encoding_for_interleaved(w,n,n,w,n,n,n,n,w,w).must_equal '111010001010111000'
43
+ assert_equal '111010001010111000', @code.encoding_for_interleaved(w,n,n,w,n,n,n,n,w,w)
44
44
  # 3 4 3 4 3 4 3 4 3 4 digits 3 and 4
45
45
  # B S B S B S B S B S bars and spaces
46
- @code.encoding_for_interleaved(w,n,w,n,n,w,n,n,n,w).must_equal '111011101000101000'
46
+ assert_equal '111011101000101000', @code.encoding_for_interleaved(w,n,w,n,n,w,n,n,n,w)
47
47
  end
48
48
 
49
49
  it "should return all characters in sequence for to_s" do
50
- @code.to_s.must_equal @code.characters.join
50
+ assert_equal @code.characters.join, @code.to_s
51
51
  end
52
-
52
+
53
53
  describe "with checksum" do
54
54
 
55
55
  before do
@@ -59,19 +59,19 @@ class Code25InterleavedTest < Barby::TestCase
59
59
  end
60
60
 
61
61
  it "should have the expected digit_pairs_with_checksum" do
62
- @code.digit_pairs_with_checksum.must_equal [[1,2],[3,4],[5,6],[7,0]]
62
+ assert_equal [[1,2],[3,4],[5,6],[7,0]], @code.digit_pairs_with_checksum
63
63
  end
64
64
 
65
65
  it "should have the expected digit_encodings_with_checksum" do
66
- @code.digit_encodings_with_checksum.must_equal %w(111010001010111000 111011101000101000 111010001110001010 101010001110001110)
66
+ assert_equal %w(111010001010111000 111011101000101000 111010001110001010 101010001110001110), @code.digit_encodings_with_checksum
67
67
  end
68
68
 
69
69
  it "should have the expected data_encoding_with_checksum" do
70
- @code.data_encoding_with_checksum.must_equal "111010001010111000111011101000101000111010001110001010101010001110001110"
70
+ assert_equal "111010001010111000111011101000101000111010001110001010101010001110001110", @code.data_encoding_with_checksum
71
71
  end
72
72
 
73
73
  it "should have the expected encoding" do
74
- @code.encoding.must_equal "101011101000101011100011101110100010100011101000111000101010101000111000111011101"
74
+ assert_equal "101011101000101011100011101110100010100011101000111000101010101000111000111011101", @code.encoding
75
75
  end
76
76
 
77
77
  it "should be valid" do
@@ -79,7 +79,7 @@ class Code25InterleavedTest < Barby::TestCase
79
79
  end
80
80
 
81
81
  it "should return all characters including checksum in sequence on to_s" do
82
- @code.to_s.must_equal @code.characters_with_checksum.join
82
+ assert_equal @code.characters_with_checksum.join, @code.to_s
83
83
  end
84
84
 
85
85
  end
@@ -96,9 +96,15 @@ class Code25InterleavedTest < Barby::TestCase
96
96
  end
97
97
 
98
98
  it "should raise ArgumentError on all encoding methods" do
99
- lambda{ @code.encoding }.must_raise(ArgumentError)
100
- lambda{ @code.data_encoding }.must_raise(ArgumentError)
101
- lambda{ @code.digit_encodings }.must_raise(ArgumentError)
99
+ assert_raises ArgumentError do
100
+ @code.encoding
101
+ end
102
+ assert_raises ArgumentError do
103
+ @code.data_encoding
104
+ end
105
+ assert_raises ArgumentError do
106
+ @code.digit_encodings
107
+ end
102
108
  end
103
109
 
104
110
  it "should not raise ArgumentError on encoding methods that include checksum" do