Skip to content

Commit

Permalink
Added function signature tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfjlaros committed Dec 19, 2018
1 parent 6152405 commit ffc6de4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
EXEC := tests
MAIN := test_lib
TESTS := test_types test_print
TESTS := test_types test_print test_tuple
FIXTURES := Arduino


CC := g++
INCLUDE_PATH := .
CC_ARGS := -Wno-pmf-conversions


OBJS := $(addsuffix .o, $(TESTS) $(FIXTURES))
Expand All @@ -16,10 +17,10 @@ OBJS := $(addsuffix .o, $(TESTS) $(FIXTURES))
all: $(EXEC)

$(EXEC): $(OBJS)
$(CC) -I $(INCLUDE_PATH) -o $@ $(MAIN).cc $^
$(CC) -o $@ $(MAIN).cc $^

%.o: %.cc
$(CC) -I $(INCLUDE_PATH) -c $<
$(CC) $(CC_ARGS) -I $(INCLUDE_PATH) -c $<

clean:
rm -f $(OBJS)
Expand Down
16 changes: 16 additions & 0 deletions tests/test_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,19 @@ TEST_CASE("Compound types", "[types]") {
REQUIRE(_typeof(iscul) == "<ib<L");
REQUIRE(_typeof(iiP) == "<i<i*");
}

TEST_CASE("Function pointer types", "[types]") {
class C {
public:
short int f(char, float) {}
void g(char, float) {}
};

short int (*f)(char, float);
void (*g)(char, float);

REQUIRE(signature(f) == "<h: c <f");
REQUIRE(signature(g) == ": c <f");
REQUIRE(signature(&C::f) == "<h: c <f");
REQUIRE(signature(&C::g) == ": c <f");
}

0 comments on commit ffc6de4

Please sign in to comment.