Fix TestAstUtils

This commit is contained in:
Daniel Marjamäki 2016-01-16 19:08:51 +01:00
parent 522de81cc7
commit d54f4f9c65
3 changed files with 15 additions and 8 deletions

View File

@ -181,6 +181,7 @@ CLIOBJ = cli/cmdlineparser.o \
TESTOBJ = test/options.o \
test/test64bit.o \
test/testassert.o \
test/testastutils.o \
test/testautovariables.o \
test/testbool.o \
test/testboost.o \
@ -451,6 +452,9 @@ test/test64bit.o: test/test64bit.cpp lib/cxx11emu.h lib/tokenize.h lib/errorlogg
test/testassert.o: test/testassert.cpp lib/cxx11emu.h lib/tokenize.h lib/errorlogger.h lib/config.h lib/suppressions.h lib/tokenlist.h lib/checkassert.h lib/check.h lib/token.h lib/valueflow.h lib/mathlib.h lib/settings.h lib/library.h lib/standards.h lib/timer.h test/testsuite.h
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CFG) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o test/testassert.o test/testassert.cpp
test/testastutils.o: test/testastutils.cpp lib/cxx11emu.h lib/astutils.h test/testsuite.h lib/errorlogger.h lib/config.h lib/suppressions.h
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CFG) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o test/testastutils.o test/testastutils.cpp
test/testautovariables.o: test/testautovariables.cpp lib/cxx11emu.h lib/tokenize.h lib/errorlogger.h lib/config.h lib/suppressions.h lib/tokenlist.h lib/checkautovariables.h lib/check.h lib/token.h lib/valueflow.h lib/mathlib.h lib/settings.h lib/library.h lib/standards.h lib/timer.h test/testsuite.h
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CFG) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o test/testautovariables.o test/testautovariables.cpp

View File

@ -17,7 +17,9 @@
*/
#include "astutils.h"
#include "tokenizer.h"
#include "token.h"
#include "settings.h"
#include "tokenize.h"
#include "testsuite.h"
@ -32,16 +34,16 @@ private:
TEST_CASE(isReturnScope);
}
Tokenizer tokenize(const char code[], const char filename[]) {
Tokenizer tokenizer(&settings0, this);
bool isReturnScope(const char code[], const char filename[]="test.cpp") {
Settings settings;
Tokenizer tokenizer(&settings, this);
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
return tokenizer;
tokenizer.tokenize(istr, filename);
return ::isReturnScope(Token::findsimplematch(tokenizer.tokens(),"}"));
}
void isReturnScope() const {
const Tokenizer &t1 = tokenize("void f() { if (a) { return; } }");
ASSERT_EQUALS(true, ::isReturnScope(Token::findsimplematch(t1.tokens(),"} }")));
void isReturnScope() {
ASSERT_EQUALS(true, isReturnScope("void f() { if (a) { return; } }"));
}
};

View File

@ -5,6 +5,7 @@ INCLUDEPATH += ../externals/tinyxml
SOURCES += $${BASEPATH}/test64bit.cpp \
$${BASEPATH}/testassert.cpp \
$${BASEPATH}/testastutils.cpp \
$${BASEPATH}/testautovariables.cpp \
$${BASEPATH}/testbool.cpp \
$${BASEPATH}/testboost.cpp \