png 1.2.0 → 1.3.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/test/test_png.rb CHANGED
@@ -1,42 +1,34 @@
1
- dir = File.expand_path "~/.ruby_inline"
2
- if test ?d, dir then
3
- require 'fileutils'
4
- puts "nuking #{dir}"
5
- # force removal, Windoze is bitching at me, something to hunt later...
6
- FileUtils.rm_r dir, :force => true
7
- end
8
-
9
- require 'minitest/autorun'
10
- require 'rubygems'
11
- require 'png'
12
- require 'png/reader'
13
- require 'png/pie'
1
+ require "minitest/autorun"
2
+ require "rubygems"
3
+ require "png"
4
+ require "png/reader"
5
+ require "png/pie"
14
6
 
15
- class TestPng < MiniTest::Unit::TestCase
7
+ class TestPng < Minitest::Test
16
8
  def setup
17
9
  @canvas = PNG::Canvas.new 5, 10, PNG::Color::White
18
10
  @png = PNG.new @canvas
19
11
 
20
- @blob = <<-EOF.unpack('m*').first
12
+ @blob = <<-EOF.unpack("m*").first
21
13
  iVBORw0KGgoAAAANSUhEUgAAAAUAAAAKCAYAAAB8OZQwAAAAD0lEQVR4nGP4
22
14
  jwUwDGVBALuJxzlQugpEAAAAAElFTkSuQmCC
23
15
  EOF
24
16
  end
25
17
 
26
18
  def test_class_chunk
27
- chunk = PNG.chunk 'IHDR', [10, 10, 8, 6, 0, 0, 0 ].pack('N2C5')
19
+ chunk = PNG.chunk "IHDR", [10, 10, 8, 6, 0, 0, 0].pack("N2C5")
28
20
 
29
- header_crc = "\2152\317\275"
30
- header_data = "\000\000\000\n\000\000\000\n\b\006\000\000\000"
31
- header_length = "\000\000\000\r"
32
- header_chunk = "#{header_length}IHDR#{header_data}#{header_crc}"
21
+ header_crc = "\2152\317\275".b
22
+ header_data = "\000\000\000\n\000\000\000\n\b\006\000\000\000".b
23
+ header_length = "\000\000\000\r".b
24
+ header_chunk = "#{header_length}IHDR#{header_data}#{header_crc}".b
33
25
 
34
26
  assert_equal header_chunk, chunk
35
27
  end
36
28
 
37
29
  def test_class_chunk_empty
38
- chunk = PNG.chunk 'IHDR'
39
- expected = "#{0.chr * 4}IHDR#{["IHDR".png_crc].pack 'N'}"
30
+ chunk = PNG.chunk "IHDR"
31
+ expected = "#{0.chr * 4}IHDR#{["IHDR".png_crc].pack "N"}"
40
32
  assert_equal expected, chunk
41
33
  end
42
34
 
@@ -47,7 +39,7 @@ jwUwDGVBALuJxzlQugpEAAAAAElFTkSuQmCC
47
39
  def test_save
48
40
  path = "blah.png"
49
41
  @png.save(path)
50
- file = File.open(path, 'rb') { |f| f.read }
42
+ file = File.open(path, "rb") { |f| f.read }
51
43
  assert_equal @blob, file
52
44
  ensure
53
45
  assert_equal 1, File.unlink(path)
@@ -55,7 +47,7 @@ jwUwDGVBALuJxzlQugpEAAAAAElFTkSuQmCC
55
47
 
56
48
  end
57
49
 
58
- class TestCanvas < MiniTest::Unit::TestCase
50
+ class TestCanvas < Minitest::Test
59
51
 
60
52
  def setup
61
53
  @canvas = PNG::Canvas.new 5, 10, PNG::Color::White
@@ -70,9 +62,9 @@ class TestCanvas < MiniTest::Unit::TestCase
70
62
  xxxxxxxx
71
63
  xx..xxxx
72
64
  ..xxxxxx
73
- ".gsub(/ /, '')
65
+ ".gsub(/ /, "")
74
66
 
75
- assert_equal expected, canvas1.to_s.gsub(/ /, 'x')
67
+ assert_equal expected, canvas1.to_s.gsub(/ /, "x")
76
68
  end
77
69
 
78
70
  def test_composite_underlay
@@ -84,9 +76,9 @@ class TestCanvas < MiniTest::Unit::TestCase
84
76
  xxxx..xx
85
77
  xx00xxxx
86
78
  ..xxxxxx
87
- ".gsub(/ /, '')
79
+ ".gsub(/ /, "")
88
80
 
89
- assert_equal expected, canvas1.to_s.gsub(/ /, 'x')
81
+ assert_equal expected, canvas1.to_s.gsub(/ /, "x")
90
82
  end
91
83
 
92
84
  def test_composite_overlay
@@ -98,9 +90,9 @@ class TestCanvas < MiniTest::Unit::TestCase
98
90
  xxxx..xx
99
91
  xx..xxxx
100
92
  ..xxxxxx
101
- ".gsub(/ /, '')
93
+ ".gsub(/ /, "")
102
94
 
103
- assert_equal expected, canvas1.to_s.gsub(/ /, 'x')
95
+ assert_equal expected, canvas1.to_s.gsub(/ /, "x")
104
96
  end
105
97
 
106
98
  def test_composite_blend
@@ -112,9 +104,9 @@ class TestCanvas < MiniTest::Unit::TestCase
112
104
  xxxx..xx
113
105
  xx,,xxxx
114
106
  ..xxxxxx
115
- ".gsub(/ /, '')
107
+ ".gsub(/ /, "")
116
108
 
117
- assert_equal expected, canvas1.to_s.gsub(/ /, 'x')
109
+ assert_equal expected, canvas1.to_s.gsub(/ /, "x")
118
110
  end
119
111
 
120
112
  def test_composite_bad_style
@@ -132,17 +124,17 @@ class TestCanvas < MiniTest::Unit::TestCase
132
124
  xxxx..xx
133
125
  xx00xxxx
134
126
  ..xxxxxx
135
- ".gsub(/ /, '')
127
+ ".gsub(/ /, "")
136
128
 
137
- assert_equal expected, canvas1.to_s.gsub(/ /, 'x')
129
+ assert_equal expected, canvas1.to_s.gsub(/ /, "x")
138
130
 
139
131
  canvas2 = canvas1.extract(1, 1, 2, 2)
140
132
 
141
133
  expected = " xx..
142
134
  00xx
143
- ".gsub(/ /, '')
135
+ ".gsub(/ /, "")
144
136
 
145
- assert_equal expected, canvas2.to_s.gsub(/ /, 'x')
137
+ assert_equal expected, canvas2.to_s.gsub(/ /, "x")
146
138
  end
147
139
 
148
140
  def test_index
@@ -152,10 +144,10 @@ class TestCanvas < MiniTest::Unit::TestCase
152
144
 
153
145
  def test_index_tall
154
146
  @canvas = PNG::Canvas.new 2, 4, PNG::Color::White
155
- @canvas[ 0, 0] = PNG::Color::Black
156
- @canvas[ 0, 3] = PNG::Color::Background
157
- @canvas[ 1, 0] = PNG::Color::Yellow
158
- @canvas[ 1, 3] = PNG::Color::Blue
147
+ @canvas[0, 0] = PNG::Color::Black
148
+ @canvas[0, 3] = PNG::Color::Background
149
+ @canvas[1, 0] = PNG::Color::Yellow
150
+ @canvas[1, 3] = PNG::Color::Blue
159
151
 
160
152
  expected = " ,,\n0000\n0000\n..++\n"
161
153
 
@@ -164,10 +156,10 @@ class TestCanvas < MiniTest::Unit::TestCase
164
156
 
165
157
  def test_index_wide
166
158
  @canvas = PNG::Canvas.new 4, 2, PNG::Color::White
167
- @canvas[ 0, 0] = PNG::Color::Black
168
- @canvas[ 3, 0] = PNG::Color::Background
169
- @canvas[ 0, 1] = PNG::Color::Yellow
170
- @canvas[ 3, 1] = PNG::Color::Blue
159
+ @canvas[0, 0] = PNG::Color::Black
160
+ @canvas[3, 0] = PNG::Color::Background
161
+ @canvas[0, 1] = PNG::Color::Yellow
162
+ @canvas[3, 1] = PNG::Color::Blue
171
163
 
172
164
  expected = "++0000,,\n..0000 \n"
173
165
 
@@ -175,23 +167,19 @@ class TestCanvas < MiniTest::Unit::TestCase
175
167
  end
176
168
 
177
169
  def test_index_bad_x
178
- begin
179
- @canvas[6, 1]
180
- rescue => e
181
- assert_equal "bad x value 6 >= 5", e.message
182
- else
183
- flunk "didn't raise"
184
- end
170
+ @canvas[6, 1] # TODO: convert these to assert_raises
171
+ rescue => e
172
+ assert_equal "bad x value 6 >= 5", e.message
173
+ else
174
+ flunk "didn't raise"
185
175
  end
186
176
 
187
177
  def test_index_bad_y
188
- begin
189
- @canvas[1, 11]
190
- rescue => e
191
- assert_equal "bad y value 11 >= 10", e.message
192
- else
193
- flunk "didn't raise"
194
- end
178
+ @canvas[1, 11]
179
+ rescue => e
180
+ assert_equal "bad y value 11 >= 10", e.message
181
+ else
182
+ flunk "didn't raise"
195
183
  end
196
184
 
197
185
  def test_index_equals
@@ -215,28 +203,24 @@ class TestCanvas < MiniTest::Unit::TestCase
215
203
  end
216
204
 
217
205
  def test_index_equals_bad_x
218
- begin
219
- @canvas[6, 1] = PNG::Color::Red
220
- rescue => e
221
- assert_equal "bad x value 6 >= 5", e.message
222
- else
223
- flunk "didn't raise"
224
- end
206
+ @canvas[6, 1] = PNG::Color::Red
207
+ rescue => e
208
+ assert_equal "bad x value 6 >= 5", e.message
209
+ else
210
+ flunk "didn't raise"
225
211
  end
226
212
 
227
213
  def test_index_equals_bad_y
228
- begin
229
- @canvas[1, 11] = PNG::Color::Red
230
- rescue => e
231
- assert_equal "bad y value 11 >= 10", e.message
232
- else
233
- flunk "didn't raise"
234
- end
214
+ @canvas[1, 11] = PNG::Color::Red
215
+ rescue => e
216
+ assert_equal "bad y value 11 >= 10", e.message
217
+ else
218
+ flunk "didn't raise"
235
219
  end
236
220
 
237
- # def test_point
238
- # raise NotImplementedError, 'Need to write test_point'
239
- # end
221
+ # def test_point
222
+ # raise NotImplementedError, 'Need to write test_point'
223
+ # end
240
224
 
241
225
  def test_inspect
242
226
  assert_equal "#<PNG::Canvas 5x10>", @canvas.inspect
@@ -320,29 +304,28 @@ class TestCanvas < MiniTest::Unit::TestCase
320
304
  xxxx..xx
321
305
  xx00xxxx
322
306
  ..xxxxxx
323
- ".gsub(/ /, '')
324
-
325
- assert_equal expected, canvas1.to_s.gsub(/ /, 'x')
307
+ ".gsub(/ /, "")
326
308
 
309
+ assert_equal expected, canvas1.to_s.gsub(/ /, "x")
327
310
 
328
311
  canvas2 = PNG::Canvas.new 2, 2
329
312
  canvas2[0, 0] = PNG::Color::Black
330
313
 
331
- expected = " xxxx
314
+ expected = " xxxx
332
315
  ..xx
333
- ".gsub(/ /, '')
316
+ ".gsub(/ /, "")
334
317
 
335
- assert_equal expected, canvas2.to_s.gsub(/ /, 'x')
318
+ assert_equal expected, canvas2.to_s.gsub(/ /, "x")
336
319
 
337
320
  return canvas1, canvas2
338
321
  end
339
322
 
340
- def util_ascii_art(width, height)
323
+ def util_ascii_art width, height
341
324
  (("0" * width * 2) + "\n") * height
342
325
  end
343
326
  end
344
327
 
345
- class TestPng::TestColor < MiniTest::Unit::TestCase
328
+ class TestPng::TestColor < Minitest::Test
346
329
  def setup
347
330
  @color = PNG::Color.new 0x01, 0x02, 0x03, 0x04
348
331
  end
@@ -380,11 +363,6 @@ class TestPng::TestColor < MiniTest::Unit::TestCase
380
363
  end
381
364
 
382
365
  def test_blend
383
- # c1 = @color
384
- # c2 = PNG::Color.new 0xFF, 0xFE, 0xFD, 0xFC
385
-
386
- # assert_equal PNG::Color.new(0xFB, 0xFA, 0xF9, 0xF8), c1.blend(c2)
387
-
388
366
  c1 = PNG::Color::White
389
367
  c2 = PNG::Color::Black
390
368
 
@@ -420,50 +398,50 @@ class TestPng::TestColor < MiniTest::Unit::TestCase
420
398
  end
421
399
 
422
400
  def test_to_ascii
423
- assert_equal '00', PNG::Color::White.to_ascii, "white"
424
- assert_equal '++', PNG::Color::Yellow.to_ascii, "yellow"
425
- assert_equal ',,', PNG::Color::Red.to_ascii, "red"
426
- assert_equal '..', PNG::Color::Black.to_ascii, "black"
427
- assert_equal ' ', PNG::Color::Background.to_ascii, "background"
401
+ assert_equal "00", PNG::Color::White.to_ascii, "white"
402
+ assert_equal "++", PNG::Color::Yellow.to_ascii, "yellow"
403
+ assert_equal ",,", PNG::Color::Red.to_ascii, "red"
404
+ assert_equal "..", PNG::Color::Black.to_ascii, "black"
405
+ assert_equal " ", PNG::Color::Background.to_ascii, "background"
428
406
  end
429
407
 
430
408
  def test_to_ascii_alpha
431
- assert_equal '00', PNG::Color.new(255,255,255,255).to_ascii
432
- assert_equal '00', PNG::Color.new(255,255,255,192).to_ascii
433
- assert_equal '++', PNG::Color.new(255,255,255,191).to_ascii
434
- assert_equal ',,', PNG::Color.new(255,255,255,127).to_ascii
435
- assert_equal ',,', PNG::Color.new(255,255,255,126).to_ascii
436
- assert_equal ',,', PNG::Color.new(255,255,255, 64).to_ascii
437
- assert_equal '..', PNG::Color.new(255,255,255, 63).to_ascii
438
- assert_equal '..', PNG::Color.new(255,255,255, 1).to_ascii
439
- assert_equal ' ', PNG::Color.new(255,255,255, 0).to_ascii
409
+ assert_equal "00", PNG::Color.new(255, 255, 255, 255).to_ascii
410
+ assert_equal "00", PNG::Color.new(255, 255, 255, 192).to_ascii
411
+ assert_equal "++", PNG::Color.new(255, 255, 255, 191).to_ascii
412
+ assert_equal ",,", PNG::Color.new(255, 255, 255, 127).to_ascii
413
+ assert_equal ",,", PNG::Color.new(255, 255, 255, 126).to_ascii
414
+ assert_equal ",,", PNG::Color.new(255, 255, 255, 64).to_ascii
415
+ assert_equal "..", PNG::Color.new(255, 255, 255, 63).to_ascii
416
+ assert_equal "..", PNG::Color.new(255, 255, 255, 1).to_ascii
417
+ assert_equal " ", PNG::Color.new(255, 255, 255, 0).to_ascii
440
418
  end
441
419
 
442
420
  def test_to_s_name
443
- assert_equal 'Red', PNG::Color::Red.to_s
421
+ assert_equal "Red", PNG::Color::Red.to_s
444
422
  end
445
423
 
446
424
  def test_to_s
447
- obj = PNG::Color.new(255,255,255, 0)
448
- assert_equal '#<PNG::Color:0xXXXXXX>', obj.to_s.sub(/0x[0-9a-f]+/, '0xXXXXXX')
425
+ obj = PNG::Color.new(255, 255, 255, 0)
426
+ assert_equal "#<PNG::Color:0xXXXXXX>", obj.to_s.sub(/0x[0-9a-f]+/, "0xXXXXXX")
449
427
  end
450
428
 
451
429
  def test_equals2
452
- assert_equal PNG::Color.new(255,255,255, 0), PNG::Color.new(255,255,255, 0)
430
+ assert_equal PNG::Color.new(255, 255, 255, 0), PNG::Color.new(255, 255, 255, 0)
453
431
  end
454
432
 
455
433
  def test_hash
456
- a = PNG::Color.new(255,255,255, 0)
457
- b = PNG::Color.new(255,255,255, 0)
434
+ a = PNG::Color.new(255, 255, 255, 0)
435
+ b = PNG::Color.new(255, 255, 255, 0)
458
436
  assert_equal a.hash, b.hash
459
437
  end
460
438
 
461
- # def test_values
462
- # raise NotImplementedError, 'Need to write test_values'
463
- # end
439
+ # def test_values
440
+ # raise NotImplementedError, 'Need to write test_values'
441
+ # end
464
442
  end
465
443
 
466
- class TestPng::TestPie < MiniTest::Unit::TestCase
444
+ class TestPng::TestPie < Minitest::Test
467
445
  def test_pie_chart_odd
468
446
  expected =
469
447
  [" .. ",
@@ -477,9 +455,9 @@ class TestPng::TestPie < MiniTest::Unit::TestCase
477
455
  " ,,,,,,,,,,,,,,,,,, ",
478
456
  " ,,,,,,,,,,,,,, ",
479
457
  " ,, ",
480
- nil].join("\n")
458
+ nil].join("\n")
481
459
 
482
- actual = PNG::pie_chart(11, 0.25, PNG::Color::Black, PNG::Color::Green)
460
+ actual = PNG.pie_chart(11, 0.25, PNG::Color::Black, PNG::Color::Green)
483
461
  assert_equal expected, actual.to_s
484
462
  end
485
463
 
@@ -496,38 +474,32 @@ class TestPng::TestPie < MiniTest::Unit::TestCase
496
474
  " ,,,,,,,,,,,,,,,,,, ",
497
475
  " ,,,,,,,,,,,,,, ",
498
476
  " ,, ",
499
- nil].join("\n")
477
+ nil].join("\n")
500
478
 
501
- actual = PNG::pie_chart(10, 0.25, PNG::Color::Black, PNG::Color::Green)
479
+ actual = PNG.pie_chart(10, 0.25, PNG::Color::Black, PNG::Color::Green)
502
480
  assert_equal expected, actual.to_s
503
481
  end
504
482
 
505
- def util_angle(expect, x, y)
483
+ def assert_angle expect, x, y
506
484
  actual = PNG.angle(x, y)
507
- case expect
508
- when Integer then
509
- assert_equal(expect, actual,
510
- "[#{x}, #{y}] should be == #{expect}, was #{actual}")
511
- else
512
- assert_in_delta(expect, actual, 0.5)
513
- end
485
+ assert_in_epsilon expect, actual
514
486
  end
515
487
 
516
488
  def test_math_is_hard_lets_go_shopping
517
- util_angle 0, 0, 0
489
+ assert_angle 0, 0, 0
518
490
  (25..500).step(25) do |n|
519
- util_angle 0, 0, n
520
- util_angle 90, n, 0
521
- util_angle 180, 0, -n
522
- util_angle 270, -n, 0
491
+ assert_angle 0, 0, n
492
+ assert_angle 90, n, 0
493
+ assert_angle 180, 0, -n
494
+ assert_angle 270, -n, 0
523
495
  end
524
496
 
525
- util_angle 359.5, -1, 250
526
- util_angle 0.0, 0, 250
527
- util_angle 0.5, 1, 250
497
+ assert_angle 359.5, -1, 250
498
+ assert_angle 0.0, 0, 250
499
+ assert_angle 0.2292, 1, 250
528
500
 
529
- util_angle 89.5, 250, 1
530
- util_angle 90.0, 250, 0
531
- util_angle 90.5, 250, -1
501
+ assert_angle 89.77, 250, 1
502
+ assert_angle 90.0, 250, 0
503
+ assert_angle 90.23, 250, -1
532
504
  end
533
505
  end
@@ -1,16 +1,8 @@
1
- dir = File.expand_path "~/.ruby_inline"
2
- if test ?d, dir then
3
- require 'fileutils'
4
- puts "nuking #{dir}"
5
- # force removal, Windoze is bitching at me, something to hunt later...
6
- FileUtils.rm_r dir, :force => true
7
- end
8
-
9
- require 'rubygems'
10
- require 'minitest/autorun'
11
- require 'png/font'
1
+ require "rubygems"
2
+ require "minitest/autorun"
3
+ require "png/font"
12
4
 
13
- class TestPngFont < MiniTest::Unit::TestCase
5
+ class TestPngFont < Minitest::Test
14
6
 
15
7
  def setup
16
8
  @font = PNG::Font.default
@@ -25,13 +17,13 @@ class TestPngFont < MiniTest::Unit::TestCase
25
17
  end
26
18
 
27
19
  def test_coordinates
28
- assert_equal [ 0, 0, 5, 5], @font.coordinates('(')
29
- assert_equal [ 0, 6, 5, 11], @font.coordinates('0')
30
- assert_equal [ 0, 12, 5, 17], @font.coordinates('a')
31
- assert_equal [ 0, 18, 5, 23], @font.coordinates('A')
20
+ assert_equal [0, 0, 5, 5], @font.coordinates("(")
21
+ assert_equal [0, 6, 5, 11], @font.coordinates("0")
22
+ assert_equal [0, 12, 5, 17], @font.coordinates("a")
23
+ assert_equal [0, 18, 5, 23], @font.coordinates("A")
32
24
 
33
- assert_equal [42, 12, 47, 17], @font.coordinates('h')
34
- assert_equal [42, 18, 47, 23], @font.coordinates('H')
25
+ assert_equal [42, 12, 47, 17], @font.coordinates("h")
26
+ assert_equal [42, 18, 47, 23], @font.coordinates("H")
35
27
  end
36
28
 
37
29
  def test_index
@@ -44,7 +36,7 @@ class TestPngFont < MiniTest::Unit::TestCase
44
36
  000000000000
45
37
  ".strip + "\n"
46
38
 
47
- assert_equal expected, @font['A'].to_s
39
+ assert_equal expected, @font["A"].to_s
48
40
 
49
41
  expected = "
50
42
  00000000..00
@@ -55,11 +47,11 @@ class TestPngFont < MiniTest::Unit::TestCase
55
47
  000000000000
56
48
  ".strip + "\n"
57
49
 
58
- assert_equal expected, @font['l'].to_s
50
+ assert_equal expected, @font["l"].to_s
59
51
  end
60
52
 
61
53
  def test_index_identity
62
- assert_same @font['A'], @font['A']
54
+ assert_same @font["A"], @font["A"]
63
55
  end
64
56
 
65
57
  def test_annotate
@@ -1,16 +1,8 @@
1
- dir = File.expand_path "~/.ruby_inline"
2
- if test ?d, dir then
3
- require 'fileutils'
4
- puts "nuking #{dir}"
5
- # force removal, Windoze is bitching at me, something to hunt later...
6
- FileUtils.rm_r dir, :force => true
7
- end
8
-
9
- require 'rubygems'
10
- require 'minitest/autorun'
11
- require 'png/reader'
1
+ require "rubygems"
2
+ require "minitest/autorun"
3
+ require "png/reader"
12
4
 
13
- class TestPngReader < MiniTest::Unit::TestCase
5
+ class TestPngReader < Minitest::Test
14
6
 
15
7
  def setup
16
8
  @canvas = PNG::Canvas.new 5, 10, PNG::Color::White
@@ -18,32 +10,30 @@ class TestPngReader < MiniTest::Unit::TestCase
18
10
 
19
11
  @IHDR_length = "\000\000\000\r"
20
12
  @IHDR_crc = "\2152\317\275"
21
- @IHDR_crc_value = @IHDR_crc.unpack('N').first
13
+ @IHDR_crc_value = @IHDR_crc.unpack("N").first
22
14
  @IHDR_data = "\000\000\000\n\000\000\000\n\b\006\000\000\000"
23
15
  @IHDR_chunk = "#{@IHDR_length}IHDR#{@IHDR_data}#{@IHDR_crc}"
24
16
 
25
- @blob = <<-EOF.unpack('m*').first
17
+ @blob = <<-EOF.unpack("m*").first
26
18
  iVBORw0KGgoAAAANSUhEUgAAAAUAAAAKCAYAAAB8OZQwAAAAD0lEQVR4nGP4
27
19
  jwUwDGVBALuJxzlQugpEAAAAAElFTkSuQmCC
28
20
  EOF
29
21
  end
30
22
 
31
23
  def test_class_check_crc
32
- assert PNG.check_crc('IHDR', @IHDR_data, @IHDR_crc_value)
24
+ assert PNG.check_crc("IHDR", @IHDR_data, @IHDR_crc_value)
33
25
  end
34
26
 
35
27
  def test_class_check_crc_exception
36
- begin
37
- PNG.check_crc('IHDR', @IHDR_data, @IHDR_crc_value + 1)
38
- rescue ArgumentError => e
39
- assert_equal "Invalid CRC encountered in IHDR chunk", e.message
40
- else
41
- flunk "exception wasn't raised"
42
- end
28
+ PNG.check_crc("IHDR", @IHDR_data, @IHDR_crc_value + 1)
29
+ rescue ArgumentError => e
30
+ assert_equal "Invalid CRC encountered in IHDR chunk", e.message
31
+ else
32
+ flunk "exception wasn't raised"
43
33
  end
44
34
 
45
35
  def test_class_read_chunk
46
- data = PNG.read_chunk 'IHDR', @IHDR_chunk
36
+ data = PNG.read_chunk "IHDR", @IHDR_chunk.dup
47
37
 
48
38
  assert_equal @IHDR_data, data
49
39
  end
@@ -51,8 +41,8 @@ jwUwDGVBALuJxzlQugpEAAAAAElFTkSuQmCC
51
41
  def test_class_read_IDAT
52
42
  canvas = PNG::Canvas.new 5, 10, PNG::Color::White
53
43
 
54
- data = ([ 0, [255] * (4*5) ] * 10)
55
- data = data.flatten.map { |n| n.chr }.join
44
+ data = ([0, [255] * (4*5)] * 10)
45
+ data = data.flatten.map(&:chr).join
56
46
  data = Zlib::Deflate.deflate(data)
57
47
 
58
48
  PNG.read_IDAT data, 8, PNG::RGBA, canvas
@@ -61,13 +51,13 @@ jwUwDGVBALuJxzlQugpEAAAAAElFTkSuQmCC
61
51
  end
62
52
 
63
53
  def test_class_read_IHDR
64
- bit_depth, color_type, width, height = PNG.read_IHDR @IHDR_data
54
+ _, _, width, height = PNG.read_IHDR @IHDR_data
65
55
  assert_equal 10, width
66
56
  assert_equal 10, height
67
57
  end
68
58
 
69
59
  def test_class_load_metadata
70
- png, canvas = util_png
60
+ png, _ = util_png
71
61
 
72
62
  width, height, bit_depth = PNG.load(png.to_blob, :metadata)
73
63
 
data.tar.gz.sig CHANGED
Binary file