mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
init test for unitest
This commit is contained in:
parent
462b7e64d1
commit
16818c0d69
@ -11,7 +11,6 @@ namespace CppJieba
|
||||
|
||||
class ChFilterIterator
|
||||
{
|
||||
public:
|
||||
public:
|
||||
const Unicode * ptUnico;
|
||||
UniConIter begin;
|
||||
|
26
test/ChineseFilterUt.cpp
Normal file
26
test/ChineseFilterUt.cpp
Normal 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
54
test/Makefile
Normal 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 $@.$$$$
|
Loading…
x
Reference in New Issue
Block a user