Class: TestGeneratorCollections

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/puppet/vendor/plist/test/test_generator_collections.rb

Instance Method Summary collapse

Instance Method Details

#test_arrayObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/puppet/vendor/plist/test/test_generator_collections.rb', line 12

def test_array
  expected = "<array>\n  <integer>1</integer>\n  <integer>2</integer>\n  <integer>3</integer>\n</array>\n"

  assert_equal expected, [1,2,3].to_plist(false)
end

#test_array_with_hash_elementObject



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/puppet/vendor/plist/test/test_generator_collections.rb', line 68

def test_array_with_hash_element
  expected = "<array>\n  <dict>\n<key>foo</key>\n<string>bar</string>\n  </dict>\n  <string>b</string>\n  <integer>3</integer>\n</array>\n"

  assert_equal expected, [{:foo => 'bar'}, :b, 3].to_plist(false)
end

#test_empty_arrayObject



24
25
26
27
28
29
30
# File 'lib/puppet/vendor/plist/test/test_generator_collections.rb', line 24

def test_empty_array
  expected = "<array/>\n"

  assert_equal expected, [].to_plist(false)
end

#test_empty_hashObject



46
47
48
49
50
51
52
# File 'lib/puppet/vendor/plist/test/test_generator_collections.rb', line 46

def test_empty_hash
  expected = "<dict/>\n"

  assert_equal expected, {}.to_plist(false)
end

#test_hashObject



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/puppet/vendor/plist/test/test_generator_collections.rb', line 32

def test_hash
  expected = "<dict>\n  <key>abc</key>\n  <integer>123</integer>\n  <key>foo</key>\n  <string>bar</string>\n</dict>\n"
  # 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

#test_hash_with_array_elementObject



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/puppet/vendor/plist/test/test_generator_collections.rb', line 54

def test_hash_with_array_element
  expected = "<dict>\n  <key>ary</key>\n  <array>\n<integer>1</integer>\n<string>b</string>\n<string>3</string>\n  </array>\n</dict>\n"
  assert_equal expected, {:ary => [1,:b,'3']}.to_plist(false)
end