Sha256: 1e18ec4319f73c6b0b6f10dff338a2ed32634b6a0852843e79489c7e112beced

Contents?: true

Size: 1.02 KB

Versions: 13

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

13 entries across 13 versions & 1 rubygems

Version Path
rays-0.1.34 test/test_bitmap.rb
rays-0.1.33 test/test_bitmap.rb
rays-0.1.32 test/test_bitmap.rb
rays-0.1.31 test/test_bitmap.rb
rays-0.1.30 test/test_bitmap.rb
rays-0.1.29 test/test_bitmap.rb
rays-0.1.28 test/test_bitmap.rb
rays-0.1.27 test/test_bitmap.rb
rays-0.1.26 test/test_bitmap.rb
rays-0.1.25 test/test_bitmap.rb
rays-0.1.24 test/test_bitmap.rb
rays-0.1.23 test/test_bitmap.rb
rays-0.1.22 test/test_bitmap.rb