OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkRandom.h" | 8 #include "SkRandom.h" |
9 #include "SkTTopoSort.h" | 9 #include "SkTTopoSort.h" |
10 #include "Test.h" | 10 #include "Test.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } tests[] = { | 114 } tests[] = { |
115 { create_graph0, true }, | 115 { create_graph0, true }, |
116 { create_graph1, true }, | 116 { create_graph1, true }, |
117 { create_graph2, false }, | 117 { create_graph2, false }, |
118 { create_graph3, true }, | 118 { create_graph3, true }, |
119 { create_graph4, true }, | 119 { create_graph4, true }, |
120 }; | 120 }; |
121 | 121 |
122 for (size_t i = 0; i < SK_ARRAY_COUNT(tests); ++i) { | 122 for (size_t i = 0; i < SK_ARRAY_COUNT(tests); ++i) { |
123 SkTDArray<sk_tool_utils::TopoTestNode*> graph; | 123 SkTDArray<sk_tool_utils::TopoTestNode*> graph; |
124 | 124 |
125 (tests[i].fCreate)(&graph); | 125 (tests[i].fCreate)(&graph); |
126 | 126 |
127 sk_tool_utils::TopoTestNode::Shuffle(&graph, &rand); | 127 sk_tool_utils::TopoTestNode::Shuffle(&graph, &rand); |
128 | 128 |
129 bool actualResult = SkTTopoSort<sk_tool_utils::TopoTestNode>(&graph); | 129 bool actualResult = SkTTopoSort<sk_tool_utils::TopoTestNode>(&graph); |
130 REPORTER_ASSERT(reporter, actualResult == tests[i].fExpectedResult); | 130 REPORTER_ASSERT(reporter, actualResult == tests[i].fExpectedResult); |
131 | 131 |
132 if (tests[i].fExpectedResult) { | 132 if (tests[i].fExpectedResult) { |
133 for (int j = 0; j < graph.count(); ++j) { | 133 for (int j = 0; j < graph.count(); ++j) { |
134 REPORTER_ASSERT(reporter, graph[j]->check()); | 134 REPORTER_ASSERT(reporter, graph[j]->check()); |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 //SkDEBUGCODE(print(graph);) | 138 //SkDEBUGCODE(print(graph);) |
139 sk_tool_utils::TopoTestNode::DeallocNodes(&graph); | 139 sk_tool_utils::TopoTestNode::DeallocNodes(&graph); |
140 } | 140 } |
141 } | 141 } |
142 | |
OLD | NEW |