[Quiz] Support C++ cases

This commit is contained in:
Romain Goyet
2015-09-03 23:51:47 +02:00
parent 2bb2a2af28
commit 107dd016d0
5 changed files with 12 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
#include <quiz.h>
#include <kandinsky.h>
TEST(setpixel) {
QUIZ_CASE(setpixel) {
2+2;
}

View File

@@ -1,6 +1,6 @@
#include <quiz.h>
#include <poincare.h>
TEST(integer) {
QUIZ_CASE(integer) {
1+1;
}

View File

@@ -1,4 +1,5 @@
SFLAGS += -Iquiz/include
objs += $(addprefix quiz/src/, runner.o symbols.o)
symbols_file = $(addprefix quiz/src/, symbols.c)
products += $(symbols_file)
@@ -9,4 +10,6 @@ $(symbols_file): $(tests)
test_objs = $(subst .c,.o, $(subst .cpp,.o,$(tests)))
test.elf: quiz/src/symbols.o quiz/src/runner.o $(test_objs)
test.elf: $(objs) $(test_objs)
@echo "LD $@"
@$(LD) $(LDFLAGS) $(objs) $(test_objs) -o $@

View File

@@ -1,6 +1,10 @@
#ifndef QUIZ_H
#define QUIZ_H
#define TEST(foo) void test_##foo()
#ifdef __cplusplus
#define QUIZ_CASE(name) extern "C" { void quiz_case_##name();}; void quiz_case_##name()
#else
#define QUIZ_CASE(name) void quiz_case_##name()
#endif
#endif

View File

@@ -6,7 +6,7 @@ BEGIN {
#FIXME: Is there a way to capture subexpression in awk? The following gsub is
# kind of ugly
/TEST\(([a-z0-9_]+)\)/ { gsub(/(TEST\()|(\))/, "", $1); tests = tests "," $1 }
/QUIZ_CASE\(([a-z0-9_]+)\)/ { gsub(/(QUIZ_CASE\()|(\))/, "", $1); tests = tests ",quiz_case_" $1 }
END {
a = tests;