From 87f10dad540971c4aa22d892c676dce590ca189a Mon Sep 17 00:00:00 2001 From: Amlal Date: Sat, 9 Aug 2025 21:54:20 +0200 Subject: feat: move network.hpp to net/ and working on url.hpp Signed-off-by: Amlal --- dev/lib/except/error.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dev/lib/except') diff --git a/dev/lib/except/error.hpp b/dev/lib/except/error.hpp index 6e75f16..486d2e6 100644 --- a/dev/lib/except/error.hpp +++ b/dev/lib/except/error.hpp @@ -14,7 +14,7 @@ namespace snu::except using runtime_error = std::runtime_error; using fix_error = runtime_error; using math_error = runtime_error; - using cgi_error = runtime_error; + using cgi_error = runtime_error; } // namespace snu::except #endif // _SNU_ERR_HPP \ No newline at end of file -- cgit v1.2.3 From 37bc0133c137cdf7fe62e79ac8208ec46096316e Mon Sep 17 00:00:00 2001 From: Amlal Date: Thu, 14 Aug 2025 19:15:53 +0200 Subject: feat: mk.test tool, test a header file with static asserts. Signed-off-by: Amlal --- dev/lib/except/hpptest.hpp | 9 +++++++++ dev/lib/net/url.hpp | 10 ++++++++++ tools/hpptest.py | 10 ++++++++++ 3 files changed, 29 insertions(+) create mode 100644 dev/lib/except/hpptest.hpp create mode 100755 tools/hpptest.py (limited to 'dev/lib/except') diff --git a/dev/lib/except/hpptest.hpp b/dev/lib/except/hpptest.hpp new file mode 100644 index 0000000..5277780 --- /dev/null +++ b/dev/lib/except/hpptest.hpp @@ -0,0 +1,9 @@ +#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/net/url.hpp b/dev/lib/net/url.hpp index 9a28f9b..496889c 100644 --- a/dev/lib/net/url.hpp +++ b/dev/lib/net/url.hpp @@ -50,5 +50,15 @@ namespace snu::net ss_ += in; return *this; } + + explicit operator bool() + { + return this->is_valid(); + } + + bool is_valid() + { + return ss_.size() > 0; + } }; } // namespace snu::net diff --git a/tools/hpptest.py b/tools/hpptest.py new file mode 100755 index 0000000..2cf8e9d --- /dev/null +++ b/tools/hpptest.py @@ -0,0 +1,10 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- + +import sys, os + +if __name__ == '__main__': + if len(sys.argv) == 2: + os.system(f"clang++ -std=c++20 -DSOCL_HPPTEST '-DSOCL_HPPTEST_ASSERT(x)=static_assert(x, #x)' {sys.argv[1]} -o a.out && cat {sys.argv[1]}") + print("[TEST] HEADER COMPILATION PASSES") + -- cgit v1.2.3 From 70945244a35e0e6d2a2e0f84ae83f31b9898a0ca Mon Sep 17 00:00:00 2001 From: Amlal Date: Fri, 15 Aug 2025 12:09:28 +0200 Subject: feat: new hpptest and gtest module. Other module improvements. Signed-off-by: Amlal --- README.md | 12 +++++++++--- dev/examples/fix/fix.cc | 2 +- dev/lib/core/includes.hpp | 15 +++++++++++++++ dev/lib/except/hpptest.hpp | 9 --------- dev/lib/fix/parser.hpp | 2 +- dev/lib/io/print.hpp | 19 +++++++++---------- dev/lib/net/url.hpp | 16 ++++++++-------- dev/lib/tests/gtest.hpp | 8 ++++++++ dev/lib/tests/hpptest.hpp | 22 ++++++++++++++++++++++ dev/tests/network_basic/CMakeLists.txt | 4 ++-- dev/tests/network_basic/net_test.cc | 7 ++++--- 11 files changed, 79 insertions(+), 37 deletions(-) create mode 100644 dev/lib/core/includes.hpp delete mode 100644 dev/lib/except/hpptest.hpp create mode 100644 dev/lib/tests/gtest.hpp create mode 100644 dev/lib/tests/hpptest.hpp (limited to 'dev/lib/except') diff --git a/README.md b/README.md index bdee118..c7bf8c4 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 +#include #include #include #include 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 +#include +#include +#include +#include +#include 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 in_tmp{}; + static thread_local std::basic_string 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 namespace snu::io -{ - template - inline void printv(T fmt) noexcept +{ + template + inline void print(T fmt, Args... other) noexcept { std::cout << fmt; + print(other...); } template - inline void printv(std::initializer_list fmt) noexcept + inline void print(T fmt) noexcept { std::cout << fmt; } - template - inline void print(T... fmt) noexcept + inline void print() noexcept { - (printv(fmt), ...); + std::cout << std::endl; } template inline void println(T... fmt) noexcept { - print(static_cast(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 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 + 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 #include +#include #include -#include TEST(NetworkTest, BasicNetworkUsage) { @@ -27,8 +27,9 @@ TEST(NetworkTest, BasicNetworkUsage) modem_cl.transmit(buf_dst); modem.receive(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; -- cgit v1.2.3