lib/take/unit/generator.rb in take-0.0.11 vs lib/take/unit/generator.rb in take-0.0.12
- old
+ new
@@ -52,58 +52,51 @@
@output << <<-CODE
// group #{group_name}
void group_#{group_name}()
{
-
- output(TEXT_COLOR_MAGENTA "\\tSET \\"" TEXT_COLOR_BOLD_MAGENTA
- "#{group_name}" TEXT_COLOR_MAGENTA "\\":\\n");
+ _uassert_group_start("#{group_name}");
CODE
@output << group.children.select(&:test?).
map { |child| " test_#{group_name(child)}();" }.
join("\n")
@output << "\n"
group.children.select(&:group?).
each { |child| @output << " group_#{group_name}_" \
"#{child.name}();\n" }
- @output << "}\n\n"
+ @output << " _uassert_group_stop();\n}\n\n"
@groups.pop
end
def walk_test(node)
@output << <<-CODE
void test_#{group_name(node)}()
{
- tests++;
- int test_skip = 0, test_success = 1;
- output(TEXT_COLOR_MAGENTA "\\t\\tTEST \\"" TEXT_COLOR_BOLD_MAGENTA
- "#{node.name}" TEXT_COLOR_MAGENTA "\\": ");
+ _uassert_test_start("#{node.name}");
CODE
befores.each { |child| walk(child) }
node.children.select(&:block?).each { |child| walk(child) }
afters.each { |child| walk(child) }
@output << <<-CODE
if(test_skip)
{
- output(TEXT_COLOR_BOLD_YELLOW "PASS\\n");
+ _uassert_test_skip();
}
else if(test_success)
{
-#ifdef VERBOSE
- output("\\n\\t\\t\\t" TEXT_COLOR_GREEN "OK\\n");
-#else
- output(TEXT_COLOR_BOLD_GREEN "OK\\n");
-#endif
+ _uassert_test_success();
}
else
{
- failed++;
+ _uassert_test_fail();
}
+
+ _uassert_test_end();
}
CODE
end
def walk_block(node, indent = 2)
@@ -130,23 +123,18 @@
node.children.select(&:prefix?).each { |child| walk(child) }
node.children.reject(&:prefix?).each { |child| walk(child) }
@output << <<-CODE
int main()
{
- output(TEXT_COLOR_MAGENTA "FILE \\"" TEXT_COLOR_BOLD_MAGENTA
- __FILE TEXT_COLOR_MAGENTA "\\":\\n");
+ _uassert_begin();
CODE
node.children.select(&:group?).
each { |child| @output << " group_#{child.name}();\n" }
@output << <<-CODE
- output2("\\n\\t" TEXT_COLOR_MAGENTA "RESULT:\\n\\t\\t"
- "PASSED: " TEXT_COLOR_BOLD_MAGENTA "%zu"
- TEXT_COLOR_MAGENTA "\\n\\t\\tFAILED: "
- TEXT_COLOR_BOLD_MAGENTA "%zu" TEXT_COLOR_MAGENTA
- "\\n", tests - failed, failed);
+ _uassert_stop();
return TEST_RETURN;
}
CODE