require 'test/unit' require 'plist' class TestGeneratorCollections < Test::Unit::TestCase def test_array expected = < 1 2 3 END assert_equal expected, [1,2,3].to_plist(false) end def test_empty_array expected = < END assert_equal expected, [].to_plist(false) end def test_hash expected = < abc 123 foo bar END # thanks to recent changes in the generator code, hash keys are sorted before emission, # so multi-element hash tests should be reliable. We're testing that here too. assert_equal expected, {:foo => :bar, :abc => 123}.to_plist(false) end def test_empty_hash expected = < END assert_equal expected, {}.to_plist(false) end def test_hash_with_array_element expected = < ary 1 b 3 END assert_equal expected, {:ary => [1,:b,'3']}.to_plist(false) end def test_array_with_hash_element expected = < foo bar b 3 END assert_equal expected, [{:foo => 'bar'}, :b, 3].to_plist(false) end end