active_assets 0.2.3 → 0.2.4

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,82 +0,0 @@
1
- require 'helper'
2
- require 'fileutils'
3
-
4
- class Pixmap
5
- def ==(a_bitmap)
6
- return false if @width != a_bitmap.width or @height != a_bitmap.height
7
- @width.times do |x|
8
- @height.times do |y|
9
- return false if not self[x,y] == (a_bitmap[x,y])
10
- end
11
- end
12
- true
13
- end
14
- end
15
-
16
- class RGBColourTest < Test::Unit::TestCase
17
- def test_init
18
- color = RGBColour.new(0,100,200)
19
- assert_equal(100, color.g)
20
- end
21
- def test_constants
22
- assert_equal([255,0,0], [RGBColour::RED.r,RGBColour::RED.g,RGBColour::RED.b])
23
- assert_equal([0,255,0], [RGBColour::GREEN.r,RGBColour::GREEN.g,RGBColour::GREEN.b])
24
- assert_equal([0,0,255], [RGBColour::BLUE.r,RGBColour::BLUE.g,RGBColour::BLUE.b])
25
- end
26
- def test_error
27
- color = RGBColour.new(0,100,200)
28
- assert_raise(ArgumentError) {RGBColour.new(0,0,256)}
29
- end
30
- end
31
-
32
- class PixmapTest < Test::Unit::TestCase
33
- def setup
34
- @w = 20
35
- @h = 30
36
- @bitmap = Pixmap.new(@w,@h)
37
- end
38
-
39
- def teardown
40
- Dir[File.expand_path('../fixtures/*.ppm', __FILE__)].each do |f|
41
- FileUtils.rm(f)
42
- end
43
- end
44
-
45
- def test_init
46
- assert_equal(@w, @bitmap.width)
47
- assert_equal(@h, @bitmap.height)
48
- assert_equal(RGBColour::WHITE, @bitmap.get_pixel(10,10))
49
- end
50
- def test_fill
51
- @bitmap.fill(RGBColour::RED)
52
- assert_equal(255,@bitmap[10,10].red)
53
- assert_equal(0,@bitmap[10,10].green)
54
- assert_equal(0,@bitmap[10,10].blue)
55
- end
56
- def test_get_pixel
57
- assert_equal(@bitmap[5,6], @bitmap.get_pixel(5,6))
58
- assert_raise(ArgumentError) {@bitmap[100,100]}
59
- end
60
- def test_grayscale
61
- @bitmap.fill(RGBColour::BLUE)
62
- @bitmap.height.times {|y| [9,10,11].each {|x| @bitmap[x,y]=RGBColour::GREEN}}
63
- @bitmap.width.times {|x| [14,15,16].each {|y| @bitmap[x,y]=RGBColour::GREEN}}
64
- @bitmap.save(File.expand_path('../fixtures/testcross.ppm', __FILE__))
65
- Pixmap.open(File.expand_path('../fixtures/testcross.ppm', __FILE__)).to_grayscale.save(File.expand_path('../fixtures/testgray.ppm', __FILE__))
66
- end
67
- def test_save
68
- @bitmap.fill(RGBColour::BLUE)
69
- filename = File.expand_path('../fixtures/test.ppm', __FILE__)
70
- @bitmap.save(filename)
71
- expected_size = 3 + (@w.to_s.length + 1 + @h.to_s.length + 1) + 4 + (@w * @h * 3)
72
- assert_equal(expected_size, File.size(filename))
73
- end
74
- def test_open
75
- @bitmap.fill(RGBColour::RED)
76
- @bitmap.set_pixel(10,15, RGBColour::WHITE)
77
- filename = File.expand_path('../fixtures/test.ppm', __FILE__)
78
- @bitmap.save(filename)
79
- new = Pixmap.open(filename)
80
- assert(@bitmap == new)
81
- end
82
- end