OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 { | 188 { |
189 TrioWithGrandChild trio; | 189 TrioWithGrandChild trio; |
190 trio.appendChildren(); | 190 trio.appendChildren(); |
191 | 191 |
192 TestTree* order[] = { | 192 TestTree* order[] = { |
193 trio.root.get(), trio.firstChild.get(), trio.middleChild.get(), | 193 trio.root.get(), trio.firstChild.get(), trio.middleChild.get(), |
194 trio.grandChild.get(), trio.lastChild.get() | 194 trio.grandChild.get(), trio.lastChild.get() |
195 }; | 195 }; |
196 | 196 |
197 unsigned orderIndex = 0; | 197 unsigned orderIndex = 0; |
198 for (TestTree* node = trio.root.get(); node; node = traverseNext(*node), ord
erIndex++) | 198 for (TestTree* node = trio.root.get(); node; node = traverseNext<TestTree>(*
node), orderIndex++) |
199 ASSERT_EQ(node, order[orderIndex]); | 199 ASSERT_EQ(node, order[orderIndex]); |
200 ASSERT_EQ(orderIndex, sizeof(order) / sizeof(TestTree*)); | 200 ASSERT_EQ(orderIndex, sizeof(order) / sizeof(TestTree*)); |
201 } | 201 } |
202 | 202 |
203 TEST(WTF, TreeNodeTraverseNextPostORder) | 203 TEST(WTF, TreeNodeTraverseNextPostORder) |
204 { | 204 { |
205 TrioWithGrandChild trio; | 205 TrioWithGrandChild trio; |
206 trio.appendChildren(); | 206 trio.appendChildren(); |
207 | 207 |
208 | 208 |
209 TestTree* order[] = { | 209 TestTree* order[] = { |
210 trio.firstChild.get(), | 210 trio.firstChild.get(), |
211 trio.grandChild.get(), trio.middleChild.get(), trio.lastChild.get(), tri
o.root.get() | 211 trio.grandChild.get(), trio.middleChild.get(), trio.lastChild.get(), tri
o.root.get() |
212 }; | 212 }; |
213 | 213 |
214 unsigned orderIndex = 0; | 214 unsigned orderIndex = 0; |
215 for (TestTree* node = traverseFirstPostOrder(*trio.root.get()); node; node =
traverseNextPostOrder(*node), orderIndex++) | 215 for (TestTree* node = traverseFirstPostOrder<TestTree>(*trio.root.get()); no
de; node = traverseNextPostOrder<TestTree>(*node), orderIndex++) |
216 ASSERT_EQ(node, order[orderIndex]); | 216 ASSERT_EQ(node, order[orderIndex]); |
217 ASSERT_EQ(orderIndex, sizeof(order) / sizeof(TestTree*)); | 217 ASSERT_EQ(orderIndex, sizeof(order) / sizeof(TestTree*)); |
218 | 218 |
219 } | 219 } |
220 | 220 |
221 | 221 |
222 } // namespace | 222 } // namespace |
OLD | NEW |