blob: e912f72f538ba5e91ed0245b6348adee28ae834f [file] [log] [blame]
Charles Giardina18088882018-09-11 15:58:42 -07001#
2# Licensed to the Apache Software Foundation (ASF) under one
3# or more contributor license agreements. See the NOTICE file
4# distributed with this work for additional information
5# regarding copyright ownership. The ASF licenses this file
6# to you under the Apache License, Version 2.0 (the
7# "License"); you may not use this file except in compliance
8# with the License. You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing,
13# software distributed under the License is distributed on an
14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15# KIND, either express or implied. See the License for the
16# specific language governing permissions and limitations
17# under the License.
18#
19
20require File.join(File.dirname(__FILE__), '../test_helper')
21require 'recursive_types'
22
23class TestRecursiveGeneration < Test::Unit::TestCase
24 CHILD_ITEM = "child item"
25 PARENT_ITEM = "parent item"
26
27 def test_can_create_recursive_tree
28
29 child_tree = RecTree.new
30 child_tree.item = CHILD_ITEM
31
32 parent_tree = RecTree.new
33 parent_tree.item = PARENT_ITEM
34 parent_tree.children = [child_tree]
35
36 assert_equal(PARENT_ITEM, parent_tree.item)
37 assert_equal(1, parent_tree.children.length)
38 assert_equal(CHILD_ITEM, parent_tree.children.first.item)
39 assert_nil(parent_tree.children.first.children)
40 end
41end