1require 'caca'
2
3class TC_Canvas < Test::Unit::TestCase
4    def test_create
5	assert_nothing_raised {
6            d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0)
7	}
8    end
9    def test_fail_create
10	assert_raise(RuntimeError) {
11            d = Caca::Dither.new(-1, 32, 32, 32, 0, 0, 0, 0)
12	}
13    end
14    def test_set_palette
15	assert_nothing_raised {
16            d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0)
17            d.palette=[[0xfff, 0xfff, 0xfff, 0xfff]]*256
18	}
19    end
20    def test_fail_set_palette
21	assert_raise(ArgumentError) {
22            d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0)
23            d.palette=[]
24	}
25    end
26    def test_fail_set_palette2
27	assert_raise(RuntimeError) {
28            d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0)
29            d.palette=[[0xffff, 0, 0, 0]]*256
30	}
31    end
32    def test_set_brightness
33        assert_nothing_raised {
34            d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0)
35            d.brightness=0.5
36        }
37    end
38    def test_set_gamma
39        assert_nothing_raised {
40            d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0)
41            d.gamma=0.5
42        }
43    end
44    def test_set_contrast
45        assert_nothing_raised {
46            d = Caca::Dither.new(8, 32, 32, 32, 0, 0, 0, 0)
47            d.contrast=0.5
48        }
49    end
50end
51