summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-03-09 17:44:36 +0100
committerDavid Robillard <d@drobilla.net>2019-12-12 19:42:09 +0100
commit3c0ed6b66b6e99c68fc01c86b5796a55d74a5977 (patch)
tree7be3252c13ef123b956424169c1bfbf55359564a /tests
parente32f32a360f2bf8f017ea347b6d1e568c0beaf68 (diff)
downloadingen-serd1.tar.gz
ingen-serd1.tar.bz2
ingen-serd1.zip
WIP: Port to serd1serd1
Diffstat (limited to 'tests')
-rw-r--r--tests/empty.ingen/main.ttl1
-rw-r--r--tests/ingen_test.cpp66
-rw-r--r--tests/tst_FilePath.cpp5
3 files changed, 33 insertions, 39 deletions
diff --git a/tests/empty.ingen/main.ttl b/tests/empty.ingen/main.ttl
index 8b60b3aa..4a0925c3 100644
--- a/tests/empty.ingen/main.ttl
+++ b/tests/empty.ingen/main.ttl
@@ -46,4 +46,3 @@
lv2:symbol "notify" ;
a atom:AtomPort ,
lv2:OutputPort .
-
diff --git a/tests/ingen_test.cpp b/tests/ingen_test.cpp
index 476fab64..96117e8f 100644
--- a/tests/ingen_test.cpp
+++ b/tests/ingen_test.cpp
@@ -15,6 +15,7 @@
*/
#include "TestClient.hpp"
+
#include "ingen_config.h"
#include "ingen/Atom.hpp"
@@ -37,15 +38,15 @@
#include "ingen/runtime_paths.hpp"
#include "ingen/types.hpp"
#include "raul/Path.hpp"
-#include "serd/serd.h"
-#include "sord/sordmm.hpp"
-#include "sratom/sratom.h"
+#include "serd/serd.hpp"
+#include "sratom/sratom.hpp"
#include <chrono>
#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <string>
+#include <string>
#include <utility>
using namespace std;
@@ -124,9 +125,8 @@ main(int argc, char** argv)
// Read commands
- AtomForge forge(world->uri_map().urid_map_feature()->urid_map);
-
- sratom_set_object_mode(&forge.sratom(), SRATOM_OBJECT_MODE_BLANK_SUBJECT);
+ AtomForge forge(world->rdf_world(),
+ world->uri_map().urid_map_feature()->urid_map);
// AtomReader to read commands from a file and send them to engine
AtomReader atom_reader(world->uri_map(),
@@ -140,47 +140,46 @@ main(int argc, char** argv)
world->interface()->set_respondee(client);
world->engine()->register_client(client);
- SerdURI cmds_base;
- SerdNode cmds_file_uri = serd_node_new_file_uri(
- (const uint8_t*)run_path.c_str(),
- nullptr, &cmds_base, true);
- Sord::Model* cmds = new Sord::Model(*world->rdf_world(),
- (const char*)cmds_file_uri.buf);
- SerdEnv* env = serd_env_new(&cmds_file_uri);
- cmds->load_file(env, SERD_TURTLE, run_path);
- Sord::Node nil;
+ serd::Node run_uri = serd::make_file_uri(run_path.string());
+ serd::Model cmds(world->rdf_world(),
+ serd::ModelFlag::index_SPO | serd::ModelFlag::index_OPS);
+
+ serd::Env env(run_uri);
+ serd::Inserter inserter(cmds, env);
+ serd::Reader reader(
+ world->rdf_world(), serd::Syntax::Turtle, {}, inserter.sink(), 4096);
+
+ reader.start_file(run_path.string());
+ reader.read_document();
+ reader.finish();
+
int n_events = 0;
for (;; ++n_events) {
- std::string subject_str = fmt("msg%1%", n_events);
- Sord::URI subject(*world->rdf_world(), subject_str,
- (const char*)cmds_file_uri.buf);
- Sord::Iter iter = cmds->find(subject, nil, nil);
- if (iter.end()) {
+ const auto subject = serd::make_resolved_uri(
+ std::string("msg") + std::to_string(n_events), run_uri);
+ if (!cmds.ask(subject, {}, {})) {
break;
}
- forge.clear();
- forge.read(*world->rdf_world(), cmds->c_obj(), subject.c_obj());
+ auto atom = forge.read(cmds, subject);
#if 0
- const LV2_Atom* atom = forge.atom();
- cerr << "READ " << atom->size << " BYTES" << endl;
- cerr << sratom_to_turtle(
- sratom,
- &world->uri_map().urid_unmap_feature()->urid_unmap,
- (const char*)cmds_file_uri.buf,
- nullptr, nullptr, atom->type, atom->size, LV2_ATOM_BODY(atom)) << endl;
+ sratom::Streamer streamer{
+ world->rdf_world(),
+ world->uri_map().urid_map_feature()->urid_map,
+ world->uri_map().urid_unmap_feature()->urid_unmap};
+
+ auto str = streamer.to_string(env, *atom);
+ cerr << "Read " << atom->size << " bytes:\n" << str << endl;
#endif
- if (!atom_reader.write(forge.atom(), n_events + 1)) {
+ if (!atom_reader.write(atom, n_events + 1)) {
return EXIT_FAILURE;
}
world->engine()->flush_events(std::chrono::milliseconds(20));
}
- delete cmds;
-
// Save resulting graph
auto r = world->store()->find(Raul::Path("/"));
const std::string base = run_path.stem();
@@ -212,9 +211,6 @@ main(int argc, char** argv)
const FilePath redo_path = filesystem::current_path() / redo_name;
world->serialiser()->write_bundle(r->second, URI(redo_path));
- serd_env_free(env);
- serd_node_free(&cmds_file_uri);
-
// Shut down
world->engine()->deactivate();
diff --git a/tests/tst_FilePath.cpp b/tests/tst_FilePath.cpp
index 768371fe..68f734f0 100644
--- a/tests/tst_FilePath.cpp
+++ b/tests/tst_FilePath.cpp
@@ -18,8 +18,7 @@
#include "ingen/FilePath.hpp"
#include "ingen/fmt.hpp"
-
-#include <boost/utility/string_view.hpp>
+#include "serd/serd.hpp"
#include <string>
@@ -91,7 +90,7 @@ main(int, char**)
path += 'r';
EXPECT_EQ(path, "/a/bar/car");
- path += boost::string_view("/d");
+ path += serd::StringView("/d");
EXPECT_EQ(path, "/a/bar/car/d");
const FilePath apple("apple");