Add test sample
This commit is contained in:
parent
89e9fdc55e
commit
7f2a84c10c
4
Makefile
4
Makefile
|
@ -46,8 +46,8 @@ libupdfparser.a: $(OBJECTS)
|
|||
libupdfparser.so: $(OBJECTS)
|
||||
$(CXX) obj/*.o $(LDFLAGS) -o $@ -shared
|
||||
|
||||
test: test.c libupdfparser.a
|
||||
test: tests/test.cpp libupdfparser.a
|
||||
g++ -ggdb -O0 $^ -o $@ -Iinclude libupdfparser.a
|
||||
|
||||
clean:
|
||||
rm -rf libupdfparser.so libupdfparser.a obj
|
||||
rm -rf libupdfparser.so libupdfparser.a obj test
|
||||
|
|
27
tests/test.cpp
Normal file
27
tests/test.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include <iostream>
|
||||
#include <uPDFParser.h>
|
||||
#include <uPDFParser_common.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
uPDFParser::Parser parser;
|
||||
|
||||
if (argc != 2 || std::string(argv[1]) == "-h" || std::string(argv[1]) == "--help")
|
||||
{
|
||||
std::cout << "Usage : " << argv[0] << " <file>" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::cout << "Parse " << argv[1] << std::endl;
|
||||
try
|
||||
{
|
||||
parser.parse(argv[1]);
|
||||
}
|
||||
catch(uPDFParser::Exception e)
|
||||
{
|
||||
std::cout << e.what() << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user