Sha256: 3d570ea95b2eddcf7623613664557adf0bed3d32f184043d8cd75189f593c304

Contents?: true

Size: 1.65 KB

Versions: 37

Compression:

Stored size: 1.65 KB

Contents

# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__)) + '/helper'

class TestKeyframe < Test::Unit::TestCase
  def test_supports_block_init
    keyframe = Tracksperanto::Keyframe.new do |k| 
      k.frame = 0
      k.abs_x = 10.3
      k.abs_y = 12.5
    end
    
    assert_equal 0, keyframe.frame
    assert_equal 10.3, keyframe.abs_x
    assert_equal 12.5, keyframe.abs_y
  end
  
  def test_sorts_on_frame
    kf = Tracksperanto::Keyframe.new(:frame => 4, :abs_x => 10, :abs_y => 12.0)
    kf2 = Tracksperanto::Keyframe.new(:frame => 2, :abs_x => 10, :abs_y => 12.0)
    assert_equal [kf2, kf], [kf, kf2].sort
  end
  
  def test_compares_equally_with_same_values
    kf = Tracksperanto::Keyframe.new(:frame => 2, :abs_x => 10, :abs_y => 12.0)
    kf2 = Tracksperanto::Keyframe.new(:frame => 2, :abs_x => 10, :abs_y => 12.0)
    assert_equal kf, kf2
  end
  
  def test_dup
    kf = Tracksperanto::Keyframe.new(:frame => 2, :abs_x => 10, :abs_y => 12.0)
    kf2 = kf.dup
    kf2.frame = 15
    assert_not_equal kf, kf2
  end
  
  def test_inspect
    kf = Tracksperanto::Keyframe.new(:frame => 0, :abs_x => 10, :abs_y => 12.0)
    assert_equal "#< 10.0x12.0 @0 ~0.00) >", kf.inspect
  end
  
  def test_frame_translated_to_int
    kf = Tracksperanto::Keyframe.new {|k|  k.frame = '0' }
    assert_equal 0, kf.frame
  end
  
  def test_residual_defaults_to_zero
    kf = Tracksperanto::Keyframe.new
    assert_in_delta 0.0, kf.residual, 0.01
  end

  def test_abs_x_abs_y_translated_to_float
    kf = Tracksperanto::Keyframe.new {|k|  k.abs_x = '123.45678'; k.abs_y = '321.45678' }
    assert_kind_of Float, kf.abs_x
    assert_kind_of Float, kf.abs_y
  end

end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
tracksperanto-3.5.9 test/test_keyframe.rb
tracksperanto-3.5.8 test/test_keyframe.rb
tracksperanto-3.5.7 test/test_keyframe.rb
tracksperanto-3.5.6 test/test_keyframe.rb
tracksperanto-3.5.5 test/test_keyframe.rb
tracksperanto-3.5.4 test/test_keyframe.rb
tracksperanto-3.5.2 test/test_keyframe.rb
tracksperanto-3.5.1 test/test_keyframe.rb
tracksperanto-3.5.0 test/test_keyframe.rb
tracksperanto-3.4.1 test/test_keyframe.rb
tracksperanto-3.4.0 test/test_keyframe.rb
tracksperanto-3.3.13 test/test_keyframe.rb
tracksperanto-3.3.12 test/test_keyframe.rb
tracksperanto-3.3.11 test/test_keyframe.rb
tracksperanto-3.3.10 test/test_keyframe.rb
tracksperanto-3.3.9 test/test_keyframe.rb
tracksperanto-3.3.8 test/test_keyframe.rb
tracksperanto-3.3.7 test/test_keyframe.rb
tracksperanto-3.3.6 test/test_keyframe.rb
tracksperanto-3.3.0.pre test/test_keyframe.rb