class TestEnum

Public Instance Methods

test_enum_by_string() click to toggle source
# File glib2/test/test_enum.rb, line 18
def test_enum_by_string
  original = [0x00c1].pack("U*") # A with acute

  assert_equal(GLib::UTF8.normalize(original, GLib::NormalizeMode::NFD),
               GLib::UTF8.normalize(original, "nfd"))
  assert_equal(GLib::UTF8.normalize(original, GLib::NormalizeMode::NFD),
               GLib::UTF8.normalize(original, "NFD"))

  assert_raise(TypeError) do
    GLib::UTF8.normalize(original, "unknown")
  end
end
test_enum_by_symbol() click to toggle source
# File glib2/test/test_enum.rb, line 5
def test_enum_by_symbol
  original = [0x00c1].pack("U*") # A with acute

  assert_equal(GLib::UTF8.normalize(original, GLib::NormalizeMode::NFD),
               GLib::UTF8.normalize(original, :nfd))
  assert_equal(GLib::UTF8.normalize(original, GLib::NormalizeMode::NFD),
               GLib::UTF8.normalize(original, :NFD))

  assert_raise(TypeError) do
    GLib::UTF8.normalize(original, :unknown)
  end
end
test_flags_by_array() click to toggle source
# File glib2/test/test_enum.rb, line 47
def test_flags_by_array
  assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS |
                       GLib::KeyFile::KEEP_TRANSLATIONS,
                       [:keep_comments, :keep_translations])
  assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS |
                       GLib::KeyFile::KEEP_TRANSLATIONS,
                       [:keep_COMMENTS, "KEEP_TRANSLATIONS"])
  assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS |
                       GLib::KeyFile::KEEP_TRANSLATIONS,
                       ["keep_comments", "KEEP_translations"])
  assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS |
                       GLib::KeyFile::KEEP_TRANSLATIONS,
                       [:keep_comments, GLib::KeyFile::KEEP_TRANSLATIONS])

  assert_raise(TypeError) do
    assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS |
                         GLib::KeyFile::KEEP_TRANSLATIONS,
                         [:keep_comments, nil, :keep_translations])
  end
end
test_flags_or() click to toggle source
# File glib2/test/test_enum.rb, line 68
def test_flags_or
  assert_equal(GLib::KeyFile::KEEP_COMMENTS,
               GLib::KeyFile::KEEP_COMMENTS | [])
  assert_equal(GLib::KeyFile::KEEP_COMMENTS |
               GLib::KeyFile::KEEP_TRANSLATIONS ,
               GLib::KeyFile::KEEP_COMMENTS | [:keep_translations])
end
test_flags_simple() click to toggle source
# File glib2/test/test_enum.rb, line 31
def test_flags_simple
  assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS, :keep_comments)
  assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS, :KEEP_COMMENTS)
  assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS, "keep_comments")
  assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS, "KEEP_COMMENTS")
  assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS, "keep COMMENTS")

  assert_raise(TypeError) do
    assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS, :unknown)
  end

  assert_raise(TypeError) do
    assert_key_file_load(GLib::KeyFile::KEEP_COMMENTS, "UNKNOWN")
  end
end