Sha256: 701ec91732f6cc9093541b69f346aaf4706e9aeabc54b135a67211df9f8af27b
Contents?: true
Size: 1.02 KB
Versions: 9
Compression:
Stored size: 1.02 KB
Contents
# -*- coding: utf-8 -*- require_relative 'helper' class TestBitmap < Test::Unit::TestCase W = 32 H = 16 def bitmap (w = W, h = H) Rays::Bitmap.new w, h end def color (*args) Rays::Color.new *args end def test_initialize () assert_equal W, bitmap.width assert_equal H, bitmap.height end def test_dup () o = bitmap assert_equal color(0, 0, 0, 0), o[0, 0] o[0, 0] = color(1, 0, 0, 0) assert_equal color(1, 0, 0, 0), o[0, 0] x = o.dup assert_equal color(1, 0, 0, 0), x[0, 0] x[0, 0] = color(0, 1, 0, 0) assert_equal color(0, 1, 0, 0), x[0, 0] assert_equal color(1, 0, 0, 0), o[0, 0] end def test_at () o = bitmap assert_equal color(0, 0, 0, 0), o[0, 0] o[0, 0] = 1 assert_equal color(1, 1, 1, 1), o[0, 0] end def test_to_a () colors = %w[#f00 #0f0 #00f #ff0].map {|s| color s} bmp = bitmap 2, 2 bmp[0, 0], bmp[1, 0], bmp[0, 1], bmp[1, 1] = colors assert_equal colors, bmp.to_a end end# TestBitmap
Version data entries
9 entries across 9 versions & 1 rubygems