diff --git a/SConstruct b/SConstruct index 3d16997..44d50d5 100644 --- a/SConstruct +++ b/SConstruct @@ -29,9 +29,9 @@ def add_kel_source_files(self, sources, filetype, lib_env=None, shared=False, ta sources.append( self.StaticObject( target=target_name, source=path ) ) pass -env=Environment(ENV=os.environ, CPPPATH=['#source/forst-io','#source','#','#driver'], +env=Environment(ENV=os.environ, CPPPATH=['#source/forstio','#source','#','#driver'], CXX='clang++', - CPPDEFINES=['GIN_UNIX'], + CPPDEFINES=['SAW_UNIX'], CXXFLAGS=['-std=c++20','-g','-Wall','-Wextra'], LIBS=['gnutls']) env.__class__.add_source_files = add_kel_source_files @@ -47,7 +47,7 @@ env.driver_sources = [] env.driver_headers = [] Export('env') -SConscript('source/kelgin/SConscript') +SConscript('source/forstio/SConscript') SConscript('driver/SConscript') # Library build @@ -56,11 +56,11 @@ env_library = env.Clone() env.objects_shared = [] env_library.add_source_files(env.objects_shared, env.sources + env.driver_sources + env.tls_sources, shared=True) -env.library_shared = env_library.SharedLibrary('#bin/kelgin', [env.objects_shared]) +env.library_shared = env_library.SharedLibrary('#bin/forstio', [env.objects_shared]) env.objects_static = [] env_library.add_source_files(env.objects_static, env.sources + env.driver_sources + env.tls_sources) -env.library_static = env_library.StaticLibrary('#bin/kelgin', [env.objects_static]) +env.library_static = env_library.StaticLibrary('#bin/forstio', [env.objects_static]) env.Alias('library', [env.library_shared, env.library_static]) env.Alias('library_shared', env.library_shared) diff --git a/driver/io-unix.h b/driver/io-unix.h index d63f27e..8a84efe 100644 --- a/driver/io-unix.h +++ b/driver/io-unix.h @@ -1,6 +1,6 @@ #pragma once -#ifndef GIN_UNIX +#ifndef SAW_UNIX #error "Don't include this" #endif @@ -26,8 +26,7 @@ #include #include -#include "./io.h" -#include "kelgin/io.h" +#include "forstio/io.h" namespace saw { namespace unix { diff --git a/source/forst-io/SConscript b/source/forstio/SConscript similarity index 100% rename from source/forst-io/SConscript rename to source/forstio/SConscript diff --git a/source/forst-io/async.cpp b/source/forstio/async.cpp similarity index 100% rename from source/forst-io/async.cpp rename to source/forstio/async.cpp diff --git a/source/forst-io/async.h b/source/forstio/async.h similarity index 100% rename from source/forst-io/async.h rename to source/forstio/async.h diff --git a/source/forst-io/async.tmpl.h b/source/forstio/async.tmpl.h similarity index 96% rename from source/forst-io/async.tmpl.h rename to source/forstio/async.tmpl.h index 2c8b586..c959498 100644 --- a/source/forst-io/async.tmpl.h +++ b/source/forstio/async.tmpl.h @@ -65,7 +65,7 @@ template Conveyor Conveyor::buffer(size_t size) { size); ConveyorStorage *storage_ptr = static_cast(storage_node.get()); - GIN_ASSERT(storage) { return Conveyor{nullptr, nullptr}; } + SAW_ASSERT(storage) { return Conveyor{nullptr, nullptr}; } storage->setParent(storage_ptr); return Conveyor{std::move(storage_node), storage_ptr}; @@ -104,7 +104,7 @@ SinkConveyor Conveyor::sink(ErrorFunc &&error_func) { ConveyorStorage *storage_ptr = static_cast(sink_node.get()); - GIN_ASSERT(storage) { return SinkConveyor{}; } + SAW_ASSERT(storage) { return SinkConveyor{}; } storage->setParent(storage_ptr); return SinkConveyor{std::move(sink_node)}; @@ -228,7 +228,7 @@ template void QueueBufferConveyorNode::childHasFired() { } template void QueueBufferConveyorNode::parentHasFired() { - GIN_ASSERT(parent) { return; } + SAW_ASSERT(parent) { return; } if (parent->space() == 0) { return; @@ -261,7 +261,7 @@ template void ImmediateConveyorNode::childHasFired() { } template void ImmediateConveyorNode::parentHasFired() { - GIN_ASSERT(parent) { return; } + SAW_ASSERT(parent) { return; } assert(parent->space() > 0); if (queued() > 0) { @@ -287,7 +287,7 @@ template MergeConveyor::~MergeConveyor() {} template void MergeConveyor::attach(Conveyor conveyor) { auto sp = data.lock(); - GIN_ASSERT(sp) { return; } + SAW_ASSERT(sp) { return; } sp->attach(std::move(conveyor)); } @@ -295,7 +295,7 @@ template void MergeConveyor::attach(Conveyor conveyor) { template MergeConveyorNode::MergeConveyorNode(Our> d) : data{d} { - GIN_ASSERT(data) { return; } + SAW_ASSERT(data) { return; } data->merger = this; } @@ -306,7 +306,7 @@ template void MergeConveyorNode::getResult(ErrorOrValue &eov) noexcept { ErrorOr> &err_or_val = eov.as>(); - GIN_ASSERT(data) { return; } + SAW_ASSERT(data) { return; } /// @todo search appendages for result @@ -334,7 +334,7 @@ void MergeConveyorNode::getResult(ErrorOrValue &eov) noexcept { } template void MergeConveyorNode::fire() { - GIN_ASSERT(queued() > 0) { return; } + SAW_ASSERT(queued() > 0) { return; } if (parent) { parent->childHasFired(); @@ -348,7 +348,7 @@ template void MergeConveyorNode::fire() { template size_t MergeConveyorNode::space() const { return 0; } template size_t MergeConveyorNode::queued() const { - GIN_ASSERT(data) { return 0; } + SAW_ASSERT(data) { return 0; } size_t queue_count = 0; @@ -365,7 +365,7 @@ template void MergeConveyorNode::childHasFired() { } template void MergeConveyorNode::parentHasFired() { - GIN_ASSERT(parent) { return; } + SAW_ASSERT(parent) { return; } if (queued() > 0) { if (parent->space() > 0) { armLater(); @@ -374,7 +374,7 @@ template void MergeConveyorNode::parentHasFired() { } template size_t MergeConveyorNode::Appendage::space() const { - GIN_ASSERT(merger) { return 0; } + SAW_ASSERT(merger) { return 0; } if (error_or_value.has_value()) { return 0; @@ -384,7 +384,7 @@ template size_t MergeConveyorNode::Appendage::space() const { } template size_t MergeConveyorNode::Appendage::queued() const { - GIN_ASSERT(merger) { return 0; } + SAW_ASSERT(merger) { return 0; } if (error_or_value.has_value()) { return 1; @@ -397,7 +397,7 @@ template void MergeConveyorNode::Appendage::getAppendageResult(ErrorOrValue &eov) { ErrorOr> &err_or_val = eov.as>(); - GIN_ASSERT(queued() > 0) { + SAW_ASSERT(queued() > 0) { err_or_val = criticalError("No element queued in Merge Appendage Node"); return; } @@ -407,7 +407,7 @@ void MergeConveyorNode::Appendage::getAppendageResult(ErrorOrValue &eov) { } template void MergeConveyorNode::Appendage::childHasFired() { - GIN_ASSERT(!error_or_value.has_value()) { return; } + SAW_ASSERT(!error_or_value.has_value()) { return; } ErrorOr> eov; child->getResult(eov); @@ -426,9 +426,9 @@ template void MergeConveyorNode::Appendage::parentHasFired() { template void MergeConveyorNode::Appendage::setParent(ConveyorStorage *par) { - GIN_ASSERT(merger) { return; } + SAW_ASSERT(merger) { return; } - GIN_ASSERT(child) { return; } + SAW_ASSERT(child) { return; } parent = par; } @@ -541,7 +541,7 @@ template void AdaptConveyorNode::childHasFired() { } template void AdaptConveyorNode::parentHasFired() { - GIN_ASSERT(parent) { return; } + SAW_ASSERT(parent) { return; } if (parent->space() == 0) { return; diff --git a/source/forst-io/buffer.cpp b/source/forstio/buffer.cpp similarity index 100% rename from source/forst-io/buffer.cpp rename to source/forstio/buffer.cpp diff --git a/source/forst-io/buffer.h b/source/forstio/buffer.h similarity index 100% rename from source/forst-io/buffer.h rename to source/forstio/buffer.h diff --git a/source/forst-io/common.h b/source/forstio/common.h similarity index 81% rename from source/forst-io/common.h rename to source/forstio/common.h index 82dea5c..3761ca3 100644 --- a/source/forst-io/common.h +++ b/source/forstio/common.h @@ -7,27 +7,27 @@ namespace saw { -#define GIN_CONCAT_(x, y) x##y -#define GIN_CONCAT(x, y) GIN_CONCAT_(x, y) -#define GIN_UNIQUE_NAME(prefix) GIN_CONCAT(prefix, __LINE__) +#define SAW_CONCAT_(x, y) x##y +#define SAW_CONCAT(x, y) SAW_CONCAT_(x, y) +#define SAW_UNIQUE_NAME(prefix) SAW_CONCAT(prefix, __LINE__) -#define GIN_FORBID_COPY(classname) \ +#define SAW_FORBID_COPY(classname) \ classname(const classname &) = delete; \ classname &operator=(const classname &) = delete -#define GIN_FORBID_MOVE(classname) \ +#define SAW_FORBID_MOVE(classname) \ classname(classname &&) = delete; \ classname &operator=(classname &&) = delete -#define GIN_DEFAULT_COPY(classname) \ +#define SAW_DEFAULT_COPY(classname) \ classname(const classname &) = default; \ classname &operator=(const classname &) = default -#define GIN_DEFAULT_MOVE(classname) \ +#define SAW_DEFAULT_MOVE(classname) \ classname(classname &&) = default; \ classname &operator=(classname &&) = default -#define GIN_ASSERT(expression) \ +#define SAW_ASSERT(expression) \ assert(expression); \ if (!(expression)) diff --git a/source/forst-io/error.cpp b/source/forstio/error.cpp similarity index 100% rename from source/forst-io/error.cpp rename to source/forstio/error.cpp diff --git a/source/forst-io/error.h b/source/forstio/error.h similarity index 99% rename from source/forst-io/error.h rename to source/forstio/error.h index a429c10..e2fda88 100644 --- a/source/forst-io/error.h +++ b/source/forstio/error.h @@ -31,7 +31,7 @@ public: Error(std::string &&msg, Error::Code code); Error(Error &&error); - GIN_FORBID_COPY(Error); + SAW_FORBID_COPY(Error); Error &operator=(Error &&) = default; diff --git a/source/forst-io/io.cpp b/source/forstio/io.cpp similarity index 86% rename from source/forst-io/io.cpp rename to source/forstio/io.cpp index e9ddb85..e835617 100644 --- a/source/forst-io/io.cpp +++ b/source/forstio/io.cpp @@ -22,9 +22,9 @@ AsyncIoStream::AsyncIoStream(Own str) .sink()} {} void AsyncIoStream::read(void *buffer, size_t min_length, size_t max_length) { - GIN_ASSERT(buffer && max_length >= min_length && min_length > 0) { return; } + SAW_ASSERT(buffer && max_length >= min_length && min_length > 0) { return; } - GIN_ASSERT(!read_stepper.read_task.has_value()) { return; } + SAW_ASSERT(!read_stepper.read_task.has_value()) { return; } read_stepper.read_task = ReadTaskAndStepHelper::ReadIoTask{buffer, min_length, max_length, 0}; @@ -44,9 +44,9 @@ Conveyor AsyncIoStream::onReadDisconnected() { } void AsyncIoStream::write(const void *buffer, size_t length) { - GIN_ASSERT(buffer && length > 0) { return; } + SAW_ASSERT(buffer && length > 0) { return; } - GIN_ASSERT(!write_stepper.write_task.has_value()) { return; } + SAW_ASSERT(!write_stepper.write_task.has_value()) { return; } write_stepper.write_task = WriteTaskAndStepHelper::WriteIoTask{buffer, length, 0}; diff --git a/source/forst-io/io.h b/source/forstio/io.h similarity index 100% rename from source/forst-io/io.h rename to source/forstio/io.h diff --git a/source/forst-io/io_helpers.cpp b/source/forstio/io_helpers.cpp similarity index 100% rename from source/forst-io/io_helpers.cpp rename to source/forstio/io_helpers.cpp diff --git a/source/forst-io/io_helpers.h b/source/forstio/io_helpers.h similarity index 100% rename from source/forst-io/io_helpers.h rename to source/forstio/io_helpers.h diff --git a/source/forst-io/io_wrapper.h b/source/forstio/io_wrapper.h similarity index 100% rename from source/forst-io/io_wrapper.h rename to source/forstio/io_wrapper.h diff --git a/source/forst-io/log.cpp b/source/forstio/log.cpp similarity index 100% rename from source/forst-io/log.cpp rename to source/forstio/log.cpp diff --git a/source/forst-io/log.h b/source/forstio/log.h similarity index 100% rename from source/forst-io/log.h rename to source/forstio/log.h diff --git a/source/forst-io/message.h b/source/forstio/message.h similarity index 100% rename from source/forst-io/message.h rename to source/forstio/message.h diff --git a/source/forst-io/message_container.h b/source/forstio/message_container.h similarity index 100% rename from source/forst-io/message_container.h rename to source/forstio/message_container.h diff --git a/source/forst-io/proto_kel.h b/source/forstio/proto_kel.h similarity index 100% rename from source/forst-io/proto_kel.h rename to source/forstio/proto_kel.h diff --git a/source/forst-io/schema.h b/source/forstio/schema.h similarity index 100% rename from source/forst-io/schema.h rename to source/forstio/schema.h diff --git a/source/forst-io/stream_endian.h b/source/forstio/stream_endian.h similarity index 100% rename from source/forst-io/stream_endian.h rename to source/forstio/stream_endian.h diff --git a/source/forst-io/string_literal.h b/source/forstio/string_literal.h similarity index 86% rename from source/forst-io/string_literal.h rename to source/forstio/string_literal.h index b9759ff..2624ecd 100644 --- a/source/forst-io/string_literal.h +++ b/source/forstio/string_literal.h @@ -34,7 +34,7 @@ public: }; template -constexpr gin::StringLiteral operator""_key() { - return gin::StringLiteral{Chars..., '\0'}; +constexpr StringLiteral operator""_key() { + return StringLiteral{Chars..., '\0'}; } } // namespace saw diff --git a/source/forst-io/timer.h b/source/forstio/timer.h similarity index 100% rename from source/forst-io/timer.h rename to source/forstio/timer.h diff --git a/source/forst-io/tls/tls.cpp b/source/forstio/tls/tls.cpp similarity index 90% rename from source/forst-io/tls/tls.cpp rename to source/forstio/tls/tls.cpp index 339ad7b..ffe4f1c 100644 --- a/source/forst-io/tls/tls.cpp +++ b/source/forstio/tls/tls.cpp @@ -28,9 +28,9 @@ public: } }; -static ssize_t kelgin_tls_push_func(gnutls_transport_ptr_t p, const void *data, +static ssize_t forst_tls_push_func(gnutls_transport_ptr_t p, const void *data, size_t size); -static ssize_t kelgin_tls_pull_func(gnutls_transport_ptr_t p, void *data, size_t size); +static ssize_t forst_tls_pull_func(gnutls_transport_ptr_t p, void *data, size_t size); Tls::Tls() : impl{heap()} {} @@ -90,7 +90,7 @@ public: TlsServer::TlsServer(Own srv) : internal{std::move(srv)} {} Conveyor> TlsServer::accept() { - GIN_ASSERT(internal) { return Conveyor>{nullptr, nullptr}; } + SAW_ASSERT(internal) { return Conveyor>{nullptr, nullptr}; } return internal->accept().then([](Own stream) -> Own { /// @todo handshake @@ -117,7 +117,7 @@ public: {} void setupTurn(){ - GIN_ASSERT(stream){ + SAW_ASSERT(stream){ return; } @@ -133,7 +133,7 @@ public: void turn(){ if(stream){ // Guarantee that the receiving end is already setup - GIN_ASSERT(feeder){ + SAW_ASSERT(feeder){ return; } @@ -159,12 +159,12 @@ TlsNetworkAddress::TlsNetworkAddress(Own net_addr, const std::st : internal{std::move(net_addr)}, host_name{host_name_}, tls{tls_} {} Own TlsNetworkAddress::listen() { - GIN_ASSERT(internal) { return nullptr; } + SAW_ASSERT(internal) { return nullptr; } return heap(internal->listen()); } Conveyor> TlsNetworkAddress::connect() { - GIN_ASSERT(internal) { return Conveyor>{nullptr, nullptr}; } + SAW_ASSERT(internal) { return Conveyor>{nullptr, nullptr}; } // Helper setups auto caf = newConveyorAndFeeder>(); @@ -192,8 +192,8 @@ Conveyor> TlsNetworkAddress::connect() { gnutls_session_set_verify_cert(session, addr.c_str(), 0); gnutls_transport_set_ptr(session, reinterpret_cast(inner_stream)); - gnutls_transport_set_push_function(session, kelgin_tls_push_func); - gnutls_transport_set_pull_function(session, kelgin_tls_pull_func); + gnutls_transport_set_push_function(session, forst_tls_push_func); + gnutls_transport_set_pull_function(session, forst_tls_pull_func); // gnutls_handshake_set_timeout(session, GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT); @@ -209,7 +209,7 @@ Conveyor> TlsNetworkAddress::connect() { return caf.conveyor.attach(std::move(helper)); } -static ssize_t kelgin_tls_push_func(gnutls_transport_ptr_t p, const void *data, +static ssize_t forst_tls_push_func(gnutls_transport_ptr_t p, const void *data, size_t size) { IoStream *stream = reinterpret_cast(p); if (!stream) { @@ -224,7 +224,7 @@ static ssize_t kelgin_tls_push_func(gnutls_transport_ptr_t p, const void *data, return static_cast(length.value()); } -static ssize_t kelgin_tls_pull_func(gnutls_transport_ptr_t p, void *data, size_t size) { +static ssize_t forst_tls_pull_func(gnutls_transport_ptr_t p, void *data, size_t size) { IoStream *stream = reinterpret_cast(p); if (!stream) { return -1; diff --git a/source/forst-io/tls/tls.h b/source/forstio/tls/tls.h similarity index 100% rename from source/forst-io/tls/tls.h rename to source/forstio/tls/tls.h diff --git a/test/SConscript b/test/SConscript index 7d0198f..0d52054 100644 --- a/test/SConscript +++ b/test/SConscript @@ -10,7 +10,7 @@ dir_path = Dir('.').abspath env.test_sources = sorted(glob.glob(dir_path + "/*.cpp")) env_test = env.Clone() -env_test.Append(CPPDEFINES=['GIN_COMPILE_TEST_BINARY']) +env_test.Append(CPPDEFINES=['SAW_COMPILE_TEST_BINARY']) env.test_objects = [] env.test_sources.append(dir_path+'/suite/suite.cpp') env.test_headers = [dir_path + '/suite/suite.h'] diff --git a/test/async.cpp b/test/async.cpp index 5e9f094..b2ce8c8 100644 --- a/test/async.cpp +++ b/test/async.cpp @@ -1,10 +1,10 @@ #include "suite/suite.h" -#include "source/kelgin/async.h" +#include "source/forstio/async.h" namespace { -GIN_TEST("Async Immediate"){ - using namespace gin; +SAW_TEST("Async Immediate"){ + using namespace saw; EventLoop event_loop; WaitScope wait_scope{event_loop}; @@ -19,13 +19,13 @@ GIN_TEST("Async Immediate"){ ErrorOr error_or_number = is_number.take(); - GIN_EXPECT(!error_or_number.isError(), error_or_number.error().message()); - GIN_EXPECT(error_or_number.isValue(), "Return is not a value"); - GIN_EXPECT(error_or_number.value(), "Value is not 5"); + SAW_EXPECT(!error_or_number.isError(), error_or_number.error().message()); + SAW_EXPECT(error_or_number.isValue(), "Return is not a value"); + SAW_EXPECT(error_or_number.value(), "Value is not 5"); } -GIN_TEST("Async Adapt"){ - using namespace gin; +SAW_TEST("Async Adapt"){ + using namespace saw; EventLoop event_loop; WaitScope wait_scope{event_loop}; @@ -36,14 +36,14 @@ GIN_TEST("Async Adapt"){ ErrorOr foo = feeder_conveyor.conveyor.take(); - GIN_EXPECT(!foo.isError(), foo.error().message()); - GIN_EXPECT(foo.isValue(), "Return is not a value"); - GIN_EXPECT(foo.value() == 5, "Values not 5, but " + std::to_string(foo.value())); + SAW_EXPECT(!foo.isError(), foo.error().message()); + SAW_EXPECT(foo.isValue(), "Return is not a value"); + SAW_EXPECT(foo.value() == 5, "Values not 5, but " + std::to_string(foo.value())); } -GIN_TEST("Async Adapt Multiple"){ - using namespace gin; +SAW_TEST("Async Adapt Multiple"){ + using namespace saw; EventLoop event_loop; WaitScope wait_scope{event_loop}; @@ -54,17 +54,17 @@ GIN_TEST("Async Adapt Multiple"){ ErrorOr foo = feeder_conveyor.conveyor.take(); - GIN_EXPECT(!foo.isError(), foo.error().message()); - GIN_EXPECT(foo.isValue(), "Return is not a value"); - GIN_EXPECT(foo.value() == 5, "Values not 5, but " + std::to_string(foo.value())); + SAW_EXPECT(!foo.isError(), foo.error().message()); + SAW_EXPECT(foo.isValue(), "Return is not a value"); + SAW_EXPECT(foo.value() == 5, "Values not 5, but " + std::to_string(foo.value())); feeder_conveyor.feeder->feed(10); ErrorOr bar = feeder_conveyor.conveyor.take(); - GIN_EXPECT(!foo.isError(), bar.error().message()); - GIN_EXPECT(bar.isValue(), "Return is not a value"); - GIN_EXPECT(bar.value() == 10, "Values not 10, but " + std::to_string(bar.value())); + SAW_EXPECT(!foo.isError(), bar.error().message()); + SAW_EXPECT(bar.isValue(), "Return is not a value"); + SAW_EXPECT(bar.value() == 10, "Values not 10, but " + std::to_string(bar.value())); feeder_conveyor.feeder->feed(2); feeder_conveyor.feeder->feed(4234); @@ -72,17 +72,17 @@ GIN_TEST("Async Adapt Multiple"){ ErrorOr a = feeder_conveyor.conveyor.take(); ErrorOr b = feeder_conveyor.conveyor.take(); - GIN_EXPECT(!foo.isError(), a.error().message()); - GIN_EXPECT(a.isValue(), "Return is not a value"); - GIN_EXPECT(a.value() == 2, "Values not 2, but " + std::to_string(a.value())); + SAW_EXPECT(!foo.isError(), a.error().message()); + SAW_EXPECT(a.isValue(), "Return is not a value"); + SAW_EXPECT(a.value() == 2, "Values not 2, but " + std::to_string(a.value())); - GIN_EXPECT(!foo.isError(), b.error().message()); - GIN_EXPECT(b.isValue(), "Return is not a value"); - GIN_EXPECT(b.value() == 4234, "Values not 4234, but " + std::to_string(b.value())); + SAW_EXPECT(!foo.isError(), b.error().message()); + SAW_EXPECT(b.isValue(), "Return is not a value"); + SAW_EXPECT(b.value() == 4234, "Values not 4234, but " + std::to_string(b.value())); } -GIN_TEST("Async Conversion"){ - using namespace gin; +SAW_TEST("Async Conversion"){ + using namespace saw; EventLoop event_loop; WaitScope wait_scope{event_loop}; @@ -97,13 +97,13 @@ GIN_TEST("Async Conversion"){ ErrorOr foo = string_conveyor.take(); - GIN_EXPECT(!foo.isError(), foo.error().message()); - GIN_EXPECT(foo.isValue(), "Return is not a value"); - GIN_EXPECT(foo.value() == std::to_string(10), "Values is not 10, but " + foo.value()); + SAW_EXPECT(!foo.isError(), foo.error().message()); + SAW_EXPECT(foo.isValue(), "Return is not a value"); + SAW_EXPECT(foo.value() == std::to_string(10), "Values is not 10, but " + foo.value()); } -GIN_TEST("Async Conversion Multistep"){ - using namespace gin; +SAW_TEST("Async Conversion Multistep"){ + using namespace saw; EventLoop event_loop; WaitScope wait_scope{event_loop}; @@ -122,13 +122,13 @@ GIN_TEST("Async Conversion Multistep"){ ErrorOr foo = conveyor.take(); - GIN_EXPECT(!foo.isError(), foo.error().message()); - GIN_EXPECT(foo.isValue(), "Return is not a value"); - GIN_EXPECT(foo.value(), "Values is not true"); + SAW_EXPECT(!foo.isError(), foo.error().message()); + SAW_EXPECT(foo.isValue(), "Return is not a value"); + SAW_EXPECT(foo.value(), "Values is not true"); } -GIN_TEST("Async Scheduling"){ - using namespace gin; +SAW_TEST("Async Scheduling"){ + using namespace saw; EventLoop event_loop; WaitScope wait_scope{event_loop}; @@ -165,25 +165,25 @@ GIN_TEST("Async Scheduling"){ ErrorOr foo_10 = string_conveyor.take(); - GIN_EXPECT(!foo_10.isError(), foo_10.error().message()); - GIN_EXPECT(foo_10.isValue(), "Return is not a value"); - GIN_EXPECT(foo_10.value() == (std::string{"pre"} + std::to_string(11) + std::string{"post"}), "Values is not pre11post, but " + foo_10.value()); + SAW_EXPECT(!foo_10.isError(), foo_10.error().message()); + SAW_EXPECT(foo_10.isValue(), "Return is not a value"); + SAW_EXPECT(foo_10.value() == (std::string{"pre"} + std::to_string(11) + std::string{"post"}), "Values is not pre11post, but " + foo_10.value()); ErrorOr foo_20 = string_conveyor.take(); - GIN_EXPECT(!foo_20.isError(), foo_20.error().message()); - GIN_EXPECT(foo_20.isValue(), "Return is not a value"); - GIN_EXPECT(foo_20.value() == (std::string{"pre"} + std::to_string(22) + std::string{"post"}), "Values is not pre22post, but " + foo_20.value()); + SAW_EXPECT(!foo_20.isError(), foo_20.error().message()); + SAW_EXPECT(foo_20.isValue(), "Return is not a value"); + SAW_EXPECT(foo_20.value() == (std::string{"pre"} + std::to_string(22) + std::string{"post"}), "Values is not pre22post, but " + foo_20.value()); ErrorOr foo_30 = string_conveyor.take(); - GIN_EXPECT(!foo_30.isError(), foo_30.error().message()); - GIN_EXPECT(foo_30.isValue(), "Return is not a value"); - GIN_EXPECT(foo_30.value() == (std::string{"pre"} + std::to_string(33) + std::string{"post"}), "Values is not pre33post, but " + foo_30.value()); + SAW_EXPECT(!foo_30.isError(), foo_30.error().message()); + SAW_EXPECT(foo_30.isValue(), "Return is not a value"); + SAW_EXPECT(foo_30.value() == (std::string{"pre"} + std::to_string(33) + std::string{"post"}), "Values is not pre33post, but " + foo_30.value()); } -GIN_TEST("Async Detach"){ - using namespace gin; +SAW_TEST("Async Detach"){ + using namespace saw; EventLoop event_loop; WaitScope wait_scope{event_loop}; @@ -196,11 +196,11 @@ GIN_TEST("Async Detach"){ wait_scope.poll(); - GIN_EXPECT(num == 10, std::string{"Bad value: Expected 10, but got "} + std::to_string(num)); + SAW_EXPECT(num == 10, std::string{"Bad value: Expected 10, but got "} + std::to_string(num)); } -GIN_TEST("Async Merge"){ - using namespace gin; +SAW_TEST("Async Merge"){ + using namespace saw; EventLoop event_loop; WaitScope wait_scope{event_loop}; @@ -224,7 +224,7 @@ GIN_TEST("Async Merge"){ wait_scope.poll(); - GIN_EXPECT(!wrong_value, std::string{"Expected values 10 or 11"}); - GIN_EXPECT(elements_passed == 3, std::string{"Expected 2 passed elements, got only "} + std::to_string(elements_passed)); + SAW_EXPECT(!wrong_value, std::string{"Expected values 10 or 11"}); + SAW_EXPECT(elements_passed == 3, std::string{"Expected 2 passed elements, got only "} + std::to_string(elements_passed)); } } diff --git a/test/message.cpp b/test/message.cpp index c2ef17b..c287a2a 100644 --- a/test/message.cpp +++ b/test/message.cpp @@ -3,20 +3,20 @@ #include #include -#include "source/kelgin/message.h" -#include "source/kelgin/schema.h" +#include "source/forstio/message.h" +#include "source/forstio/schema.h" namespace { namespace schema { - using namespace gin::schema; + using namespace saw::schema; } using TestTuple = schema::Tuple; -GIN_TEST("Message Tuple"){ +SAW_TEST("Message Tuple"){ std::string test_string_1 = "banana"; - auto root = gin::heapMessageRoot(); + auto root = saw::heapMessageRoot(); auto builder = root.build(); auto uint = builder.init<0>(); uint.set(10); @@ -27,16 +27,16 @@ GIN_TEST("Message Tuple"){ auto uint_reader = reader.get<0>(); auto string_reader = reader.get<1>(); - GIN_EXPECT( uint_reader.get() == 10 && string_reader.get() == test_string_1, "wrong values"); + SAW_EXPECT( uint_reader.get() == 10 && string_reader.get() == test_string_1, "wrong values"); } using NestedTestTuple = schema::Tuple, schema::String>; -GIN_TEST("Message Tuple nested"){ +SAW_TEST("Message Tuple nested"){ std::string test_string_1 = "banana"; std::string test_string_2 = "bat"; - auto root = gin::heapMessageRoot(); + auto root = saw::heapMessageRoot(); auto builder = root.build(); auto inner_list = builder.init<0>(); auto uint = inner_list.init<0>(); @@ -53,7 +53,7 @@ GIN_TEST("Message Tuple nested"){ auto inner_string_reader = inner_reader.get<1>(); auto string_reader = root_reader.get<1>(); - GIN_EXPECT(uint_reader.get() == 20 && inner_string_reader.get() == test_string_2 && string_reader.get() == test_string_1, "wrong values"); + SAW_EXPECT(uint_reader.get() == 20 && inner_string_reader.get() == test_string_2 && string_reader.get() == test_string_1, "wrong values"); } using TestStruct = schema::Struct< @@ -62,9 +62,9 @@ using TestStruct = schema::Struct< schema::NamedMember >; -GIN_TEST("Message Struct"){ +SAW_TEST("Message Struct"){ std::string test_string = "foo"; - auto root = gin::heapMessageRoot(); + auto root = saw::heapMessageRoot(); auto builder = root.build(); auto uint = builder.init<"test_uint">(); uint.set(23); @@ -83,12 +83,12 @@ GIN_TEST("Message Struct"){ */ test_string = "foo2"; - GIN_EXPECT(uint_reader.get() == 23 && string_reader.get() != test_string && string_reader.get() == "foo" && name_reader.get() == "test_name", "Wrong values"); + SAW_EXPECT(uint_reader.get() == 23 && string_reader.get() != test_string && string_reader.get() == "foo" && name_reader.get() == "test_name", "Wrong values"); } using TestArray = schema::Array; -void arrayCheck(gin::Message::Builder builder){ +void arrayCheck(saw::Message::Builder builder){ auto one = builder.init(0); auto two = builder.init(1); auto three = builder.init(2); @@ -99,11 +99,11 @@ void arrayCheck(gin::Message::Builder builder){ auto reader = builder.asReader(); - GIN_EXPECT(reader.get(0).get() == 24 && reader.get(1).get() == 45 && reader.get(2).get(), "Wrong values"); + SAW_EXPECT(reader.get(0).get() == 24 && reader.get(1).get() == 45 && reader.get(2).get(), "Wrong values"); } -GIN_TEST("Message Array"){ - auto root = gin::heapMessageRoot(); +SAW_TEST("Message Array"){ + auto root = saw::heapMessageRoot(); auto builder = root.build(3); @@ -114,8 +114,8 @@ using TestArrayStruct = schema::Struct< schema::NamedMember >; -GIN_TEST("Message Array in Struct"){ - auto root = gin::heapMessageRoot(); +SAW_TEST("Message Array in Struct"){ + auto root = saw::heapMessageRoot(); auto builder = root.build(); diff --git a/test/proto_kel.cpp b/test/proto_kel.cpp index 49055cc..9813935 100644 --- a/test/proto_kel.cpp +++ b/test/proto_kel.cpp @@ -1,12 +1,12 @@ #include "suite/suite.h" -#include "source/kelgin/proto_kel.h" +#include "source/forstio/proto_kel.h" #include namespace { namespace schema { - using namespace gin::schema; + using namespace saw::schema; } using TestSize = schema::UInt32; @@ -23,8 +23,8 @@ using TestUnion = schema::Union< schema::NamedMember >; -GIN_TEST("Primitive Encoding"){ - using namespace gin; +SAW_TEST("Primitive Encoding"){ + using namespace saw; uint32_t value = 5; auto root = heapMessageRoot(); @@ -37,14 +37,14 @@ GIN_TEST("Primitive Encoding"){ Error error = codec.encode(root.read(), temp_buffer); - GIN_EXPECT(!error.failed(), error.message()); - GIN_EXPECT(temp_buffer.readCompositeLength() == (sizeof(value)+sizeof(msg_packet_length_t)), "Bad Size: " + std::to_string(temp_buffer.readCompositeLength())); + SAW_EXPECT(!error.failed(), error.message()); + SAW_EXPECT(temp_buffer.readCompositeLength() == (sizeof(value)+sizeof(msg_packet_length_t)), "Bad Size: " + std::to_string(temp_buffer.readCompositeLength())); constexpr size_t pkt_shift = sizeof(msg_packet_length_t); - GIN_EXPECT(temp_buffer[pkt_shift] == 5 && temp_buffer[pkt_shift+1] == 0 && temp_buffer[pkt_shift+2] == 0 && temp_buffer[pkt_shift+3] == 0, "Wrong encoded values"); + SAW_EXPECT(temp_buffer[pkt_shift] == 5 && temp_buffer[pkt_shift+1] == 0 && temp_buffer[pkt_shift+2] == 0 && temp_buffer[pkt_shift+3] == 0, "Wrong encoded values"); } -GIN_TEST("List Encoding"){ - using namespace gin; +SAW_TEST("List Encoding"){ + using namespace saw; auto root = heapMessageRoot(); auto builder = root.build(); @@ -59,13 +59,13 @@ GIN_TEST("List Encoding"){ Error error = codec.encode(root.read(), buffer); - GIN_EXPECT(!error.failed(), error.message()); - GIN_EXPECT(buffer.readCompositeLength() == 14, "Bad Size: " + std::to_string(buffer.readCompositeLength())); - GIN_EXPECT("06 00 00 00\n00 00 00 00\nbf 94 20 00\n5f ab" == buffer.toHex(), "Not equal encoding\n"+buffer.toHex()); + SAW_EXPECT(!error.failed(), error.message()); + SAW_EXPECT(buffer.readCompositeLength() == 14, "Bad Size: " + std::to_string(buffer.readCompositeLength())); + SAW_EXPECT("06 00 00 00\n00 00 00 00\nbf 94 20 00\n5f ab" == buffer.toHex(), "Not equal encoding\n"+buffer.toHex()); } -GIN_TEST("Struct Encoding"){ - using namespace gin; +SAW_TEST("Struct Encoding"){ + using namespace saw; auto root = heapMessageRoot(); auto builder = root.build(); @@ -85,14 +85,14 @@ GIN_TEST("Struct Encoding"){ Error error = codec.encode(builder.asReader(), buffer); - GIN_EXPECT(!error.failed(), error.message()); - GIN_EXPECT(buffer.readCompositeLength() == 40, "Bad Size: " + std::to_string(buffer.readCompositeLength())); - GIN_EXPECT("20 00 00 00\n00 00 00 00\n17 00 00 00\n03 00 00 00\n00 00 00 00\n66 6f 6f 09\n00 00 00 00\n00 00 00 74\n65 73 74 5f\n6e 61 6d 65" + SAW_EXPECT(!error.failed(), error.message()); + SAW_EXPECT(buffer.readCompositeLength() == 40, "Bad Size: " + std::to_string(buffer.readCompositeLength())); + SAW_EXPECT("20 00 00 00\n00 00 00 00\n17 00 00 00\n03 00 00 00\n00 00 00 00\n66 6f 6f 09\n00 00 00 00\n00 00 00 74\n65 73 74 5f\n6e 61 6d 65" == buffer.toHex(), "Not equal encoding:\n"+buffer.toHex()); } -GIN_TEST("Union Encoding"){ - using namespace gin; +SAW_TEST("Union Encoding"){ + using namespace saw; { auto root = heapMessageRoot(); auto builder = root.build(); @@ -105,9 +105,9 @@ GIN_TEST("Union Encoding"){ Error error = codec.encode(builder.asReader(), buffer); - GIN_EXPECT(!error.failed(), error.message()); - GIN_EXPECT(buffer.readCompositeLength() == 16, "Bad Size: " + std::to_string(buffer.readCompositeLength())); - GIN_EXPECT("08 00 00 00\n00 00 00 00\n00 00 00 00\n17 00 00 00" + SAW_EXPECT(!error.failed(), error.message()); + SAW_EXPECT(buffer.readCompositeLength() == 16, "Bad Size: " + std::to_string(buffer.readCompositeLength())); + SAW_EXPECT("08 00 00 00\n00 00 00 00\n00 00 00 00\n17 00 00 00" == buffer.toHex(), "Not equal encoding:\n"+buffer.toHex()); } { @@ -122,15 +122,15 @@ GIN_TEST("Union Encoding"){ Error error = codec.encode(builder.asReader(), buffer); - GIN_EXPECT(!error.failed(), error.message()); - GIN_EXPECT(buffer.readCompositeLength() == 23, "Bad Size: " + std::to_string(buffer.readCompositeLength())); - GIN_EXPECT("0f 00 00 00\n00 00 00 00\n01 00 00 00\n03 00 00 00\n00 00 00 00\n66 6f 6f" + SAW_EXPECT(!error.failed(), error.message()); + SAW_EXPECT(buffer.readCompositeLength() == 23, "Bad Size: " + std::to_string(buffer.readCompositeLength())); + SAW_EXPECT("0f 00 00 00\n00 00 00 00\n01 00 00 00\n03 00 00 00\n00 00 00 00\n66 6f 6f" == buffer.toHex(), "Not equal encoding:\n"+buffer.toHex()); } } -GIN_TEST("Tuple Decoding"){ - using namespace gin; +SAW_TEST("Tuple Decoding"){ + using namespace saw; const uint8_t buffer_raw[] = {0x06, 0, 0, 0, 0, 0, 0, 0, 0xbf, 0x94, 0x20, 0x00, 0x5f, 0xab}; RingBuffer buffer; @@ -142,18 +142,18 @@ GIN_TEST("Tuple Decoding"){ auto builder = root.build(); Error error = codec.decode(builder, buffer); - GIN_EXPECT(!error.failed(), error.message()); + SAW_EXPECT(!error.failed(), error.message()); auto reader = builder.asReader(); auto first = reader.get<0>(); auto second = reader.get<1>(); - GIN_EXPECT(first.get() == 2135231 && second.get() == 43871, "Values not correctly decoded"); + SAW_EXPECT(first.get() == 2135231 && second.get() == 43871, "Values not correctly decoded"); } -GIN_TEST("Struct Decoding"){ - using namespace gin; +SAW_TEST("Struct Decoding"){ + using namespace saw; const uint8_t buffer_raw[] = {0x20,0,0,0,0,0,0,0,0x17,0,0,0,0x03,0,0,0,0,0,0,0,0x66,0x6f,0x6f,0x09,0,0,0,0,0,0,0,0x74,0x65,0x73,0x74,0x5f,0x6e,0x61,0x6d,0x65}; RingBuffer buffer; @@ -171,12 +171,12 @@ GIN_TEST("Struct Decoding"){ auto test_uint = reader.get<"test_uint">(); auto test_name = reader.get<"test_name">(); - GIN_EXPECT(!error.failed(), error.message()); - GIN_EXPECT(foo_string.get() == "foo" && test_uint.get() == 23 && test_name.get() == "test_name", "Values not correctly decoded"); + SAW_EXPECT(!error.failed(), error.message()); + SAW_EXPECT(foo_string.get() == "foo" && test_uint.get() == 23 && test_name.get() == "test_name", "Values not correctly decoded"); } -GIN_TEST("Union Decoding"){ - using namespace gin; +SAW_TEST("Union Decoding"){ + using namespace saw; const uint8_t buffer_raw[] = {0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x6f,0x6f}; RingBuffer buffer; @@ -190,18 +190,18 @@ GIN_TEST("Union Decoding"){ Error error = codec.decode(builder, buffer); - GIN_EXPECT(!error.failed(), error.message()); - GIN_EXPECT(reader.hasAlternative<"test_string">(), "Wrong union value"); + SAW_EXPECT(!error.failed(), error.message()); + SAW_EXPECT(reader.hasAlternative<"test_string">(), "Wrong union value"); auto str_rd = reader.get<"test_string">(); - GIN_EXPECT(str_rd.get() == "foo", "Wrong value: " + std::string{str_rd.get()}); + SAW_EXPECT(str_rd.get() == "foo", "Wrong value: " + std::string{str_rd.get()}); } using TestArrayStruct = schema::Array< TestStruct >; -GIN_TEST("Array Encoding"){ - using namespace gin; +SAW_TEST("Array Encoding"){ + using namespace saw; ProtoKelCodec codec; auto root = heapMessageRoot(); @@ -222,6 +222,6 @@ GIN_TEST("Array Encoding"){ Error error = codec.encode(root.read(), buffer); - GIN_EXPECT(!error.failed(), "Error occured"); + SAW_EXPECT(!error.failed(), "Error occured"); } } diff --git a/test/suite/suite.cpp b/test/suite/suite.cpp index 8e48674..2d4af65 100644 --- a/test/suite/suite.cpp +++ b/test/suite/suite.cpp @@ -5,7 +5,7 @@ #include #include -namespace gin { +namespace saw { namespace test { TestCase* testCaseHead = nullptr; @@ -100,10 +100,10 @@ namespace test { } } -#if GIN_COMPILE_TEST_BINARY +#if SAW_COMPILE_TEST_BINARY int main() { - gin::test::TestRunner runner; + saw::test::TestRunner runner; runner.allowAll(); int rv = runner.run(); return rv<0?-1:0; diff --git a/test/suite/suite.h b/test/suite/suite.h index 73412a5..111a014 100644 --- a/test/suite/suite.h +++ b/test/suite/suite.h @@ -7,7 +7,7 @@ #include "common.h" -namespace gin { +namespace saw { namespace test { class TestRunner; class TestCase { @@ -28,15 +28,15 @@ public: }; } } -#define GIN_TEST(description) \ - class GIN_UNIQUE_NAME(TestCase) : public ::gin::test::TestCase { \ +#define SAW_TEST(description) \ + class SAW_UNIQUE_NAME(TestCase) : public ::saw::test::TestCase { \ public: \ - GIN_UNIQUE_NAME(TestCase)(): ::gin::test::TestCase(__FILE__,__LINE__,description) {} \ + SAW_UNIQUE_NAME(TestCase)(): ::saw::test::TestCase(__FILE__,__LINE__,description) {} \ void run() override; \ - }GIN_UNIQUE_NAME(testCase); \ - void GIN_UNIQUE_NAME(TestCase)::run() + }SAW_UNIQUE_NAME(testCase); \ + void SAW_UNIQUE_NAME(TestCase)::run() -#define GIN_EXPECT(expr, msg_split) \ +#define SAW_EXPECT(expr, msg_split) \ if( ! (expr) ){ \ auto msg = msg_split; \ throw std::runtime_error{std::string{msg}};\