Sha256: 284b88fa18a0001c23f1207cf3ea20480ce9ba2c0a8cc420d6fdbb420fdfe0d7

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

require 'test/unit'
$:.unshift(File.expand_path('../../lib',__FILE__))
require 'graphviz/types'

class TypesTest < Test::Unit::TestCase
  def test_gv_bool
    bool = nil

    assert_block "Create true GvBool failed." do
      bool = GraphViz::Types::GvBool.new(true)
    end
    assert bool
    assert_equal true, bool.to_ruby

    assert_block "Create \"true\" GvBool failed." do
      bool = GraphViz::Types::GvBool.new("true")
    end
    assert bool
    assert_equal true, bool.to_ruby

    assert_block "Create \"Yes\" GvBool failed." do
      bool = GraphViz::Types::GvBool.new("Yes")
    end
    assert bool
    assert_equal true, bool.to_ruby

    assert_block "Create 1 GvBool failed." do
      bool = GraphViz::Types::GvBool.new(1)
    end
    assert bool
    assert_equal true, bool.to_ruby

    assert_block "Create false GvBool failed." do
      bool = GraphViz::Types::GvBool.new(false)
    end
    assert bool
    assert_equal false, bool.to_ruby

    assert_block "Create \"false\" GvBool failed." do
      bool = GraphViz::Types::GvBool.new("false")
    end
    assert bool
    assert_equal false, bool.to_ruby

    assert_block "Create \"NO\" GvBool failed." do
      bool = GraphViz::Types::GvBool.new("NO")
    end
    assert bool
    assert_equal false, bool.to_ruby

    assert_block "Create 0 GvBool failed." do
      bool = GraphViz::Types::GvBool.new(0)
    end
    assert bool
    assert_equal false, bool.to_ruby

    assert_raise BoolException, "Wrong bool value" do
       GraphViz::Types::GvBool.new("toto")
    end

    assert_raise BoolException, "Wrong bool value" do
       GraphViz::Types::GvBool.new("")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-graphviz-1.0.3 test/test_types.rb
ruby-graphviz-1.0.2 test/test_types.rb
ruby-graphviz-1.0.1 test/test_types.rb