From 44e5ea10ea8d95a66e8fab60b85a0ea88287444f Mon Sep 17 00:00:00 2001 From: Mathias Lang Date: Sat, 10 Feb 2024 17:59:14 +0100 Subject: [PATCH] Enable std::string tests on all platforms --- extras/test.cpp | 3 +++ source/stdcpp/test/string.d | 27 ++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/extras/test.cpp b/extras/test.cpp index 1394590..f8b6679 100644 --- a/extras/test.cpp +++ b/extras/test.cpp @@ -8,6 +8,7 @@ *******************************************************************************/ #include +#include #include namespace stdcpp { @@ -19,6 +20,8 @@ namespace stdcpp { }; }; +template std::size_t stdcpp::test::cppSizeOf(); + template class std::list; template std::size_t stdcpp::test::cppSizeOf >(); diff --git a/source/stdcpp/test/string.d b/source/stdcpp/test/string.d index f10ec04..e551031 100644 --- a/source/stdcpp/test/string.d +++ b/source/stdcpp/test/string.d @@ -5,16 +5,21 @@ *******************************************************************************/ module stdcpp.test.string; + +import stdcpp.test.base; import stdcpp.string; -version (CppRuntime_Gcc) + +/// Test that the sizes matches +unittest +{ + assert(cppSizeOf!(std_string) == std_string.sizeof); +} + +unittest { - unittest - { - auto a = std_string("hello"); - a.push_back('a'); - assert(a.size() == 6); - assert(std_string.sizeof == 32); - // verifying small string optimization - assert(a.capacity == 15); - } -} \ No newline at end of file + auto a = std_string("hello"); + a.push_back('a'); + assert(a.size() == 6); + // verifying small string optimization + assert(a.capacity == 15); +}