C ++我如何运行makefile输出
下面是我的MakeFile,我想问一下如何运行我的unitTest.cpp,因为当我用NetBean MakeFile 时,使用下面的MakeFile,main.exe 实际上是main.cpp 输出
但我想运行 unitTest.cpp 的输出
我如何运行 unitTest.cpp
# ExampleTests Project
SRCS = main.cpp currencyConverter.cpp unitTest.cpp
HDRS = currencyConverter.h unitTest.h
PROJ = main
# Remaining lines shouldn't need changing
# Here's what they do:
# - rebuild if any header file or this Makefile changes
# - include CppUnit as dynamic library
# - search /opt/local for MacPorts
# - generate .exe files for Windows
# - add -enable-auto-import flag for Cygwin only
CC = g++
OBJS = $(SRCS:.cpp=.o)
APP = $(PROJ).exe
CFLAGS = -c -g -Wall -I/opt/local/include
ifeq (,$(findstring CYGWIN,$(shell uname)))
LDFLAGS = -L/opt/local/lib
else
LDFLAGS = -L/opt/local/lib -enable-auto-import
endif
LIBS = -lcppunit -ldl
all: $(APP)
$(APP): $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) -o $(APP) $(LIBS)
%.o: %.cpp $(HDRS)
$(CC) $(CFLAGS) $< -o $@
clean:
rm -f *.o $(APP)
下面是我的 unitTest.cpp
#include "unitTest.h"
#include "currencyConverter.h"
CPPUNIT_TEST_SUITE_REGISTRATION(unitTest);
unitTest::unitTest() {
}
unitTest::~unitTest() {
}
void unitTest::setUp() {
}
void unitTest::tearDown() {
}
void stringToUpper(string&);
void unitTest::testStringLowerToUpper()
{
string str = "ILOVECPLUSPLUS";
string str2 = "IloveCplusplus";
cout << "\nChecking if string 1 '" << str << "' equals string 2 '" << str2 << "'";
CPPUNIT_ASSERT_EQUAL(str,str2);
//this part i will use my stringToUpperFunction to test.
currencyConverter c;
c.stringToUpper(str2);
cout << "\nChecking if string 1 '" << str << "' equals string 2 '" << str2 << "'";
CPPUNIT_ASSERT_EQUAL(str,str2);
}