Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,19 @@ target_link_libraries(tests_Serialization
)
add_test(NAME tests_Serialization COMMAND tests_Serialization)

if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/test_swdf/swdf.nt")
file(DOWNLOAD "https://files.dice-research.org/datasets/ISWC2020_Tentris/swdf.zip" "${CMAKE_CURRENT_BINARY_DIR}/test_swdf/swdf.zip")
execute_process(COMMAND unzip "${CMAKE_CURRENT_BINARY_DIR}/test_swdf/swdf.zip" -d "${CMAKE_CURRENT_BINARY_DIR}/test_swdf")
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test_swdf/swdf.zip")
endif ()
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/graph/tests_loading_simple.trig" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
add_executable(tests_Loading graph/tests_loading.cpp)
target_link_libraries(tests_Loading
doctest::doctest
rdf4cpp
)
add_test(NAME tests_Loading COMMAND tests_Loading)

# copy files for testing to the binary folder
# file(COPY foldername DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/parser/tests_RDFFileParser_simple.ttl" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
30 changes: 30 additions & 0 deletions tests/graph/tests_loading.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <doctest/doctest.h>

#include <rdf4cpp.hpp>

using namespace rdf4cpp;

TEST_CASE("load Graph") {
Graph set{};
std::fstream file{"test_swdf/swdf.nt"};
set.load_rdf_data(file, parser::ParsingFlags::none(), nullptr, [](parser::ParsingError e) {
FAIL(std::format("{}", e));
});
CHECK(set.size() == 304592);
}

TEST_CASE("load dataset") {
Dataset set{};
std::fstream file{"tests_loading_simple.trig"};
set.load_rdf_data(file, parser::ParsingFlags::none(), nullptr, [](parser::ParsingError e) {
FAIL(std::format("{}", e));
});
CHECK(set.size() == 4);
int i = 0;
for ([[maybe_unused]] const auto& _ : set) {
++i;
}
CHECK(i == 4);
CHECK(set.graph(IRI::make("http://data.semanticweb.org/workshop/admire/2012")).size() == 4);
}
6 changes: 6 additions & 0 deletions tests/graph/tests_loading_simple.trig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<http://data.semanticweb.org/workshop/admire/2012> {
<http://data.semanticweb.org/workshop/admire/2012/paper/12> <http://purl.org/dc/elements/1.1/subject> "search" .
<http://data.semanticweb.org/workshop/admire/2012/paper/12> <http://purl.org/ontology/bibo/authorList> <http://data.semanticweb.org/workshop/admire/2012/paper/12/authorlist> .
<http://data.semanticweb.org/workshop/admire/2012/paper/12> <http://purl.org/dc/elements/1.1/subject> "web applications" .
<http://dbpedia.org/resource/Nikolai_Skoblin> <http://dbpedia.org/ontology/deathDate> "1937-1-1"^^<http://www.w3.org/2001/XMLSchema#date> .
}
Loading