Class/Module Index [+]

Quicksearch

TestStructure

Public Instance Methods

test_accessor() click to toggle source
# File gstreamer/test/test_structure.rb, line 23
def test_accessor
  structure = Gst::Structure.new("anonymous")

  structure["string"] = "value"
  structure["integer"] = 1

  assert_nil(structure["non-existence"])
  assert_equal("value", structure["string"])
  assert_equal(1, structure["integer"])
end
test_clear() click to toggle source
# File gstreamer/test/test_structure.rb, line 46
def test_clear
  structure = Gst::Structure.new("anonymous")

  structure["string"] = "value"
  structure["integer"] = 1

  assert_equal("value", structure["string"])
  assert_equal(1, structure["integer"])
  structure.clear
  assert_nil(structure["string"])
  assert_nil(structure["integer"])
end
test_collect() click to toggle source
# File gstreamer/test/test_structure.rb, line 73
def test_collect
  structure = Gst::Structure.new("anonymous")
  assert_equal([], structure.collect {|key, value| [key, value]})

  structure["string"] = "value"
  structure["integer"] = 1
  assert_equal([
                ["string", "value" * 2],
                ["integer", 1 * 2],
               ],
               structure.collect {|key, value| [key, value * 2]})

  assert_equal("value", structure["string"])
  assert_equal(1, structure["integer"])
end
test_collect!() click to toggle source
# File gstreamer/test/test_structure.rb, line 89
def test_collect!
  structure = Gst::Structure.new("anonymous")
  assert_equal([], structure.collect {|key, value| [key, value]})

  structure["string"] = "value"
  structure["integer"] = 1
  structure.collect! {|key, value| value * 2}

  assert_equal("value" * 2, structure["string"])
  assert_equal(1 * 2, structure["integer"])
end
test_delete() click to toggle source
# File gstreamer/test/test_structure.rb, line 34
def test_delete
  structure = Gst::Structure.new("anonymous")

  structure["string"] = "value"
  structure["integer"] = 1

  assert_equal("value", structure["string"])
  structure.delete("string")
  assert_nil(structure["string"])
  assert_equal(1, structure["integer"])
end
test_each_break() click to toggle source
# File gstreamer/test/test_structure.rb, line 59
def test_each_break
  structure = Gst::Structure.new("anonymous")

  structure["string"] = "value"
  structure["integer"] = 1

  result = []
  structure.each do |key, value|
    result << [key, value]
    break
  end
  assert_equal([["string", "value"]], result)
end
test_empty_new() click to toggle source
# File gstreamer/test/test_structure.rb, line 2
def test_empty_new
  assert_raise(ArgumentError) do
    Gst::Structure.new
  end
end
test_have_field?() click to toggle source
# File gstreamer/test/test_structure.rb, line 122
def test_have_field?
  structure = Gst::Structure.new("anonymous")

  assert(!structure.have_field?("string"))

  structure["string"] = "value"
  assert(structure.have_field?("string"))
  assert(!structure.have_field?("integer"))
end
test_name() click to toggle source
# File gstreamer/test/test_structure.rb, line 13
def test_name
  structure = Gst::Structure.new("anonymous")
  assert(structure.have_name?("anonymous"))

  assert(!structure.have_name?("me"))
  structure.name = "me"
  assert(structure.have_name?("me"))
  assert(!structure.have_name?("anonymous"))
end
test_new_with_name() click to toggle source
# File gstreamer/test/test_structure.rb, line 8
def test_new_with_name
  structure = Gst::Structure.new("anonymous")
  assert_equal("anonymous", structure.name)
end
test_nth_field_name() click to toggle source
# File gstreamer/test/test_structure.rb, line 113
def test_nth_field_name
  structure = Gst::Structure.new("anonymous")

  structure["string"] = "value"
  structure["integer"] = 1
  assert_equal("string", structure.nth_field_name(0))
  assert_equal("integer", structure.nth_field_name(1))
end
test_parse() click to toggle source
# File gstreamer/test/test_structure.rb, line 146
def test_parse
  structure = Gst::Structure.new("anonymous")
  structure["string"] = "value"
  structure["integer"] = 1

  parsed_structure, rest = Gst::Structure.parse(structure.to_s)
  assert_equal(["anonymous, string=(string)value, integer=(int)1;", ""],
               [parsed_structure.to_s, rest])

  parsed_structure, rest = Gst::Structure.parse(structure.to_s + "XXX")
  assert_equal(["anonymous, string=(string)value, integer=(int)1;", "XXX"],
               [parsed_structure.to_s, rest])
end
test_size() click to toggle source
# File gstreamer/test/test_structure.rb, line 101
def test_size
  structure = Gst::Structure.new("anonymous")

  assert_equal(0, structure.size)
  assert(structure.empty?)

  structure["string"] = "value"
  structure["integer"] = 1
  assert_equal(2, structure.size)
  assert(!structure.empty?)
end
test_to_s() click to toggle source
# File gstreamer/test/test_structure.rb, line 132
def test_to_s
  structure = Gst::Structure.new("anonymous")
  assert_equal("anonymous;", structure.to_s)

  structure["string"] = "value"
  assert_equal("anonymous, string=(string)value;", structure.to_s)

  structure["integer"] = 1
  assert_equal("anonymous, string=(string)value, integer=(int)1;",
               structure.to_s)

  assert_match(/: #{Regexp.escape(structure.to_s)}>\z/, structure.inspect)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.