summaryrefslogtreecommitdiffhomepage
path: root/dev/tests/chunk_string
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-08-21 15:10:31 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-08-21 15:11:09 +0200
commit23d52c3cb72d595c971f189363c6cf9b222581c7 (patch)
treecc070f3fc9342d227e405ef78ae09ac1560800a7 /dev/tests/chunk_string
parent5966f5da72f63dcd6d6203366a996a0c1b9f16fb (diff)
feat: chunk_string: new work in progress string container.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/tests/chunk_string')
-rw-r--r--dev/tests/chunk_string/CMakeLists.txt26
-rw-r--r--dev/tests/chunk_string/chunk_test.cc30
2 files changed, 56 insertions, 0 deletions
diff --git a/dev/tests/chunk_string/CMakeLists.txt b/dev/tests/chunk_string/CMakeLists.txt
new file mode 100644
index 0000000..defa761
--- /dev/null
+++ b/dev/tests/chunk_string/CMakeLists.txt
@@ -0,0 +1,26 @@
+cmake_minimum_required(VERSION 3.27)
+project(BasicChunkUsage LANGUAGES CXX)
+
+include(FetchContent)
+FetchContent_Declare(
+ googletest
+ URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
+)
+
+# For Windows: Prevent overriding the parent project's compiler/linker settings
+set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
+FetchContent_MakeAvailable(googletest)
+
+enable_testing()
+
+add_executable(BasicChunkUsage chunk_test.cc)
+target_link_libraries(BasicChunkUsage gtest_main)
+
+set_property(TARGET BasicChunkUsage PROPERTY CXX_STANDARD 20)
+target_include_directories(BasicChunkUsage PUBLIC ../../)
+
+# FIXME: Make a pkg-config for the boost library here!
+target_include_directories(BasicChunkUsage PUBLIC /opt/homebrew/Cellar/boost/1.87.0/include)
+
+include(GoogleTest)
+gtest_discover_tests(BasicChunkUsage)
diff --git a/dev/tests/chunk_string/chunk_test.cc b/dev/tests/chunk_string/chunk_test.cc
new file mode 100644
index 0000000..e93f11d
--- /dev/null
+++ b/dev/tests/chunk_string/chunk_test.cc
@@ -0,0 +1,30 @@
+/*
+ * File: tests/net_test.cc
+ * Purpose: Network unit tests in C++
+ * Author: Amlal El Mahrouss (founder@snu.systems)
+ * Copyright 2025, Amlal El Mahrouss and SNU Systems Corp.
+ */
+
+#include <lib/io/print.hpp>
+#include <lib/tests/gtest.hpp>
+#include <lib/utility/chunk_string.hpp>
+
+TEST(ChunkTest, BasicChunkUsage)
+{
+ const std::string test_string = "HELLO, WORLD!";
+ const unsigned iterations = 1024000;
+
+ auto start = std::chrono::high_resolution_clock::now();
+
+ snu::basic_chunk_string<char> optimized;
+
+ for (unsigned i = 0; i < iterations; ++i)
+ {
+ optimized += test_string;
+ }
+
+ auto end = std::chrono::high_resolution_clock::now();
+ auto optimized_time = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
+
+ EXPECT_TRUE(optimized_time.count() < 200U);
+}