First commit.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
#include "pch.h"
|
||||
#include "catch.hpp"
|
||||
|
||||
|
||||
#include "BeastServer.hpp"
|
||||
|
||||
using namespace piddle;
|
||||
|
||||
TEST_CASE( "BeastServer shutodwn", "[beastServerShutdown]" ) {
|
||||
|
||||
auto const address = boost::asio::ip::make_address("0.0.0.0");
|
||||
auto const port = 8081;
|
||||
std::string doc_root = "/bad";
|
||||
auto const threads = 3;
|
||||
|
||||
auto server = std::make_shared<BeastServer>(
|
||||
address,port,doc_root.c_str(),threads);
|
||||
server->RunInBackground();
|
||||
sleep(3);
|
||||
server->Stop();
|
||||
server->Join();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
cmake_minimum_required(VERSION 3.19.0)
|
||||
project(piddletest VERSION 0.1.0)
|
||||
|
||||
|
||||
# specify the C++ standard
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
set (CMAKE_CXX_FLAGS "-Wno-psabi -fsanitize=address -static-libasan")
|
||||
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
|
||||
|
||||
|
||||
include(CTest)
|
||||
enable_testing()
|
||||
|
||||
|
||||
|
||||
|
||||
include(FindPkgConfig)
|
||||
|
||||
|
||||
pkg_check_modules(SYSTEMD "systemd")
|
||||
if(!SYSTEMD_FOUND)
|
||||
message(ERROR "libsystemd-dev package not installed.")
|
||||
else()
|
||||
message(STATUS "SYSTEMD_LIBRARIES: ${SYSTEMD_LIBRARIES}")
|
||||
message(STATUS "SYSTEMD_INCLUDE_DIRS: ${SYSTEMD_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
|
||||
pkg_check_modules(LILV_0 "lilv-0")
|
||||
if(!LILV_0_FOUND)
|
||||
message(ERROR "lilv-0 package not installed.")
|
||||
else()
|
||||
message(STATUS "LILV_0_LIBRARIES: ${LILV_0_LIBRARIES}")
|
||||
message(STATUS "LILV_0_INCLUDE_DIRS: ${LILV_0_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
pkg_check_modules(JACK "jack")
|
||||
|
||||
add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
|
||||
add_executable(piddletest main.cpp pch.h UriTest.cpp JsonTest.cpp
|
||||
|
||||
|
||||
../src/Uri.cpp ../src/Uri.hpp ../src/HtmlHelper.cpp ../src/HtmlHelper.hpp BeastServerTest.cpp
|
||||
../src/BeastServer.cpp ../src/BeastServer.hpp ../src/json.hpp ../src/json.cpp
|
||||
../src/Lv2Host.cpp ../src/Lv2Host.hpp
|
||||
../src/Lv2Log.hpp ../src/Lv2Log.cpp
|
||||
../src/PluginType.hpp ../src/PluginType.cpp
|
||||
../src/Lv2Effect.hpp ../src/Lv2Effect.cpp
|
||||
../src/Lv2PedalBoard.hpp ../src/Lv2PedalBoard.cpp
|
||||
|
||||
../src/MapFeature.hpp ../src/MapFeature.cpp
|
||||
../src/LogFeature.hpp ../src/LogFeature.cpp
|
||||
../src/Worker.hpp ../src/Worker.cpp
|
||||
../src/OptionsFeature.hpp ../src/OptionsFeature.cpp
|
||||
../src/asan_options.cpp
|
||||
|
||||
../src/Units.hpp ../src/Units.cpp
|
||||
|
||||
|
||||
Lv2Test.cpp
|
||||
|
||||
)
|
||||
target_precompile_headers(piddletest PRIVATE pch.h
|
||||
)
|
||||
target_link_libraries(piddletest PUBLIC
|
||||
pthread atomic
|
||||
${LILV_0_LIBRARIES}
|
||||
${JACK_LIBRARIES}
|
||||
${SYSTEMD_LIBRARIES}
|
||||
)
|
||||
|
||||
target_include_directories(piddletest PRIVATE
|
||||
${LILV_0_INCLUDE_DIRS} ${JACK_INCLUDE_DIRS} ${SYSTEMD_INCLUDE_DIRS}
|
||||
"../src"
|
||||
)
|
||||
|
||||
#target_link_libraries(Piddle boost_system)
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
#include "pch.h"
|
||||
#include "catch.hpp"
|
||||
#include <sstream>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
|
||||
#include <json.hpp>
|
||||
|
||||
using namespace piddle;
|
||||
|
||||
class JsonTestTarget {
|
||||
private:
|
||||
JsonTestTarget(const JsonTestTarget&) {} // hide copy constructor.
|
||||
JsonTestTarget& operator=(const JsonTestTarget&) { return *this;} // hide assignment.
|
||||
public:
|
||||
JsonTestTarget() // make sure reading works without a default cosntructor.
|
||||
{
|
||||
}
|
||||
bool operator==(const JsonTestTarget &other) const
|
||||
{
|
||||
return this->int_ == other.int_
|
||||
&& this->float_ == other.float_
|
||||
&& this->double_ == other.double_
|
||||
&& this->string_ == other.string_
|
||||
&& std::equal(this->ints_.begin(),this->ints_.end(), other.ints_.begin(),other.ints_.end())
|
||||
&& std::equal(this->strings_.begin(),this->strings_.end(), other.strings_.begin(),other.strings_.end())
|
||||
;
|
||||
|
||||
}
|
||||
public:
|
||||
int int_ = 1;
|
||||
float float_ = 3;
|
||||
double double_ = 4;
|
||||
|
||||
public:
|
||||
std::string string_{"5"};
|
||||
|
||||
std::vector<int> ints_ { 1,2,3,4,5};
|
||||
std::vector<std::string> strings_ { "a","b","c","d"};
|
||||
std::vector<std::vector<int> > compound_array_ { { 1,2},{3},{4,5,6},{9}};
|
||||
|
||||
public:
|
||||
static json_map::storage_type<JsonTestTarget> jmap;
|
||||
|
||||
|
||||
public:
|
||||
JsonTestTarget(json_reader& reader)
|
||||
{
|
||||
#ifdef JUNK
|
||||
while (true)
|
||||
{
|
||||
const char*name = reader.read_member_name();
|
||||
if (name == nullptr)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
json_map::storage_type<JsonTestTarget> JsonTestTarget::jmap {{
|
||||
//json_map::reference("char_", &JsonTestTarget::char_),
|
||||
json_map::reference("int", &JsonTestTarget::int_),
|
||||
json_map::reference("floatt", &JsonTestTarget::float_),
|
||||
json_map::reference("double", &JsonTestTarget::double_),
|
||||
json_map::reference("ints", &JsonTestTarget::ints_),
|
||||
json_map::reference("string", &JsonTestTarget::string_),
|
||||
json_map::reference("strings", &JsonTestTarget::strings_),
|
||||
json_map::reference("compoundarray", &JsonTestTarget::compound_array_),
|
||||
}};
|
||||
|
||||
|
||||
|
||||
TEST_CASE( "json write", "[json_write_test]" ) {
|
||||
std::stringstream os;
|
||||
json_writer writer { os };
|
||||
|
||||
JsonTestTarget testTarget;
|
||||
|
||||
writer.write(testTarget);
|
||||
|
||||
std::cout << os.str();
|
||||
}
|
||||
|
||||
static std::string get_json()
|
||||
{
|
||||
std::stringstream os;
|
||||
json_writer writer { os };
|
||||
|
||||
JsonTestTarget testTarget;
|
||||
|
||||
writer.write(testTarget);
|
||||
return os.str();
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE( "json read", "[json_read_test]" ) {
|
||||
|
||||
JsonTestTarget source;
|
||||
source.ints_ = { 1,7,4};
|
||||
source.string_ = "xyz";
|
||||
source.double_ = 99483.1837;
|
||||
|
||||
std::stringstream os;
|
||||
json_writer writer(os);
|
||||
writer.write(source);
|
||||
std::string json = os.str();
|
||||
|
||||
std::stringstream input (json);
|
||||
json_reader reader { input };
|
||||
|
||||
JsonTestTarget dest;
|
||||
reader.read(&dest);
|
||||
REQUIRE(reader.is_complete());
|
||||
|
||||
REQUIRE( source == dest);
|
||||
|
||||
|
||||
JsonTestTarget *pDest;
|
||||
std::stringstream input2(json);
|
||||
json_reader reader2 { input2};
|
||||
reader2.read(&pDest);
|
||||
|
||||
|
||||
//JsonTestTarget *testTarget = reader.read_object<JsonTestTarget>();
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE( "json smart ptrs", "[json_smart_ptrs]" ) {
|
||||
std::string json =get_json();
|
||||
|
||||
|
||||
{
|
||||
std::unique_ptr<JsonTestTarget> uniquePtr;
|
||||
std::stringstream input(json);
|
||||
json_reader reader { input };
|
||||
reader.read(&uniquePtr);
|
||||
}
|
||||
{
|
||||
std::shared_ptr<JsonTestTarget> sharedPtr;
|
||||
std::stringstream input(json);
|
||||
json_reader reader { input };
|
||||
reader.read(&sharedPtr);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "pch.h"
|
||||
#include "catch.hpp"
|
||||
#include <string>
|
||||
#include "Lv2Host.hpp"
|
||||
|
||||
using namespace piddle;
|
||||
|
||||
TEST_CASE( "Lv2 Plugins", "[lv2_plugins]" ) {
|
||||
|
||||
Lv2Host lv2Host;
|
||||
|
||||
lv2Host.Load();
|
||||
|
||||
|
||||
{
|
||||
json_writer writer (std::cerr);
|
||||
writer.write((lv2Host.GetPlugins()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE( "Lv2 UI Plugins", "[lv2_ui_plugins]" ) {
|
||||
|
||||
Lv2Host lv2Host;
|
||||
|
||||
lv2Host.Load();
|
||||
|
||||
{
|
||||
json_writer writer (std::cerr);
|
||||
writer.write((lv2Host.GetUiPlugins()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE( "Lv2 Classes Plugins", "[lv2_classes]" ) {
|
||||
|
||||
Lv2Host lv2Host;
|
||||
|
||||
lv2Host.Load();
|
||||
|
||||
auto rootPlugin = lv2Host.GetLv2PluginClass();
|
||||
{
|
||||
json_writer writer (std::cerr);
|
||||
writer.write(rootPlugin);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
#include "pch.h"
|
||||
#include "catch.hpp"
|
||||
#include <Uri.hpp>
|
||||
#include <string>
|
||||
|
||||
using namespace piddle;
|
||||
|
||||
TEST_CASE( "uri test", "[uri]" ) {
|
||||
|
||||
uri t("http://user@authority/path?q1=1&q2=2#fragment");
|
||||
|
||||
REQUIRE( t.scheme() == std::string("http") );
|
||||
REQUIRE( t.user() == std::string("user") );
|
||||
REQUIRE( t.authority() == std::string("authority") );
|
||||
REQUIRE( t.path() == std::string("/path") );
|
||||
|
||||
REQUIRE( t.segment_count() == 1);
|
||||
REQUIRE( t.segment(0) == std::string("path") );
|
||||
REQUIRE( t.is_relative() == false );
|
||||
REQUIRE( t.fragment() == std::string("fragment") );
|
||||
|
||||
REQUIRE( t.query_count() == 2);
|
||||
REQUIRE( t.query("q1") == "1");
|
||||
REQUIRE( t.query("q2") == "2");
|
||||
REQUIRE( t.query("q3") == "");
|
||||
|
||||
REQUIRE( t.query(0) == query_segment("q1","1"));
|
||||
REQUIRE( t.query(1) == query_segment("q2","2"));
|
||||
|
||||
t.set("/");
|
||||
REQUIRE( t.scheme() == "" );
|
||||
REQUIRE( t.user() == "");
|
||||
REQUIRE( t.authority() == "");
|
||||
REQUIRE( t.path() == std::string("/") );
|
||||
|
||||
REQUIRE( t.segment_count() == 0);
|
||||
REQUIRE( t.is_relative() == false );
|
||||
REQUIRE( t.fragment() == "");
|
||||
|
||||
REQUIRE( t.query_count() == 0);
|
||||
REQUIRE( t.query("q1") == "");
|
||||
|
||||
t.set("");
|
||||
REQUIRE( t.scheme() == "" );
|
||||
REQUIRE( t.user() == "");
|
||||
REQUIRE( t.authority() == "");
|
||||
REQUIRE( t.path() == std::string("") );
|
||||
|
||||
REQUIRE( t.segment_count() == 0);
|
||||
REQUIRE( t.is_relative() == true );
|
||||
REQUIRE( t.fragment() == "");
|
||||
|
||||
REQUIRE( t.query_count() == 0);
|
||||
REQUIRE( t.query("q1") == "");
|
||||
|
||||
t.set("a");
|
||||
REQUIRE( t.scheme() == "" );
|
||||
REQUIRE( t.user() == "");
|
||||
REQUIRE( t.authority() == "");
|
||||
REQUIRE( t.path() == std::string("a") );
|
||||
|
||||
REQUIRE( t.segment_count() == 1);
|
||||
REQUIRE( t.segment(0) == "a");
|
||||
REQUIRE( t.is_relative() == true );
|
||||
REQUIRE( t.fragment() == "");
|
||||
|
||||
REQUIRE( t.query_count() == 0);
|
||||
REQUIRE( t.query("q1") == "");
|
||||
|
||||
t.set("a/b#c");
|
||||
REQUIRE( t.is_relative() == true);
|
||||
REQUIRE( t.segment_count() == 2);
|
||||
REQUIRE( t.segment(0) == "a");
|
||||
REQUIRE( t.segment(1) == "b");
|
||||
REQUIRE( t.fragment() == "c");
|
||||
|
||||
t.set("/a/b#c");
|
||||
REQUIRE( t.is_relative() == false);
|
||||
REQUIRE( t.segment_count() == 2);
|
||||
REQUIRE( t.segment(0) == "a");
|
||||
REQUIRE( t.segment(1) == "b");
|
||||
REQUIRE( t.fragment() == "c");
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "pch.h"
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch/catch.hpp>
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
// Diagnostic type used to report calculated type T in an error message.
|
||||
template <typename T> class TypeDisplay;
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <string_view>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <cstdlib>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <boost/beast/http.hpp>
|
||||
Reference in New Issue
Block a user