diff --git a/Makefile b/Makefile index bfee953..5502515 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,10 @@ $(HDTLIB)/libhdt.a $(HDTLIB)/libcds.a: FORCE FORCE: check:: + $(SWIPL) -g test_hdt -t halt test/test_hdt.pl + install:: + clean: rm -f $(OBJ) $(OBJ2) [ ! -f $(HDTHOME)/Makefile ] || (cd $(HDTHOME) && git reset --hard) @@ -47,3 +50,4 @@ clean: distclean: clean rm -f $(SOBJ) + [ ! -f $(HDTHOME)/Makefile ] || $(MAKE) -C $(HDTHOME) distclean diff --git a/pack.pl b/pack.pl index 5e706f8..f8a62f4 100644 --- a/pack.pl +++ b/pack.pl @@ -1,5 +1,5 @@ name(hdt). -version('0.5.2'). +version('0.5.3'). % TODO: swipl_version([90121]). title('Access RDF HDT files'). keywords(['RDF']). diff --git a/test/data/README.md b/test/data/README.md new file mode 100644 index 0000000..4709d9a --- /dev/null +++ b/test/data/README.md @@ -0,0 +1,13 @@ +The files were generated by: + +``` +./hdt-cpp/libhdt/tools/hdtInfo hdt-cpp/libhdt/data/literals.hdt >literals.hdtInfo-output +echo '? ? ?' | ./libhdt/tools/hdtSearch lib-cpp/libhdt/data/literals.hdt 2>/dev/null >literals.hdtSearch-output +``` + +To do this, you need to run "make" separately (the "make" that runs from `pack_install(.)` does something different because it has other options to `./configure`): +```sh +cd hdt-cpp && ./autogen.sh && ./configure && make -j8 +``` + +TODO: use hdt2rdf, rdf2hdt diff --git a/test/data/literals.hdtInfo-output b/test/data/literals.hdtInfo-output new file mode 100644 index 0000000..c899fe4 --- /dev/null +++ b/test/data/literals.hdtInfo-output @@ -0,0 +1,28 @@ +<file://literals.ttl> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.org/HDT/hdt#Dataset> . +<file://literals.ttl> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://rdfs.org/ns/void#Dataset> . +<file://literals.ttl> <http://rdfs.org/ns/void#triples> "9" . +<file://literals.ttl> <http://rdfs.org/ns/void#properties> "1" . +<file://literals.ttl> <http://rdfs.org/ns/void#distinctSubjects> "1" . +<file://literals.ttl> <http://rdfs.org/ns/void#distinctObjects> "9" . +<file://literals.ttl> <http://purl.org/HDT/hdt#statisticalInformation> _:statistics . +<file://literals.ttl> <http://purl.org/HDT/hdt#publicationInformation> _:publicationInformation . +<file://literals.ttl> <http://purl.org/HDT/hdt#formatInformation> _:format . +_:format <http://purl.org/HDT/hdt#dictionary> _:dictionary . +_:format <http://purl.org/HDT/hdt#triples> _:triples . +_:dictionary <http://purl.org/dc/terms/format> <http://purl.org/HDT/hdt#dictionaryLiteral> . +_:dictionary <http://purl.org/HDT/hdt#dictionarynumSubjects> "1" . +_:dictionary <http://purl.org/HDT/hdt#dictionarynumPredicates> "1" . +_:dictionary <http://purl.org/HDT/hdt#dictionarynumObjects> "9" . +_:dictionary <http://purl.org/HDT/hdt#dictionarynumSharedSubjectObject> "0" . +_:dictionary <http://purl.org/HDT/hdt#dictionarymaxSubjectID> "1" . +_:dictionary <http://purl.org/HDT/hdt#dictionarymaxPredicateID> "1" . +_:dictionary <http://purl.org/HDT/hdt#dictionarymaxObjectID> "9" . +_:dictionary <http://purl.org/HDT/hdt#dictionarymapping> "1" . +_:dictionary <http://purl.org/HDT/hdt#dictionarysizeStrings> "2710" . +_:dictionary <http://purl.org/HDT/hdt#dictionaryblockSize> "8" . +_:triples <http://purl.org/dc/terms/format> <http://purl.org/HDT/hdt#triplesBitmap> . +_:triples <http://purl.org/HDT/hdt#triplesnumTriples> "9" . +_:triples <http://purl.org/HDT/hdt#triplesOrder> "SPO" . +_:statistics <http://purl.org/HDT/hdt#originalSize> "156" . +_:statistics <http://purl.org/HDT/hdt#hdtSize> "2940" . +_:publicationInformation <http://purl.org/dc/terms/issued> "2015-02-13T17:21:30+0100" . diff --git a/test/data/literals.hdtSearch-output b/test/data/literals.hdtSearch-output new file mode 100644 index 0000000..62c6aed --- /dev/null +++ b/test/data/literals.hdtSearch-output @@ -0,0 +1,10 @@ +s p "a" +s p "a"@en +s p "a"^^<bcd> +s p "abc" +s p "abc"@en +s p "abc"^^<bcd> +s p "bc" +s p "bc"@en +s p "bc"^^<bcd> +9 results in 162 us diff --git a/test/test_hdt.pl b/test/test_hdt.pl new file mode 100644 index 0000000..9d9b28e --- /dev/null +++ b/test/test_hdt.pl @@ -0,0 +1,41 @@ +% -*- mode: Prolog; coding: utf-8 -*- + +/* These tests use the data in ../hdt-cpp/libhdt/data/literals.hdt + See the comments in data/README.md if a test fails - the failure + might be because the data has changed. +*/ + +:- module(test_hdt, + [ test_hdt/0 + ]). + +:- use_module(library(plunit)). +:- use_module(library(hdt)). + +test_hdt :- + run_tests([hdt]). + +:- begin_tests(hdt). + +test(hdt_search_id) :- + hdt_open_literals(H), + bagof(S:P:O, hdt_search_id(H, S, P, O), SPOs), + assertion(SPOs == [1:1:1, + 1:1:2, + 1:1:3, + 1:1:4, + 1:1:5, + 1:1:6, + 1:1:7, + 1:1:8, + 1:1:9]), + hdt_close(H). + +hdt_open_literals(H) :- + predicate_property(test_hdt, file(TestHdtFile)), + directory_file_path(TestHdtDir, _, TestHdtFile), + atom_concat(TestHdtDir, '/../hdt-cpp/libhdt/data/literals.hdt', LiteralsHdtPath), + hdt_open(H, LiteralsHdtPath). + +:- end_tests(hdt). +