Added a test case for #define/#undef/#ifdef/#ifndef/#else/#endif

This commit is contained in:
Pierre Pronchery 2013-06-04 03:30:32 +02:00
parent 1f0ec35d48
commit bd0fc7289a
6 changed files with 74 additions and 3 deletions

View File

@ -46,6 +46,7 @@ dist:
$(PACKAGE)-$(VERSION)/src/common.h \
$(PACKAGE)-$(VERSION)/src/parser.h \
$(PACKAGE)-$(VERSION)/src/project.conf \
$(PACKAGE)-$(VERSION)/tests/define.cpp \
$(PACKAGE)-$(VERSION)/tests/if.cpp \
$(PACKAGE)-$(VERSION)/tests/Makefile \
$(PACKAGE)-$(VERSION)/tests/cpp.sh \

View File

@ -1,4 +1,4 @@
TARGETS = if.o
TARGETS = define.o if.o
PREFIX = /usr/local
DESTDIR =
BINDIR = $(PREFIX)/bin
@ -13,14 +13,20 @@ INSTALL = install
all: $(TARGETS)
define.o_OBJS = define.o
define.o_CXXFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CXXFLAGS)
if.o_OBJS = if.o
if.o_CXXFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CXXFLAGS)
define.o: define.cpp cpp.sh
$(CXX) $(define.o_CXXFLAGS) -c define.cpp
if.o: if.cpp cpp.sh
$(CXX) $(if.o_CXXFLAGS) -c if.cpp
clean:
$(RM) -- $(if.o_OBJS)
$(RM) -- $(define.o_OBJS) $(if.o_OBJS)
distclean: clean
$(RM) -- $(TARGETS)

25
tests/define.cpp Normal file
View File

@ -0,0 +1,25 @@
#ifdef GOOD
#error error
#endif
#define GOOD 1
#ifdef GOOD
#warning good
#else
#error error
#endif
#ifndef GOOD
#error error
#else
#warning good
#endif
#undef GOOD
#ifndef GOOD
#warning good
#else
#error error
#endif

1
tests/define.o Normal file
View File

@ -0,0 +1 @@
#define GOOD 1 2

31
tests/if.o Normal file
View File

@ -0,0 +1,31 @@
#if 0
#warning good
#endif
#if 1
#warning good
#else
#define GOOD 1
#if GOOD
#warning good
#else
#undef GOOD
#define GOOD 0
#if !GOOD
#warning good
#else
#undef GOOD
#define GOOD 1
#if 0
#warning good
#endif
#undef GOOD
#define GOOD 0
#if 0
#warning good
#endif
#undef GOOD

View File

@ -1,8 +1,15 @@
targets=if.o
targets=define.o,if.o
cxx=./cpp.sh
cxxflags=
dist=Makefile,cpp.sh
[define.o]
type=object
sources=define.cpp
[define.cpp]
depends=cpp.sh
[if.o]
type=object
sources=if.cpp