Sha256: f8ffcbe8a828e2b7246209153a12386346a2d89054de8110570296eee4a0613d

Contents?: true

Size: 1.88 KB

Versions: 4

Compression:

Stored size: 1.88 KB

Contents

##############################################################################
# tc_time.rb
#
# Test case for the DBI::Time class (currently) located in the utils.rb file.
##############################################################################
require "test/unit"
require_relative "../../lib/dbi"

Deprecate.set_action(proc { })

class TC_DBI_Time < Test::Unit::TestCase
   def setup
      @time     = Time.new
      @dbi_time = DBI::Time.new
   end

   def test_constructor
      assert_nothing_raised{ DBI::Time.new(9) }
      assert_nothing_raised{ DBI::Time.new(9, 41) }
      assert_nothing_raised{ DBI::Time.new(9, 41, 20) }
      assert_nothing_raised{ DBI::Time.new(Date.new) }
      assert_nothing_raised{ DBI::Time.new(Time.now) }
   end

   def test_hour
      assert_respond_to(@dbi_time, :hour)
      assert_respond_to(@dbi_time, :hour=)
      assert_equal(0, @dbi_time.hour)
   end

   def test_minute
      assert_respond_to(@dbi_time, :minute)
      assert_respond_to(@dbi_time, :minute=)
      assert_equal(0, @dbi_time.minute)
   end

   # Alias for minute
   def test_min
      assert_respond_to(@dbi_time, :min)
      assert_respond_to(@dbi_time, :min=)
      assert_equal(0, @dbi_time.min)
   end

   def test_second
      assert_respond_to(@dbi_time, :second)
      assert_respond_to(@dbi_time, :second=)
      assert_equal(0, @dbi_time.second)
   end

   def test_sec
      assert_respond_to(@dbi_time, :sec)
      assert_respond_to(@dbi_time, :sec=)
      assert_equal(0, @dbi_time.sec)
   end

   def test_to_time
      assert_respond_to(@dbi_time, :to_time)
      assert_equal(@time, DBI::Time.new(@time).to_time)
      #assert_equal(@time.object_id, DBI::Time.new(@time).object_id) # Fails ??
   end

   def test_to_s
      assert_respond_to(@dbi_time, :to_s)
      assert_equal("00:00:00", @dbi_time.to_s)
   end

   def teardown
      @time     = nil
      @dbi_time = nil
   end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ydbi-0.6.0 test/dbi/tc_time.rb
ydbi-0.5.9 test/dbi/tc_time.rb
ydbi-0.5.8 test/dbi/tc_time.rb
ydbi-0.5.7 test/dbi/tc_time.rb