diff options
| author | Amlal <amlal@nekernel.org> | 2025-08-15 12:09:28 +0200 |
|---|---|---|
| committer | Amlal <amlal@nekernel.org> | 2025-08-15 12:09:28 +0200 |
| commit | 70945244a35e0e6d2a2e0f84ae83f31b9898a0ca (patch) | |
| tree | 2bf642b31c914a36c36f10b20ea5189ca3c47c09 | |
| parent | 37bc0133c137cdf7fe62e79ac8208ec46096316e (diff) | |
feat: new hpptest and gtest module. Other module improvements.
Signed-off-by: Amlal <amlal@nekernel.org>
| -rw-r--r-- | README.md | 12 | ||||
| -rw-r--r-- | dev/examples/fix/fix.cc | 2 | ||||
| -rw-r--r-- | dev/lib/core/includes.hpp | 15 | ||||
| -rw-r--r-- | dev/lib/except/hpptest.hpp | 9 | ||||
| -rw-r--r-- | dev/lib/fix/parser.hpp | 2 | ||||
| -rw-r--r-- | dev/lib/io/print.hpp | 19 | ||||
| -rw-r--r-- | dev/lib/net/url.hpp | 16 | ||||
| -rw-r--r-- | dev/lib/tests/gtest.hpp | 8 | ||||
| -rw-r--r-- | dev/lib/tests/hpptest.hpp | 22 | ||||
| -rw-r--r-- | dev/tests/network_basic/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | dev/tests/network_basic/net_test.cc | 7 |
11 files changed, 79 insertions, 37 deletions
@@ -6,9 +6,15 @@ A C++ library with additional modules for your C++ SDLC. -## Getting Started: +## Requirements: -Here is an example of how snu::opt works. +- Boost C++ libraries (https://www.boost.org/) +- Clang (https://clang.llvm.org/) +- Git (https://git-scm.com/) + +## Examples: + +### Logic Module (Option container) ```cpp #include <lib/logic/opt.hpp> @@ -23,4 +29,4 @@ int main(int argc, char** argv) } ``` -##### (c) 2025 SNU Systems, Corp.
\ No newline at end of file +##### (c) 2025 SNU Systems, Corp. diff --git a/dev/examples/fix/fix.cc b/dev/examples/fix/fix.cc index 3656c0c..ce48186 100644 --- a/dev/examples/fix/fix.cc +++ b/dev/examples/fix/fix.cc @@ -4,7 +4,7 @@ licensed under the MIT license */ -#include <lib/fix/network.hpp> +#include <lib/net/network.hpp> #include <lib/fix/parser.hpp> #include <iostream> #include <unistd.h> diff --git a/dev/lib/core/includes.hpp b/dev/lib/core/includes.hpp new file mode 100644 index 0000000..b516e5f --- /dev/null +++ b/dev/lib/core/includes.hpp @@ -0,0 +1,15 @@ +/* + * File: core/includes.hpp + * Purpose: Core includes for the SOCL library. + * Author: Amlal El Mahrouss (founder@snu.systems) + * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. + */ + +#pragma once + +#include <boost/core/nvp.hpp> +#include <boost/core/demangle.hpp> +#include <boost/core/null_deleter.hpp> +#include <memory> +#include <utility> +#include <filesystem> diff --git a/dev/lib/except/hpptest.hpp b/dev/lib/except/hpptest.hpp deleted file mode 100644 index 5277780..0000000 --- a/dev/lib/except/hpptest.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -/// @note Place your static asserts here, for hpptest.py! -#ifdef SOCL_HPPTEST -SOCL_HPPTEST_ASSERT(true); -SOCL_HPPTEST_ASSERT(1 + 1 == 2); -#endif - -/// @brief This header file is meant to be a tutorial on how to use mk.test and its macro framework. diff --git a/dev/lib/fix/parser.hpp b/dev/lib/fix/parser.hpp index 0f2287e..8181359 100644 --- a/dev/lib/fix/parser.hpp +++ b/dev/lib/fix/parser.hpp @@ -159,7 +159,7 @@ namespace snu::fix if (in.empty()) return ret; - thread_local std::basic_string<char_type> in_tmp{}; + static thread_local std::basic_string<char_type> in_tmp{}; in_tmp.reserve(in.size()); diff --git a/dev/lib/io/print.hpp b/dev/lib/io/print.hpp index 36192c4..eb425c1 100644 --- a/dev/lib/io/print.hpp +++ b/dev/lib/io/print.hpp @@ -13,31 +13,30 @@ #include <ostream> namespace snu::io -{ - template <typename T> - inline void printv(T fmt) noexcept +{ + template <typename T, typename... Args> + inline void print(T fmt, Args... other) noexcept { std::cout << fmt; + print(other...); } template <typename T> - inline void printv(std::initializer_list<T> fmt) noexcept + inline void print(T fmt) noexcept { std::cout << fmt; } - template <typename... T> - inline void print(T... fmt) noexcept + inline void print() noexcept { - (printv(fmt), ...); + std::cout << std::endl; } template <typename... T> inline void println(T... fmt) noexcept { - print(static_cast<T>(fmt)...); - std::cout << std::endl; + print(fmt...); } } // namespace snu::io -#endif // ifndef _SNU_PRINT_HPP
\ No newline at end of file +#endif // ifndef _SNU_PRINT_HPP diff --git a/dev/lib/net/url.hpp b/dev/lib/net/url.hpp index 496889c..f6dba95 100644 --- a/dev/lib/net/url.hpp +++ b/dev/lib/net/url.hpp @@ -51,14 +51,14 @@ namespace snu::net return *this; } - explicit operator bool() - { - return this->is_valid(); - } + explicit operator bool() + { + return this->is_valid(); + } - bool is_valid() - { - return ss_.size() > 0; - } + bool is_valid() + { + return ss_.size() > 0; + } }; } // namespace snu::net diff --git a/dev/lib/tests/gtest.hpp b/dev/lib/tests/gtest.hpp new file mode 100644 index 0000000..14474c0 --- /dev/null +++ b/dev/lib/tests/gtest.hpp @@ -0,0 +1,8 @@ +/* + * File: tests/gtest.hpp + * Purpose: Google Test wrapper for the SOCL library. + * Author: Amlal El Mahrouss (founder@snu.systems) + * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. + */ + +#include <gtest/gtest.h> diff --git a/dev/lib/tests/hpptest.hpp b/dev/lib/tests/hpptest.hpp new file mode 100644 index 0000000..4c99ce6 --- /dev/null +++ b/dev/lib/tests/hpptest.hpp @@ -0,0 +1,22 @@ +/* + * File: tests/hpptest.hpp + * Purpose: HPP Test wrapper for the SOCL library. + * Author: Amlal El Mahrouss (founder@snu.systems) + * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp. + */ + +#pragma once + + +#ifdef SOCL_HPPTEST +namespace snu::hpptest +{ + typedef bool condition_type; + + template <condition_type expr = true> + consteval inline void must_pass() + { + SOCL_HPPTEST_ASSERT(expr); + } +} // namespace snu::hpptest +#endif diff --git a/dev/tests/network_basic/CMakeLists.txt b/dev/tests/network_basic/CMakeLists.txt index 9e0fc6b..a5704fc 100644 --- a/dev/tests/network_basic/CMakeLists.txt +++ b/dev/tests/network_basic/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.10) -project(SOCLTests) +cmake_minimum_required(VERSION 3.28) +project(SOCLTests LANGUAGES CXX) include(FetchContent) FetchContent_Declare( diff --git a/dev/tests/network_basic/net_test.cc b/dev/tests/network_basic/net_test.cc index 9423fe7..634048e 100644 --- a/dev/tests/network_basic/net_test.cc +++ b/dev/tests/network_basic/net_test.cc @@ -7,8 +7,8 @@ #include <lib/net/network.hpp> #include <lib/io/print.hpp> +#include <lib/tests/gtest.hpp> #include <cstring> -#include <gtest/gtest.h> TEST(NetworkTest, BasicNetworkUsage) { @@ -27,8 +27,9 @@ TEST(NetworkTest, BasicNetworkUsage) modem_cl.transmit(buf_dst); modem.receive<char*>(buf, buf_dst.size()); - snu::io::println<>(buf); - snu::io::println<>(buf_dst); + snu::io::print(buf_dst); + snu::io::print(buf); + snu::io::print(); delete[] buf; buf = nullptr; |
