Sha256: af2625210c854426311e181e6362cbc718e6022ba207edc6ab607a8474b25a55

Contents?: true

Size: 1.25 KB

Versions: 4

Compression:

Stored size: 1.25 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__),'helper.rb'))


class TestFlags < Minitest::Test

  def test_flags
    f = Flt::Support::Flags(:flag_one, :flag_three)
    assert_equal "[:flag_one, :flag_three]",  f.to_a.sort_by{|flg| flg.to_s}.inspect
    f.values = Flt::Support::FlagValues(:flag_one, :flag_two, :flag_three)
    assert_equal "Flt::Support::Flags[flag_one, flag_three] (0x5)", f.inspect
    f[:flag_two] = true
    assert_equal "Flt::Support::Flags[flag_one, flag_two, flag_three] (0x7)", f.inspect
    f[:flag_one] = false
    assert_equal "Flt::Support::Flags[flag_two, flag_three] (0x6)", f.inspect
    f.clear!
    assert_equal "Flt::Support::Flags[] (0x0)", f.inspect
    f << [:flag_one,:flag_two]
    assert_equal "Flt::Support::Flags[flag_one, flag_two] (0x3)", f.inspect
    g = Flt::Support::Flags(f.values)
    g.bits = f.bits
    assert_equal "Flt::Support::Flags[flag_one, flag_two] (0x3)", g.inspect
    assert g==f
    g.set!
    assert_equal "Flt::Support::Flags[flag_one, flag_two, flag_three] (0x7)", g.inspect
    assert g!=f

    assert Flt::Support::Flags(:flag_one, :flag_three)==Flt::Support::Flags(:flag_three, :flag_one)
    assert Flt::Support::Flags(:flag_one, :flag_three)!=Flt::Support::Flags(:flag_one)



  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
flt-1.5.4 test/test_flags.rb
flt-1.5.3 test/test_flags.rb
flt-1.5.2 test/test_flags.rb
flt-1.5.1 test/test_flags.rb