init test for unitest

This commit is contained in:
wyy 2013-10-06 02:25:05 -07:00
parent 462b7e64d1
commit 16818c0d69
3 changed files with 80 additions and 1 deletions

View File

@ -11,7 +11,6 @@ namespace CppJieba
class ChFilterIterator
{
public:
public:
const Unicode * ptUnico;
UniConIter begin;

26
test/ChineseFilterUt.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <ChineseFilter.h>
#ifdef UT
using namespace CppJieba;
int main(int argc, char** argv)
{
ChineseFilter chFilter;
ifstream ifs("../demo/testlines.utf8");
string line;
while(getline(ifs, line))
{
chFilter.feed(line);
for(ChineseFilter::iterator it = chFilter.begin(); it != chFilter.end(); it++)
{
//cout<<__FILE__<<__LINE__<<endl;
string tmp;
TransCode::encode(it.begin, it.end, tmp);
cout<<tmp<<endl;
}
}
return 0;
}
#endif

54
test/Makefile Normal file
View File

@ -0,0 +1,54 @@
CXX := g++
LD := g++
AR := ar rc
INCS := -I../cppjieba/
DEBUG_CXXFLAGS := -g -Wall -DDEBUG -DUT $(INCS)
CXXFLAGS := ${DEBUG_CXXFLAGS}
LDFLAGS := ${DEBUG_LDFLAGS}
DOLINK := $(LD) $(LDFLAGS)
DOPACK := $(AR)
SOURCES := $(wildcard *.cpp)
OBJS := $(patsubst %.cpp,%.o,$(SOURCES))
UTS := $(patsubst %.cpp,%.ut,$(SOURCES))
CPPJIEBADIR = ../cppjieba
LIBCPPJIEBA = $(CPPJIEBADIR)/libcppjieba.a
CPPCOMMONDIR = ../cppcommon
LIBCPPCM = $(CPPCOMMONDIR)/libcm.a
LIBA := $(LIBCPPJIEBA) $(LIBCPPCM)
# remove the objs after compilation
.PHONY: clean $(LIBA)
# Main Targets
all: $(UTS)
# This is a suffix rule
#.c.o:
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) $<
%.ut: %.o $(LIBA)
$(CXX) $(CXXFLAGS) -o $@ $^
$(LIBCPPJIEBA):
cd $(CPPJIEBADIR) && $(MAKE)
$(LIBCPPCM):
cd $(CPPCOMMONDIR) && $(MAKE)
clean:
rm -f *.o *.ut *.d *.d.*
# cd $(CPPJIEBADIR) && make clean
# cd $(CPPCOMMONDIR) && make clean
sinclude $(SOURCES:.cpp=.d)
%.d:%.cpp
@set -e; rm -f $@; \
$(CXX) -MM $< > $@.$$$$; \
sed 's,\($*\).o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$