Sha256: 199f4627df2eccf36cf3b4b4b1fe00b7f7c07a0fa808a8d71334b43b8b03819c

Contents?: true

Size: 1.78 KB

Versions: 3

Compression:

Stored size: 1.78 KB

Contents

require File.dirname(__FILE__) + "/../test_helper"

class ConstantsTest < Test::Unit::TestCase

	should "have constantized methods for Vector3" do
		{	
			:ZERO => [0, 0, 0],
			:UNIT_X => [1, 0, 0],
			:UNIT_Y => [0, 1, 0],
			:UNIT_Z => [0, 0, 1],
			:NEGATIVE_UNIT_X => [-1, 0, 0],
			:NEGATIVE_UNIT_Y => [0, -1, 0],
			:NEGATIVE_UNIT_Z => [0, 0, -1],
			:UNIT_SCALE => [1, 1, 1]
		}.each do |method, expected|
			vec = Vector3.send(method)
			assert_equal expected, [vec.x, vec.y, vec.z]

			# And test that we don't destroy the initial data like
			# Ruby constants like to do
			vec.x = 10
			vec.y = 20
			vec.z = 30
			vec2 = Vector3.send(method)
			assert_not_equal [vec2.x, vec2.y, vec2.z], [vec.x, vec.y, vec.z]
		end
	end

	should "have constantized methods for Vector4" do
		{	
			:ZERO => [0, 0, 0, 0],
		}.each do |method, expected|
			vec = Vector4.send(method)
			assert_equal expected, [vec.x, vec.y, vec.z, vec.w]

			# And test that we don't destroy the initial data like
			# Ruby constants like to do
			vec.x = 10
			vec.y = 20
			vec.z = 30
			vec.w = 40
			vec2 = Vector4.send(method)
			assert_not_equal [vec2.x, vec2.y, vec2.z, vec2.w], [vec.x, vec.y, vec.z, vec.w]
		end
	end

	should "have constantized methods for Quanternion" do
		{	
			:ZERO => [0.0, 0.0, 0.0, 0.0],
			:IDENTITY => [1.0, 0.0, 0.0, 0.0]
		}.each do |method, expected|
			quat = Quaternion.send(method)
			assert_equal expected, [quat.w, quat.x, quat.y, quat.z]

			# And test that we don't destroy the initial data like
			# Ruby constants like to do
			quat.x = 10
			quat.y = 20
			quat.z = 30
			quat.w = 40
			quat2 = Quaternion.send(method)
			assert_not_equal [quat2.x, quat2.y, quat2.z, quat2.w], [quat.x, quat.y, quat.z, quat.w]
		end
	end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ogre.rb-0.2-i686-linux test/unit/constants_test.rb
ogre.rb-0.2-i386-mswin32 test/unit/constants_test.rb
ogre.rb-0.2-x86_64-linux test/unit/constants_test.rb