From 9bee682ec1157090b0b1dbf5b482eddedcc2b3c6 Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Thu, 22 Oct 2026 16:17:01 +1100 Subject: [PATCH 01/22] 1.11.2-alpha1 --- CHANGES.md | 6 ++++++ NEWS.md | 1 + include/stlsoft/stlsoft.h | 11 ++++++----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f4a527ce1..40a1bc4f8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,12 @@ # STLSoft - CHANGES +## 1.11.2-alpha1 - 25th October 2026 + +* testing: + * applies xTests' null-ptr macros; + + ## 1.11.1 - 21st October 2026 * Consolidates **1.11.1-alpha1** through **1.11.1-rc10** (20th February 2024 – 20th October 2026); diff --git a/NEWS.md b/NEWS.md index f010be404..cccc35113 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,7 @@ | Date | News Item | Details | | ------------------- | ----------------------------------- | ------- | +| 25th October 2026 | 1.11.2-alpha1 | xTests' null-ptr macros; | | 21st October 2026 | Release of [STLSoft 1.11.1](https://github.com/synesissoftware/STLSoft/releases/tag/1.11.1) | **1.11.1-alpha1** through **1.11.1-rc10**: process and path APIs; Resizeable Buffer concept; `module` renamed `dl_module`; CI and docs | | 20th October 2026 | Release of [STLSoft 1.11.1-rc10](https://github.com/synesissoftware/STLSoft/releases/tag/1.11.1-rc10) | Resizeable Buffer concept & traits `rb` hardening; **CONCEPTS.md**; `get_module_directory(rb)`; `resizeable_buffer_resize` docs; example **by_concept/resizeable_buffer**; C1–C5 `rb` / `dir_end` fixes; unixstl strip-all `remove_dir_end`; `readdir_sequence` no-exception soft-fail; full-path OOB size fix; `resizeable_buffer_resize` default-arg `resize` (G5); scratch **test.scratch.versions.format** (`std::format`) | | 18th October 2026 | Release of [STLSoft 1.11.1-rc9](https://github.com/synesissoftware/STLSoft/releases/tag/1.11.1-rc9) | `get_current_process_path()` (+ resizeable-buffer overloads) on **unixstl** / **winstl** `system_traits` with component tests; zero-first optional buffers; **unixstl** `wchar_t` path classification and separators; `path_str_*`; wide `get_home_directory()` and `get_environment_variable()`; `\pre` normalised to bare exprs with `nullptr`; subproject version bumps | diff --git a/include/stlsoft/stlsoft.h b/include/stlsoft/stlsoft.h index 552c711f4..4489c2e76 100644 --- a/include/stlsoft/stlsoft.h +++ b/include/stlsoft/stlsoft.h @@ -5,7 +5,7 @@ * and platform discriminations, and definitions of types. * * Created: 15th January 2002 - * Updated: 21st October 2026 + * Updated: 25th October 2026 * * Home: http://stlsoft.org/ * @@ -55,8 +55,8 @@ #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION # define STLSOFT_VER_STLSOFT_H_STLSOFT_MAJOR 3 # define STLSOFT_VER_STLSOFT_H_STLSOFT_MINOR 57 -# define STLSOFT_VER_STLSOFT_H_STLSOFT_REVISION 22 -# define STLSOFT_VER_STLSOFT_H_STLSOFT_EDIT 612 +# define STLSOFT_VER_STLSOFT_H_STLSOFT_REVISION 23 +# define STLSOFT_VER_STLSOFT_H_STLSOFT_EDIT 613 #else /* ? STLSOFT_DOCUMENTATION_SKIP_SECTION */ /* # include "./internal/doxygen_defs.h" */ #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -426,12 +426,13 @@ # define _STLSOFT_VER_1_11_1_RC9 0x010B01C9 /*!< Version 1.11.1 rc 9 (18th October 2026) */ # define _STLSOFT_VER_1_11_1_RC10 0x010B01CA /*!< Version 1.11.1 rc 10 (20th October 2026) */ # define _STLSOFT_VER_1_11_1 0x010B01FF /*!< Version 1.11.1 (21st October 2026) */ +# define _STLSOFT_VER_1_11_2_A1 0x010B0241 /*!< Version 1.11.2 alpha 1 (25th October 2026) */ #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ #define _STLSOFT_VER_MAJOR 1 #define _STLSOFT_VER_MINOR 11 -#define _STLSOFT_VER_PATCH 1 -#define _STLSOFT_VER_RELSTATUS 0xFF +#define _STLSOFT_VER_PATCH 2 +#define _STLSOFT_VER_RELSTATUS 0x41 #define _STLSOFT_VER \ (0\ From a5be343810e2706fef75a96860736903634fc3f3 Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Thu, 22 Oct 2026 16:26:02 +1100 Subject: [PATCH 02/22] test(integer_to_string): share one short performance schedule Hoist the per-section warmup, loop, and iteration counts to one shared schedule of 2 warmups, 1 loop, and 1,000,000 iterations. The previous 4 x 100 x 1,000,000 schedule was repeated in every section and took about ten minutes. --- .../conversion/integer_to_string/main.cpp | 66 +++---------------- 1 file changed, 9 insertions(+), 57 deletions(-) diff --git a/test/performance/stlsoft/conversion/integer_to_string/main.cpp b/test/performance/stlsoft/conversion/integer_to_string/main.cpp index d49505f36..ba2bb3fef 100644 --- a/test/performance/stlsoft/conversion/integer_to_string/main.cpp +++ b/test/performance/stlsoft/conversion/integer_to_string/main.cpp @@ -4,7 +4,7 @@ * Purpose: Perf-test for `stlsoft::integer_to_string<>`. * * Created: 29th October 2016 - * Updated: 30th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -412,6 +412,14 @@ int main(int argc, char* argv[]) size_t total = 0; + /* One warmup pass plus one measured pass of 1,000,000 values. The + * previous 4 x 100 x 1,000,000 schedule repeated that set and took + * about ten minutes. + */ + Warmups const warmups(2); + Loops const loops(1); + Iterations const iterations(1000000); + perf_maybe_emit_groupgaps_banner(stdout); /* Gap between API / base-family sections. */ @@ -419,10 +427,6 @@ int main(int argc, char* argv[]) fprintf(stdout, "std::to_string() - base 0\n"); { - Warmups warmups(4); - Loops loops(100); - Iterations iterations(1000000); - total += execute_xtos(warmups, loops, iterations, stopwatch, 0); total += execute_xtos< signed short>(warmups, loops, iterations, stopwatch, 0); @@ -441,10 +445,6 @@ int main(int argc, char* argv[]) fprintf(stdout, "std::to_string() - base max() - N\n"); { - Warmups warmups(4); - Loops loops(100); - Iterations iterations(1000000); - #define N (500000) total += execute_xtos(warmups, loops, iterations, stopwatch, std::numeric_limits::max() - N); total += execute_xtos< signed int>(warmups, loops, iterations, stopwatch, std::numeric_limits::min() - N); @@ -466,10 +466,6 @@ int main(int argc, char* argv[]) fprintf(stdout, "snprintf() - base 0\n"); { - Warmups warmups(4); - Loops loops(100); - Iterations iterations(1000000); - total += execute_printf(warmups, loops, iterations, stopwatch, 0); total += execute_printf< signed short>(warmups, loops, iterations, stopwatch, 0); @@ -488,10 +484,6 @@ int main(int argc, char* argv[]) fprintf(stdout, "snprintf() - base max() - N\n"); { - Warmups warmups(4); - Loops loops(100); - Iterations iterations(1000000); - #define N (500000) total += execute_printf(warmups, loops, iterations, stopwatch, std::numeric_limits::max() - N); total += execute_printf< signed int>(warmups, loops, iterations, stopwatch, std::numeric_limits::min() - N); @@ -513,10 +505,6 @@ int main(int argc, char* argv[]) fprintf(stdout, "integer_to_decimal_string() - base 0\n"); { - Warmups warmups(4); - Loops loops(100); - Iterations iterations(1000000); - total += execute_dec(warmups, loops, iterations, stopwatch, 0); total += execute_dec< signed char>(warmups, loops, iterations, stopwatch, 0); @@ -538,10 +526,6 @@ int main(int argc, char* argv[]) fprintf(stdout, "integer_to_decimal_string() - base max() - N\n"); { - Warmups warmups(4); - Loops loops(100); - Iterations iterations(1000000); - #define N (500000) total += execute_dec(warmups, loops, iterations, stopwatch, std::numeric_limits::max() - N); total += execute_dec< signed int>(warmups, loops, iterations, stopwatch, std::numeric_limits::min() - N); @@ -563,10 +547,6 @@ int main(int argc, char* argv[]) fprintf(stdout, "integer_to_octal_string() - base 0\n"); { - Warmups warmups(4); - Loops loops(100); - Iterations iterations(1000000); - total += execute_oct(warmups, loops, iterations, stopwatch, 0); total += execute_oct< signed char>(warmups, loops, iterations, stopwatch, 0); @@ -589,10 +569,6 @@ int main(int argc, char* argv[]) { - Warmups warmups(4); - Loops loops(100); - Iterations iterations(1000000); - #define N (500000) total += execute_oct(warmups, loops, iterations, stopwatch, std::numeric_limits::max() - N); total += execute_oct< signed int>(warmups, loops, iterations, stopwatch, std::numeric_limits::min() - N); @@ -613,10 +589,6 @@ int main(int argc, char* argv[]) fprintf(stdout, "integer_to_hexadecimal_string() - base 0\n"); { - Warmups warmups(4); - Loops loops(100); - Iterations iterations(1000000); - total += execute_hex(warmups, loops, iterations, stopwatch, 0); total += execute_hex< signed char>(warmups, loops, iterations, stopwatch, 0); @@ -638,10 +610,6 @@ int main(int argc, char* argv[]) fprintf(stdout, "integer_to_hexadecimal_string() - base max() - N\n"); { - Warmups warmups(4); - Loops loops(100); - Iterations iterations(1000000); - #define N (500000) total += execute_hex(warmups, loops, iterations, stopwatch, std::numeric_limits::max() - N); total += execute_hex< signed int>(warmups, loops, iterations, stopwatch, std::numeric_limits::min() - N); @@ -663,10 +631,6 @@ int main(int argc, char* argv[]) fprintf(stdout, "integer_to_base32_string() - base 0\n"); { - Warmups warmups(4); - Loops loops(100); - Iterations iterations(1000000); - total += execute_b32(warmups, loops, iterations, stopwatch, 0); total += execute_b32< signed char>(warmups, loops, iterations, stopwatch, 0); @@ -688,10 +652,6 @@ int main(int argc, char* argv[]) fprintf(stdout, "integer_to_base32_string() - base max() - N\n"); { - Warmups warmups(4); - Loops loops(100); - Iterations iterations(1000000); - #define N (500000) total += execute_b32(warmups, loops, iterations, stopwatch, std::numeric_limits::max() - N); total += execute_b32< signed int>(warmups, loops, iterations, stopwatch, std::numeric_limits::min() - N); @@ -713,10 +673,6 @@ int main(int argc, char* argv[]) fprintf(stdout, "integer_to_base36_string() - base 0\n"); { - Warmups warmups(4); - Loops loops(100); - Iterations iterations(1000000); - total += execute_b36(warmups, loops, iterations, stopwatch, 0); total += execute_b36< signed char>(warmups, loops, iterations, stopwatch, 0); @@ -738,10 +694,6 @@ int main(int argc, char* argv[]) fprintf(stdout, "integer_to_base36_string() - base max() - N\n"); { - Warmups warmups(4); - Loops loops(100); - Iterations iterations(1000000); - #define N (500000) total += execute_b36(warmups, loops, iterations, stopwatch, std::numeric_limits::max() - N); total += execute_b36< signed int>(warmups, loops, iterations, stopwatch, std::numeric_limits::min() - N); From 1b05fd3ad442e2a0e213cd3a54b2f3c92ede2fed Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Fri, 23 Oct 2026 16:49:19 +1100 Subject: [PATCH 03/22] feature(C-string functions): added **test.performance.stlsoft.string.c_string** --- include/stlsoft/string/c_string/strnchr.h | 6 +- .../unixstl/filesystem/filesystem_traits.hpp | 8 +- .../performance/stlsoft/string/CMakeLists.txt | 1 + .../stlsoft/string/c_string/CMakeLists.txt | 2 + .../stlsoft/string/c_string/main.cpp | 601 ++++++++++++++++++ 5 files changed, 611 insertions(+), 7 deletions(-) create mode 100644 test/performance/stlsoft/string/c_string/CMakeLists.txt create mode 100644 test/performance/stlsoft/string/c_string/main.cpp diff --git a/include/stlsoft/string/c_string/strnchr.h b/include/stlsoft/string/c_string/strnchr.h index c479d42e3..fd2a876ec 100644 --- a/include/stlsoft/string/c_string/strnchr.h +++ b/include/stlsoft/string/c_string/strnchr.h @@ -4,11 +4,11 @@ * Purpose: Definition of stlsoft_C_strnchr() and stlsoft_C_wcsnchr() * * Created: 1st October 2020 - * Updated: 29th September 2024 + * Updated: 20th October 2020 * * Home: http://stlsoft.org/ * - * Copyright (c) 2020, Matthew Wilson and Synesis Information Systems + * Copyright (c) 2020-2026, Matthew Wilson and Synesis Information Systems * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -54,7 +54,7 @@ # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNCHR_MAJOR 1 # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNCHR_MINOR 0 # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNCHR_REVISION 2 -# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNCHR_EDIT 3 +# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNCHR_EDIT 4 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ diff --git a/include/unixstl/filesystem/filesystem_traits.hpp b/include/unixstl/filesystem/filesystem_traits.hpp index 2bc63d6d2..ddb5a8c07 100644 --- a/include/unixstl/filesystem/filesystem_traits.hpp +++ b/include/unixstl/filesystem/filesystem_traits.hpp @@ -5,7 +5,7 @@ * Unicode specialisations thereof. * * Created: 15th November 2002 - * Updated: 21st October 2026 + * Updated: 22nd October 2026 * * Thanks: To Sergey Nikulov, for spotting a preprocessor typo that broke * GCC -pedantic; to Michal Makowski and Zar Eindl for reporting @@ -60,8 +60,8 @@ #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION # define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_MAJOR 5 # define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_MINOR 0 -# define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_REVISION 3 -# define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_EDIT 195 +# define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_REVISION 4 +# define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_EDIT 196 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -1757,7 +1757,7 @@ struct filesystem_traits } private: -#if _STLSOFT_VER >= 0x010b0200 +#if _STLSOFT_VER >= 0x010b0281 # error Sort get_root_len_() properly #endif diff --git a/test/performance/stlsoft/string/CMakeLists.txt b/test/performance/stlsoft/string/CMakeLists.txt index f7818ca72..a453a77c9 100644 --- a/test/performance/stlsoft/string/CMakeLists.txt +++ b/test/performance/stlsoft/string/CMakeLists.txt @@ -1,5 +1,6 @@ if(X_CMAKE_CXX_FULLSTANDARD GREATER_EQUAL 2011) + add_subdirectory(c_string) add_subdirectory(simple_string.compare) add_subdirectory(simple_string.op_eq) endif() diff --git a/test/performance/stlsoft/string/c_string/CMakeLists.txt b/test/performance/stlsoft/string/c_string/CMakeLists.txt new file mode 100644 index 000000000..e569aad7f --- /dev/null +++ b/test/performance/stlsoft/string/c_string/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_example_program(test.performance.stlsoft.string.c_string main.cpp) diff --git a/test/performance/stlsoft/string/c_string/main.cpp b/test/performance/stlsoft/string/c_string/main.cpp new file mode 100644 index 000000000..845e4377b --- /dev/null +++ b/test/performance/stlsoft/string/c_string/main.cpp @@ -0,0 +1,601 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: test/performance/stlsoft/string/c_string/main.cpp + * + * Purpose: Perf-test for stlsoft/string/c_string functions. + * + * Created: 20th October 2026 + * Updated: 20th October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * compatibility + */ + +#if !defined(__cplusplus) || \ + __cplusplus < 201103L +# error Requires C++11 or later +#endif + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include +#include +#include +#include +#include + +#if __cplusplus >= 201103L +# include +#else +# include +#endif /* C++11+ */ +#include + +#include "perf_group_gaps.hpp" + +#include +#include +#include + +#include +#include +#if !defined(_WIN32) +# include +#endif /* !_WIN32 */ + + +/* ///////////////////////////////////////////////////////////////////////// + * types + */ + +#if __cplusplus >= 201103L + +typedef stlsoft::std_chrono_hrc_stopwatch stopwatch_t; +#else + +typedef platformstl::stopwatch stopwatch_t; +#endif /* C++11+ */ +typedef stopwatch_t::interval_type interval_t; + +using stlsoft::ss_sint64_t; +using stlsoft::ss_size_t; + +typedef ss_sint64_t (*timed_fn_t)(); + + +/* ///////////////////////////////////////////////////////////////////////// + * constants + */ + +namespace { + + ss_size_t const NUM_ITERATIONS = 1000000; + ss_size_t const HAY_N = 96; + int const FN_COL = 22; + int const SC_COL = 12; + int const NS_COL = 16; + int const AN_COL = 16; + + char const PATTERN[] = "The Quick Brown Fox Jumps Over The Lazy Dog!!"; + ss_size_t const CMP_N = sizeof(PATTERN) - 1; + + char const NEEDLE_EARLY[] = "brown"; + char const NEEDLE_LATE[] = "jumps"; + char const NEEDLE_MISS[] = "####"; + char const NEEDLE_EARLY_CI[] = "BROWN"; + char const NEEDLE_LATE_CI[] = "JUMPS"; + + char const SET_EARLY[] = "xyzQ"; + char const SET_LATE[] = "xyzZ"; + char const SET_MISS[] = "xyz#"; + + ss_size_t const IX_EARLY_CH = 3; + ss_size_t const IX_LATE_CH = HAY_N - 4; + ss_size_t const IX_EARLY_ND = 8; + ss_size_t const IX_LATE_ND = HAY_N - 12; + + char haystack[128]; + char cmp_lhs[64]; + char cmp_rhs_equal[64]; + char cmp_rhs_early[64]; + char cmp_rhs_late[64]; + +#if defined(_WIN32) + char const BASELINE_STRNICMP_NAME[] = "_strnicmp"; +#else + char const BASELINE_STRNICMP_NAME[] = "strncasecmp"; +#endif +} // anonymous namespace + + +/* ///////////////////////////////////////////////////////////////////////// + * functions + */ + +/* Times the char forms of the c_string helpers on one fixed haystack. Where + * a C-library function does the same work it is timed beside the helper: + * memchr, strpbrk, strstr, and strncasecmp or _strnicmp. strnrchr is timed + * beside a local reverse scan. strnistrn is timed on its own. + */ + +namespace { + + STLSOFT_STATIC_ASSERT(CMP_N < sizeof(cmp_lhs)); + STLSOFT_STATIC_ASSERT(HAY_N + 1 <= sizeof(haystack)); + STLSOFT_STATIC_ASSERT(IX_EARLY_ND + 5 <= IX_LATE_ND); + STLSOFT_STATIC_ASSERT(IX_LATE_ND + 5 <= IX_LATE_CH); + + + template + std::string + thousands( + T_integer const& v + ) + { + char dest[41]; + size_t n = stlsoft::format_thousands(dest, STLSOFT_NUM_ELEMENTS(dest), "3;0", v); + + /* format_thousands() counts the terminating NUL. */ + if (0 != n) + { + --n; + } + + return std::string(dest, n); + } + + char + flip_alpha_case( + char c + ) + { + if ('a' <= c && c <= 'z') + { + return static_cast(c - 'a' + 'A'); + } + + if ('A' <= c && c <= 'Z') + { + return static_cast(c - 'A' + 'a'); + } + + return c; + } + + ss_sint64_t + ptr_anchor( + char const* base + , void const* p + ) + { + if (NULL == p) + { + return -1; + } + + return static_cast(static_cast(p) - base); + } + + ss_sint64_t + sign_of( + int r + ) + { + if (0 < r) + { + return +1; + } + + if (r < 0) + { + return -1; + } + + return 0; + } + + char const* + local_strnrchr( + char const* s + , size_t n + , int ch + ) + { + if (0 != n) + { + size_t i; + char const* p; + + for (i = 0, p = s + (n - 1); i != n; ++i, --p) + { + if (ch == *p) + { + return p; + } + } + } + + return NULL; + } + + int + baseline_strnicmp( + char const* s1 + , char const* s2 + , size_t n + ) + { +#if defined(_WIN32) + + return ::_strnicmp(s1, s2, n); +#else + + return ::strncasecmp(s1, s2, n); +#endif + } + + void + prepare_inputs() + { + ::memset(haystack, 'a', sizeof(haystack)); + + haystack[HAY_N] = '\0'; + haystack[IX_EARLY_CH] = 'Q'; + haystack[IX_LATE_CH] = 'Z'; + ::memcpy(haystack + IX_EARLY_ND, NEEDLE_EARLY, sizeof(NEEDLE_EARLY) - 1); + ::memcpy(haystack + IX_LATE_ND, NEEDLE_LATE, sizeof(NEEDLE_LATE) - 1); + + ::memcpy(cmp_lhs, PATTERN, CMP_N); + cmp_lhs[CMP_N] = '\0'; + + for (ss_size_t i = 0; CMP_N != i; ++i) + { + cmp_rhs_equal[i] = flip_alpha_case(cmp_lhs[i]); + } + + cmp_rhs_equal[CMP_N] = '\0'; + + ::memcpy(cmp_rhs_early, cmp_rhs_equal, CMP_N + 1); + ::memcpy(cmp_rhs_late, cmp_rhs_equal, CMP_N + 1); + cmp_rhs_early[0] = '#'; + cmp_rhs_late[CMP_N - 1] = '#'; + } + + + ss_sint64_t fn_strnicmp_stl_early() + { + return sign_of(stlsoft_C_strnicmp(cmp_lhs, cmp_rhs_early, CMP_N)); + } + + ss_sint64_t fn_strnicmp_crt_early() + { + return sign_of(baseline_strnicmp(cmp_lhs, cmp_rhs_early, CMP_N)); + } + + ss_sint64_t fn_strnicmp_stl_late() + { + return sign_of(stlsoft_C_strnicmp(cmp_lhs, cmp_rhs_late, CMP_N)); + } + + ss_sint64_t fn_strnicmp_crt_late() + { + return sign_of(baseline_strnicmp(cmp_lhs, cmp_rhs_late, CMP_N)); + } + + ss_sint64_t fn_strnicmp_stl_equal() + { + return sign_of(stlsoft_C_strnicmp(cmp_lhs, cmp_rhs_equal, CMP_N)); + } + + ss_sint64_t fn_strnicmp_crt_equal() + { + return sign_of(baseline_strnicmp(cmp_lhs, cmp_rhs_equal, CMP_N)); + } + + ss_sint64_t fn_strnchr_stl_start() + { + return ptr_anchor(haystack, stlsoft_C_strnchr(haystack, HAY_N, 'Q')); + } + + ss_sint64_t fn_strnchr_crt_start() + { + return ptr_anchor(haystack, ::memchr(haystack, 'Q', HAY_N)); + } + + ss_sint64_t fn_strnchr_stl_end() + { + return ptr_anchor(haystack, stlsoft_C_strnchr(haystack, HAY_N, 'Z')); + } + + ss_sint64_t fn_strnchr_crt_end() + { + return ptr_anchor(haystack, ::memchr(haystack, 'Z', HAY_N)); + } + + ss_sint64_t fn_strnchr_stl_miss() + { + return ptr_anchor(haystack, stlsoft_C_strnchr(haystack, HAY_N, '#')); + } + + ss_sint64_t fn_strnchr_crt_miss() + { + return ptr_anchor(haystack, ::memchr(haystack, '#', HAY_N)); + } + + ss_sint64_t fn_strnistrn_stl_start() + { + return ptr_anchor(haystack, stlsoft_C_strnistrn(haystack, HAY_N, NEEDLE_EARLY_CI, sizeof(NEEDLE_EARLY_CI) - 1)); + } + + ss_sint64_t fn_strnistrn_stl_end() + { + return ptr_anchor(haystack, stlsoft_C_strnistrn(haystack, HAY_N, NEEDLE_LATE_CI, sizeof(NEEDLE_LATE_CI) - 1)); + } + + ss_sint64_t fn_strnistrn_stl_miss() + { + return ptr_anchor(haystack, stlsoft_C_strnistrn(haystack, HAY_N, NEEDLE_MISS, sizeof(NEEDLE_MISS) - 1)); + } + + ss_sint64_t fn_strnpbrkn_stl_start() + { + return ptr_anchor(haystack, stlsoft_C_strnpbrkn(haystack, HAY_N, SET_EARLY, sizeof(SET_EARLY) - 1)); + } + + ss_sint64_t fn_strnpbrkn_crt_start() + { + return ptr_anchor(haystack, ::strpbrk(haystack, SET_EARLY)); + } + + ss_sint64_t fn_strnpbrkn_stl_end() + { + return ptr_anchor(haystack, stlsoft_C_strnpbrkn(haystack, HAY_N, SET_LATE, sizeof(SET_LATE) - 1)); + } + + ss_sint64_t fn_strnpbrkn_crt_end() + { + return ptr_anchor(haystack, ::strpbrk(haystack, SET_LATE)); + } + + ss_sint64_t fn_strnpbrkn_stl_miss() + { + return ptr_anchor(haystack, stlsoft_C_strnpbrkn(haystack, HAY_N, SET_MISS, sizeof(SET_MISS) - 1)); + } + + ss_sint64_t fn_strnpbrkn_crt_miss() + { + return ptr_anchor(haystack, ::strpbrk(haystack, SET_MISS)); + } + + ss_sint64_t fn_strnrchr_stl_start() + { + return ptr_anchor(haystack, stlsoft_C_strnrchr(haystack, HAY_N, 'Q')); + } + + ss_sint64_t fn_strnrchr_loc_start() + { + return ptr_anchor(haystack, local_strnrchr(haystack, HAY_N, 'Q')); + } + + ss_sint64_t fn_strnrchr_stl_end() + { + return ptr_anchor(haystack, stlsoft_C_strnrchr(haystack, HAY_N, 'Z')); + } + + ss_sint64_t fn_strnrchr_loc_end() + { + return ptr_anchor(haystack, local_strnrchr(haystack, HAY_N, 'Z')); + } + + ss_sint64_t fn_strnrchr_stl_miss() + { + return ptr_anchor(haystack, stlsoft_C_strnrchr(haystack, HAY_N, '#')); + } + + ss_sint64_t fn_strnrchr_loc_miss() + { + return ptr_anchor(haystack, local_strnrchr(haystack, HAY_N, '#')); + } + + ss_sint64_t fn_strnstrn_stl_start() + { + return ptr_anchor(haystack, stlsoft_C_strnstrn(haystack, HAY_N, NEEDLE_EARLY, sizeof(NEEDLE_EARLY) - 1)); + } + + ss_sint64_t fn_strnstrn_crt_start() + { + return ptr_anchor(haystack, ::strstr(haystack, NEEDLE_EARLY)); + } + + ss_sint64_t fn_strnstrn_stl_end() + { + return ptr_anchor(haystack, stlsoft_C_strnstrn(haystack, HAY_N, NEEDLE_LATE, sizeof(NEEDLE_LATE) - 1)); + } + + ss_sint64_t fn_strnstrn_crt_end() + { + return ptr_anchor(haystack, ::strstr(haystack, NEEDLE_LATE)); + } + + ss_sint64_t fn_strnstrn_stl_miss() + { + return ptr_anchor(haystack, stlsoft_C_strnstrn(haystack, HAY_N, NEEDLE_MISS, sizeof(NEEDLE_MISS) - 1)); + } + + ss_sint64_t fn_strnstrn_crt_miss() + { + return ptr_anchor(haystack, ::strstr(haystack, NEEDLE_MISS)); + } + + + struct row_spec + { + char const* group; + char const* function_name; + char const* scenario; + timed_fn_t fn; + }; + + row_spec const ROWS[] = + { + { "strnicmp", "stlsoft_C_strnicmp", "differ-early", fn_strnicmp_stl_early, }, + { "strnicmp", BASELINE_STRNICMP_NAME, "differ-early", fn_strnicmp_crt_early, }, + { "strnicmp", "stlsoft_C_strnicmp", "differ-late", fn_strnicmp_stl_late, }, + { "strnicmp", BASELINE_STRNICMP_NAME, "differ-late", fn_strnicmp_crt_late, }, + { "strnicmp", "stlsoft_C_strnicmp", "equal", fn_strnicmp_stl_equal, }, + { "strnicmp", BASELINE_STRNICMP_NAME, "equal", fn_strnicmp_crt_equal, }, + + { "strnchr", "stlsoft_C_strnchr", "near-start", fn_strnchr_stl_start, }, + { "strnchr", "memchr", "near-start", fn_strnchr_crt_start, }, + { "strnchr", "stlsoft_C_strnchr", "near-end", fn_strnchr_stl_end, }, + { "strnchr", "memchr", "near-end", fn_strnchr_crt_end, }, + { "strnchr", "stlsoft_C_strnchr", "miss", fn_strnchr_stl_miss, }, + { "strnchr", "memchr", "miss", fn_strnchr_crt_miss, }, + + { "strnistrn", "stlsoft_C_strnistrn", "near-start", fn_strnistrn_stl_start, }, + { "strnistrn", "stlsoft_C_strnistrn", "near-end", fn_strnistrn_stl_end, }, + { "strnistrn", "stlsoft_C_strnistrn", "miss", fn_strnistrn_stl_miss, }, + + { "strnpbrkn", "stlsoft_C_strnpbrkn", "near-start", fn_strnpbrkn_stl_start, }, + { "strnpbrkn", "strpbrk", "near-start", fn_strnpbrkn_crt_start, }, + { "strnpbrkn", "stlsoft_C_strnpbrkn", "near-end", fn_strnpbrkn_stl_end, }, + { "strnpbrkn", "strpbrk", "near-end", fn_strnpbrkn_crt_end, }, + { "strnpbrkn", "stlsoft_C_strnpbrkn", "miss", fn_strnpbrkn_stl_miss, }, + { "strnpbrkn", "strpbrk", "miss", fn_strnpbrkn_crt_miss, }, + + { "strnrchr", "stlsoft_C_strnrchr", "near-start", fn_strnrchr_stl_start, }, + { "strnrchr", "local_strnrchr", "near-start", fn_strnrchr_loc_start, }, + { "strnrchr", "stlsoft_C_strnrchr", "near-end", fn_strnrchr_stl_end, }, + { "strnrchr", "local_strnrchr", "near-end", fn_strnrchr_loc_end, }, + { "strnrchr", "stlsoft_C_strnrchr", "miss", fn_strnrchr_stl_miss, }, + { "strnrchr", "local_strnrchr", "miss", fn_strnrchr_loc_miss, }, + + { "strnstrn", "stlsoft_C_strnstrn", "near-start", fn_strnstrn_stl_start, }, + { "strnstrn", "strstr", "near-start", fn_strnstrn_crt_start, }, + { "strnstrn", "stlsoft_C_strnstrn", "near-end", fn_strnstrn_stl_end, }, + { "strnstrn", "strstr", "near-end", fn_strnstrn_crt_end, }, + { "strnstrn", "stlsoft_C_strnstrn", "miss", fn_strnstrn_stl_miss, }, + { "strnstrn", "strstr", "miss", fn_strnstrn_crt_miss, }, + }; + + + interval_t + time_calls( + timed_fn_t fn + , ss_sint64_t& anchor + ) + { + /* Volatile reload keeps the call in the loop. The callee is an + * indirect target, so the scan is not hoisted out of the timing. + */ + timed_fn_t volatile vf = fn; + stopwatch_t sw; + ss_sint64_t local = 0; + + sw.start(); + + for (ss_size_t i = 0; NUM_ITERATIONS != i; ++i) + { + timed_fn_t const call = vf; + + local += call(); + } + + sw.stop(); + + anchor = local; + + return sw.get_nanoseconds(); + } + + void + emit_header() + { + std::cout + << '\t' + << std::setw(FN_COL) << std::left << "function" + << '\t' + << std::setw(SC_COL) << std::left << "scenario" + << '\t' + << std::setw(NS_COL) << std::right << "nanoseconds" + << '\t' + << std::setw(AN_COL) << std::right << "anchor" + << std::endl; + } + + void + emit_row( + char const* function_name + , char const* scenario + , interval_t nanoseconds + , ss_sint64_t anchor + ) + { + std::cout + << '\t' + << std::setw(FN_COL) << std::left << function_name + << '\t' + << std::setw(SC_COL) << std::left << scenario + << '\t' + << std::setw(NS_COL) << std::right << thousands(nanoseconds) + << '\t' + << std::setw(AN_COL) << std::right << thousands(anchor) + << std::endl; + } + + void + measure( + row_spec const& row + ) + { + interval_t ns = 0; + ss_sint64_t anchor = 0; + + perf_maybe_emit_group_gap(std::cout, row.group); + + for (int w = 2; 0 != w; --w) + { + ns = time_calls(row.fn, anchor); + } + + emit_row(row.function_name, row.scenario, ns, anchor); + } +} // anonymous namespace + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int /*argc*/, char* /*argv*/[]) +{ + prepare_inputs(); + + perf_maybe_emit_groupgaps_banner(std::cout); + + std::cout + << "c_string" + << "\titerations=" << thousands(NUM_ITERATIONS) + << "\thaystack=" << HAY_N + << "\tcompare=" << CMP_N + << std::endl; + + emit_header(); + + for (ss_size_t i = 0; i != STLSOFT_NUM_ELEMENTS(ROWS); ++i) + { + measure(ROWS[i]); + } + + return EXIT_SUCCESS; +} + + +/* ///////////////////////////// end of file //////////////////////////// */ + From d487ee0e763d4f0d8be97a7e204de4ebcdfcbf81 Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Fri, 23 Oct 2026 17:18:08 +1100 Subject: [PATCH 04/22] test(stlsoft): add exhaustive c_string unit tests Cover strnchr, strnicmp, strnistrn, strnpbrkn, strnrchr, and strnstrn, plus each wchar analogue, with C and C++ programs. strnistrn stays on the current inner loop, so the first-character false-match cases fail; --- test/unit/stlsoft/string/CMakeLists.txt | 3 +- .../stlsoft/string/c_string/CMakeLists.txt | 13 + .../string/c_string/strnchr.C/CMakeLists.txt | 2 + .../stlsoft/string/c_string/strnchr.C/entry.c | 253 ++++++++++++ .../string/c_string/strnchr/CMakeLists.txt | 2 + .../stlsoft/string/c_string/strnchr/entry.cpp | 275 +++++++++++++ .../strnicmp.C}/CMakeLists.txt | 0 .../strnicmp.C}/entry.c | 98 ++++- .../strnicmp}/CMakeLists.txt | 0 .../strnicmp}/entry.cpp | 98 ++++- .../c_string/strnistrn.C/CMakeLists.txt | 2 + .../string/c_string/strnistrn.C/entry.c | 351 ++++++++++++++++ .../string/c_string/strnistrn/CMakeLists.txt | 2 + .../string/c_string/strnistrn/entry.cpp | 373 ++++++++++++++++++ .../c_string/strnpbrkn.C/CMakeLists.txt | 2 + .../string/c_string/strnpbrkn.C/entry.c | 325 +++++++++++++++ .../string/c_string/strnpbrkn/CMakeLists.txt | 2 + .../string/c_string/strnpbrkn/entry.cpp | 347 ++++++++++++++++ .../string/c_string/strnrchr.C/CMakeLists.txt | 2 + .../string/c_string/strnrchr.C/entry.c | 253 ++++++++++++ .../string/c_string/strnrchr/CMakeLists.txt | 2 + .../string/c_string/strnrchr/entry.cpp | 275 +++++++++++++ .../string/c_string/strnstrn.C/CMakeLists.txt | 2 + .../string/c_string/strnstrn.C/entry.c | 337 ++++++++++++++++ .../string/c_string/strnstrn/CMakeLists.txt | 2 + .../string/c_string/strnstrn/entry.cpp | 359 +++++++++++++++++ 26 files changed, 3376 insertions(+), 4 deletions(-) create mode 100644 test/unit/stlsoft/string/c_string/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnchr.C/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnchr.C/entry.c create mode 100644 test/unit/stlsoft/string/c_string/strnchr/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnchr/entry.cpp rename test/unit/stlsoft/string/{c_string.strnicmp.C => c_string/strnicmp.C}/CMakeLists.txt (100%) rename test/unit/stlsoft/string/{c_string.strnicmp.C => c_string/strnicmp.C}/entry.c (66%) rename test/unit/stlsoft/string/{c_string.strnicmp => c_string/strnicmp}/CMakeLists.txt (100%) rename test/unit/stlsoft/string/{c_string.strnicmp => c_string/strnicmp}/entry.cpp (68%) create mode 100644 test/unit/stlsoft/string/c_string/strnistrn.C/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnistrn.C/entry.c create mode 100644 test/unit/stlsoft/string/c_string/strnistrn/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnistrn/entry.cpp create mode 100644 test/unit/stlsoft/string/c_string/strnpbrkn.C/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnpbrkn.C/entry.c create mode 100644 test/unit/stlsoft/string/c_string/strnpbrkn/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnpbrkn/entry.cpp create mode 100644 test/unit/stlsoft/string/c_string/strnrchr.C/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnrchr.C/entry.c create mode 100644 test/unit/stlsoft/string/c_string/strnrchr/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnrchr/entry.cpp create mode 100644 test/unit/stlsoft/string/c_string/strnstrn.C/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnstrn.C/entry.c create mode 100644 test/unit/stlsoft/string/c_string/strnstrn/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnstrn/entry.cpp diff --git a/test/unit/stlsoft/string/CMakeLists.txt b/test/unit/stlsoft/string/CMakeLists.txt index cff73bc90..6c2d6a80d 100644 --- a/test/unit/stlsoft/string/CMakeLists.txt +++ b/test/unit/stlsoft/string/CMakeLists.txt @@ -1,6 +1,5 @@ # SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten -add_subdirectory(c_string.strnicmp) -add_subdirectory(c_string.strnicmp.C) +add_subdirectory(c_string) add_subdirectory(c_string_traits) add_subdirectory(char_traits) add_subdirectory(copy_functions) diff --git a/test/unit/stlsoft/string/c_string/CMakeLists.txt b/test/unit/stlsoft/string/c_string/CMakeLists.txt new file mode 100644 index 000000000..acee4746e --- /dev/null +++ b/test/unit/stlsoft/string/c_string/CMakeLists.txt @@ -0,0 +1,13 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +add_subdirectory(strnchr) +add_subdirectory(strnchr.C) +add_subdirectory(strnicmp) +add_subdirectory(strnicmp.C) +add_subdirectory(strnistrn) +add_subdirectory(strnistrn.C) +add_subdirectory(strnpbrkn) +add_subdirectory(strnpbrkn.C) +add_subdirectory(strnrchr) +add_subdirectory(strnrchr.C) +add_subdirectory(strnstrn) +add_subdirectory(strnstrn.C) diff --git a/test/unit/stlsoft/string/c_string/strnchr.C/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnchr.C/CMakeLists.txt new file mode 100644 index 000000000..43cebfc42 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnchr.C/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnchr.C entry.c) diff --git a/test/unit/stlsoft/string/c_string/strnchr.C/entry.c b/test/unit/stlsoft/string/c_string/strnchr.C/entry.c new file mode 100644 index 000000000..5761035f3 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnchr.C/entry.c @@ -0,0 +1,253 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnchr.C/entry.c + * + * Purpose: Unit-tests for stlsoft_C_strnchr() and stlsoft_C_wcsnchr(). + * + * Created: 23rd October 2026 + * Updated: 23rd October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +static void TEST_stlsoft_C_strnchr_n_0(void); +static void TEST_stlsoft_C_strnchr_MATCH_AT_START(void); +static void TEST_stlsoft_C_strnchr_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_strnchr_MATCH_AT_END(void); +static void TEST_stlsoft_C_strnchr_FIRST_OF_SEVERAL(void); +static void TEST_stlsoft_C_strnchr_MISS(void); +static void TEST_stlsoft_C_strnchr_DOES_NOT_READ_PAST_n(void); +static void TEST_stlsoft_C_strnchr_FINDS_EMBEDDED_NUL(void); +static void TEST_stlsoft_C_strnchr_CONTINUES_PAST_NUL(void); +static void TEST_stlsoft_C_strnchr_HIGH_BIT(void); +static void TEST_stlsoft_C_wcsnchr_n_0(void); +static void TEST_stlsoft_C_wcsnchr_MATCH_AT_START(void); +static void TEST_stlsoft_C_wcsnchr_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_wcsnchr_MATCH_AT_END(void); +static void TEST_stlsoft_C_wcsnchr_FIRST_OF_SEVERAL(void); +static void TEST_stlsoft_C_wcsnchr_MISS(void); +static void TEST_stlsoft_C_wcsnchr_DOES_NOT_READ_PAST_n(void); +static void TEST_stlsoft_C_wcsnchr_FINDS_EMBEDDED_NUL(void); +static void TEST_stlsoft_C_wcsnchr_CONTINUES_PAST_NUL(void); +static void TEST_stlsoft_C_wcsnchr_HIGH_BIT(void); + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnchr.C", verbosity)) + { + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_n_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_FIRST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_DOES_NOT_READ_PAST_n); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_FINDS_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_CONTINUES_PAST_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_HIGH_BIT); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_n_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_FIRST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_DOES_NOT_READ_PAST_n); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_FINDS_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_CONTINUES_PAST_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_HIGH_BIT); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +static void TEST_stlsoft_C_strnchr_n_0(void) +{ + TEST_PTR_NULL(stlsoft_C_strnchr("abc", 0, 'a')); + TEST_PTR_NULL(stlsoft_C_strnchr("", 0, '\0')); +} + +static void TEST_stlsoft_C_strnchr_MATCH_AT_START(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft_C_strnchr(s, 3, 'a')); + TEST_PTR_EQ(s, stlsoft_C_strnchr(s, 1, 'a')); +} + +static void TEST_stlsoft_C_strnchr_MATCH_IN_MIDDLE(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnchr(s, 3, 'b')); +} + +static void TEST_stlsoft_C_strnchr_MATCH_AT_END(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnchr(s, 3, 'c')); +} + +static void TEST_stlsoft_C_strnchr_FIRST_OF_SEVERAL(void) +{ + char const s[] = "abaca"; + + TEST_PTR_EQ(s, stlsoft_C_strnchr(s, 5, 'a')); + TEST_PTR_EQ(s + 1, stlsoft_C_strnchr(s, 5, 'b')); +} + +static void TEST_stlsoft_C_strnchr_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_strnchr("abc", 3, 'z')); + TEST_PTR_NULL(stlsoft_C_strnchr("abc", 3, 'A')); +} + +static void TEST_stlsoft_C_strnchr_DOES_NOT_READ_PAST_n(void) +{ + char const s[] = "abc"; + + TEST_PTR_NULL(stlsoft_C_strnchr(s, 2, 'c')); + TEST_PTR_EQ(s + 2, stlsoft_C_strnchr(s, 3, 'c')); +} + +static void TEST_stlsoft_C_strnchr_FINDS_EMBEDDED_NUL(void) +{ + char const s[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnchr(s, 3, '\0')); + TEST_PTR_EQ("", stlsoft_C_strnchr("", 1, '\0')); +} + +static void TEST_stlsoft_C_strnchr_CONTINUES_PAST_NUL(void) +{ + char const s[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnchr(s, 3, 'b')); + TEST_PTR_NULL(stlsoft_C_strnchr(s, 2, 'b')); +} + +static void TEST_stlsoft_C_strnchr_HIGH_BIT(void) +{ + char const s[] = { (char)0xE9, 'b', 'c' }; + + TEST_PTR_EQ(s, stlsoft_C_strnchr(s, 3, s[0])); + TEST_PTR_EQ(s + 1, stlsoft_C_strnchr(s, 3, 'b')); + TEST_PTR_NULL(stlsoft_C_strnchr(s, 3, 'x')); +} + +static void TEST_stlsoft_C_wcsnchr_n_0(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnchr(L"abc", 0, L'a')); + TEST_PTR_NULL(stlsoft_C_wcsnchr(L"", 0, L'\0')); +} + +static void TEST_stlsoft_C_wcsnchr_MATCH_AT_START(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnchr(s, 3, L'a')); + TEST_PTR_EQ(s, stlsoft_C_wcsnchr(s, 1, L'a')); +} + +static void TEST_stlsoft_C_wcsnchr_MATCH_IN_MIDDLE(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnchr(s, 3, L'b')); +} + +static void TEST_stlsoft_C_wcsnchr_MATCH_AT_END(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnchr(s, 3, L'c')); +} + +static void TEST_stlsoft_C_wcsnchr_FIRST_OF_SEVERAL(void) +{ + wchar_t const s[] = L"abaca"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnchr(s, 5, L'a')); + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnchr(s, 5, L'b')); +} + +static void TEST_stlsoft_C_wcsnchr_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnchr(L"abc", 3, L'z')); + TEST_PTR_NULL(stlsoft_C_wcsnchr(L"abc", 3, L'A')); +} + +static void TEST_stlsoft_C_wcsnchr_DOES_NOT_READ_PAST_n(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_NULL(stlsoft_C_wcsnchr(s, 2, L'c')); + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnchr(s, 3, L'c')); +} + +static void TEST_stlsoft_C_wcsnchr_FINDS_EMBEDDED_NUL(void) +{ + wchar_t const s[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnchr(s, 3, L'\0')); + TEST_PTR_EQ(L"", stlsoft_C_wcsnchr(L"", 1, L'\0')); +} + +static void TEST_stlsoft_C_wcsnchr_CONTINUES_PAST_NUL(void) +{ + wchar_t const s[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnchr(s, 3, L'b')); + TEST_PTR_NULL(stlsoft_C_wcsnchr(s, 2, L'b')); +} + +static void TEST_stlsoft_C_wcsnchr_HIGH_BIT(void) +{ + wchar_t const s[] = { L'\x00E9', L'b', L'c' }; + + TEST_PTR_EQ(s, stlsoft_C_wcsnchr(s, 3, s[0])); + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnchr(s, 3, L'b')); + TEST_PTR_NULL(stlsoft_C_wcsnchr(s, 3, L'x')); +} + + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/test/unit/stlsoft/string/c_string/strnchr/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnchr/CMakeLists.txt new file mode 100644 index 000000000..acf10c047 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnchr/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnchr entry.cpp) diff --git a/test/unit/stlsoft/string/c_string/strnchr/entry.cpp b/test/unit/stlsoft/string/c_string/strnchr/entry.cpp new file mode 100644 index 000000000..5e26fd389 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnchr/entry.cpp @@ -0,0 +1,275 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnchr/entry.cpp + * + * Purpose: Unit-tests for stlsoft::c_string::strnchr() and wcsnchr(). + * + * Created: 23rd October 2026 + * Updated: 23rd October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +namespace +{ + + static void TEST_c_string_strnchr_n_0(); + static void TEST_c_string_strnchr_MATCH_AT_START(); + static void TEST_c_string_strnchr_MATCH_IN_MIDDLE(); + static void TEST_c_string_strnchr_MATCH_AT_END(); + static void TEST_c_string_strnchr_FIRST_OF_SEVERAL(); + static void TEST_c_string_strnchr_MISS(); + static void TEST_c_string_strnchr_DOES_NOT_READ_PAST_n(); + static void TEST_c_string_strnchr_FINDS_EMBEDDED_NUL(); + static void TEST_c_string_strnchr_CONTINUES_PAST_NUL(); + static void TEST_c_string_strnchr_HIGH_BIT(); + static void TEST_c_string_wcsnchr_n_0(); + static void TEST_c_string_wcsnchr_MATCH_AT_START(); + static void TEST_c_string_wcsnchr_MATCH_IN_MIDDLE(); + static void TEST_c_string_wcsnchr_MATCH_AT_END(); + static void TEST_c_string_wcsnchr_FIRST_OF_SEVERAL(); + static void TEST_c_string_wcsnchr_MISS(); + static void TEST_c_string_wcsnchr_DOES_NOT_READ_PAST_n(); + static void TEST_c_string_wcsnchr_FINDS_EMBEDDED_NUL(); + static void TEST_c_string_wcsnchr_CONTINUES_PAST_NUL(); + static void TEST_c_string_wcsnchr_HIGH_BIT(); + + static wchar_t const* wcsnchr_both_(wchar_t const* s, size_t n, int ch); + +} /* anonymous namespace */ + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnchr", verbosity)) + { + XTESTS_RUN_CASE(TEST_c_string_strnchr_n_0); + XTESTS_RUN_CASE(TEST_c_string_strnchr_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_c_string_strnchr_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_strnchr_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_strnchr_FIRST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_c_string_strnchr_MISS); + XTESTS_RUN_CASE(TEST_c_string_strnchr_DOES_NOT_READ_PAST_n); + XTESTS_RUN_CASE(TEST_c_string_strnchr_FINDS_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_c_string_strnchr_CONTINUES_PAST_NUL); + XTESTS_RUN_CASE(TEST_c_string_strnchr_HIGH_BIT); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_n_0); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_FIRST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_MISS); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_DOES_NOT_READ_PAST_n); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_FINDS_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_CONTINUES_PAST_NUL); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_HIGH_BIT); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +namespace +{ + +static wchar_t const* wcsnchr_both_(wchar_t const* s, size_t n, int ch) +{ + wchar_t const* const via_str = stlsoft::c_string::strnchr(s, n, ch); + wchar_t const* const via_wcs = stlsoft::c_string::wcsnchr(s, n, ch); + + TEST_PTR_EQ(via_wcs, via_str); + + return via_wcs; +} + +static void TEST_c_string_strnchr_n_0() +{ + TEST_PTR_NULL(stlsoft::c_string::strnchr("abc", 0, 'a')); + TEST_PTR_NULL(stlsoft::c_string::strnchr("", 0, '\0')); +} + +static void TEST_c_string_strnchr_MATCH_AT_START() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnchr(s, 3, 'a')); + TEST_PTR_EQ(s, stlsoft::c_string::strnchr(s, 1, 'a')); +} + +static void TEST_c_string_strnchr_MATCH_IN_MIDDLE() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnchr(s, 3, 'b')); +} + +static void TEST_c_string_strnchr_MATCH_AT_END() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnchr(s, 3, 'c')); +} + +static void TEST_c_string_strnchr_FIRST_OF_SEVERAL() +{ + char const s[] = "abaca"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnchr(s, 5, 'a')); + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnchr(s, 5, 'b')); +} + +static void TEST_c_string_strnchr_MISS() +{ + TEST_PTR_NULL(stlsoft::c_string::strnchr("abc", 3, 'z')); + TEST_PTR_NULL(stlsoft::c_string::strnchr("abc", 3, 'A')); +} + +static void TEST_c_string_strnchr_DOES_NOT_READ_PAST_n() +{ + char const s[] = "abc"; + + TEST_PTR_NULL(stlsoft::c_string::strnchr(s, 2, 'c')); + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnchr(s, 3, 'c')); +} + +static void TEST_c_string_strnchr_FINDS_EMBEDDED_NUL() +{ + char const s[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnchr(s, 3, '\0')); + TEST_PTR_EQ("", stlsoft::c_string::strnchr("", 1, '\0')); +} + +static void TEST_c_string_strnchr_CONTINUES_PAST_NUL() +{ + char const s[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnchr(s, 3, 'b')); + TEST_PTR_NULL(stlsoft::c_string::strnchr(s, 2, 'b')); +} + +static void TEST_c_string_strnchr_HIGH_BIT() +{ + char const s[] = { (char)0xE9, 'b', 'c' }; + + TEST_PTR_EQ(s, stlsoft::c_string::strnchr(s, 3, s[0])); + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnchr(s, 3, 'b')); + TEST_PTR_NULL(stlsoft::c_string::strnchr(s, 3, 'x')); +} + +static void TEST_c_string_wcsnchr_n_0() +{ + TEST_PTR_NULL(wcsnchr_both_(L"abc", 0, L'a')); + TEST_PTR_NULL(wcsnchr_both_(L"", 0, L'\0')); +} + +static void TEST_c_string_wcsnchr_MATCH_AT_START() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, wcsnchr_both_(s, 3, L'a')); + TEST_PTR_EQ(s, wcsnchr_both_(s, 1, L'a')); +} + +static void TEST_c_string_wcsnchr_MATCH_IN_MIDDLE() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, wcsnchr_both_(s, 3, L'b')); +} + +static void TEST_c_string_wcsnchr_MATCH_AT_END() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 2, wcsnchr_both_(s, 3, L'c')); +} + +static void TEST_c_string_wcsnchr_FIRST_OF_SEVERAL() +{ + wchar_t const s[] = L"abaca"; + + TEST_PTR_EQ(s, wcsnchr_both_(s, 5, L'a')); + TEST_PTR_EQ(s + 1, wcsnchr_both_(s, 5, L'b')); +} + +static void TEST_c_string_wcsnchr_MISS() +{ + TEST_PTR_NULL(wcsnchr_both_(L"abc", 3, L'z')); + TEST_PTR_NULL(wcsnchr_both_(L"abc", 3, L'A')); +} + +static void TEST_c_string_wcsnchr_DOES_NOT_READ_PAST_n() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_NULL(wcsnchr_both_(s, 2, L'c')); + TEST_PTR_EQ(s + 2, wcsnchr_both_(s, 3, L'c')); +} + +static void TEST_c_string_wcsnchr_FINDS_EMBEDDED_NUL() +{ + wchar_t const s[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(s + 1, wcsnchr_both_(s, 3, L'\0')); + TEST_PTR_EQ(L"", wcsnchr_both_(L"", 1, L'\0')); +} + +static void TEST_c_string_wcsnchr_CONTINUES_PAST_NUL() +{ + wchar_t const s[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(s + 2, wcsnchr_both_(s, 3, L'b')); + TEST_PTR_NULL(wcsnchr_both_(s, 2, L'b')); +} + +static void TEST_c_string_wcsnchr_HIGH_BIT() +{ + wchar_t const s[] = { L'\x00E9', L'b', L'c' }; + + TEST_PTR_EQ(s, wcsnchr_both_(s, 3, s[0])); + TEST_PTR_EQ(s + 1, wcsnchr_both_(s, 3, L'b')); + TEST_PTR_NULL(wcsnchr_both_(s, 3, L'x')); +} + +} /* anonymous namespace */ + + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/test/unit/stlsoft/string/c_string.strnicmp.C/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnicmp.C/CMakeLists.txt similarity index 100% rename from test/unit/stlsoft/string/c_string.strnicmp.C/CMakeLists.txt rename to test/unit/stlsoft/string/c_string/strnicmp.C/CMakeLists.txt diff --git a/test/unit/stlsoft/string/c_string.strnicmp.C/entry.c b/test/unit/stlsoft/string/c_string/strnicmp.C/entry.c similarity index 66% rename from test/unit/stlsoft/string/c_string.strnicmp.C/entry.c rename to test/unit/stlsoft/string/c_string/strnicmp.C/entry.c index 3184f3ab6..4c8e71d7f 100644 --- a/test/unit/stlsoft/string/c_string.strnicmp.C/entry.c +++ b/test/unit/stlsoft/string/c_string/strnicmp.C/entry.c @@ -4,7 +4,7 @@ * Purpose: Unit-tests for stlsoft_C_strnicmp() and stlsoft_C_wcsnicmp(). * * Created: 29th September 2026 - * Updated: 29th September 2026 + * Updated: 23rd October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -34,17 +34,27 @@ static void TEST_stlsoft_C_strnicmp_EQUAL(void); static void TEST_stlsoft_C_strnicmp_LESS(void); static void TEST_stlsoft_C_strnicmp_GREATER(void); static void TEST_stlsoft_C_strnicmp_n_0(void); +static void TEST_stlsoft_C_strnicmp_n_1(void); static void TEST_stlsoft_C_strnicmp_STOPS_AT_NUL(void); +static void TEST_stlsoft_C_strnicmp_NUL_AT_START(void); static void TEST_stlsoft_C_strnicmp_IGNORES_BYTE_PAST_n(void); +static void TEST_stlsoft_C_strnicmp_DIFFER_AT_LAST(void); static void TEST_stlsoft_C_strnicmp_ASCII_CASE_FOLD(void); +static void TEST_stlsoft_C_strnicmp_CASE_THEN_DIFFER(void); +static void TEST_stlsoft_C_strnicmp_NON_LETTER(void); static void TEST_stlsoft_C_strnicmp_HIGH_BIT(void); static void TEST_stlsoft_C_wcsnicmp_EQUAL(void); static void TEST_stlsoft_C_wcsnicmp_LESS(void); static void TEST_stlsoft_C_wcsnicmp_GREATER(void); static void TEST_stlsoft_C_wcsnicmp_n_0(void); +static void TEST_stlsoft_C_wcsnicmp_n_1(void); static void TEST_stlsoft_C_wcsnicmp_STOPS_AT_NUL(void); +static void TEST_stlsoft_C_wcsnicmp_NUL_AT_START(void); static void TEST_stlsoft_C_wcsnicmp_IGNORES_BYTE_PAST_n(void); +static void TEST_stlsoft_C_wcsnicmp_DIFFER_AT_LAST(void); static void TEST_stlsoft_C_wcsnicmp_ASCII_CASE_FOLD(void); +static void TEST_stlsoft_C_wcsnicmp_CASE_THEN_DIFFER(void); +static void TEST_stlsoft_C_wcsnicmp_NON_LETTER(void); static void TEST_stlsoft_C_wcsnicmp_HIGH_BIT(void); @@ -65,17 +75,27 @@ int main(int argc, char* argv[]) XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_LESS); XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_GREATER); XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_n_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_n_1); XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_STOPS_AT_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_NUL_AT_START); XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_IGNORES_BYTE_PAST_n); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_DIFFER_AT_LAST); XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_ASCII_CASE_FOLD); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_CASE_THEN_DIFFER); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_NON_LETTER); XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_HIGH_BIT); XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_EQUAL); XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_LESS); XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_GREATER); XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_n_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_n_1); XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_STOPS_AT_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_NUL_AT_START); XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_IGNORES_BYTE_PAST_n); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_DIFFER_AT_LAST); XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_ASCII_CASE_FOLD); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_CASE_THEN_DIFFER); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_NON_LETTER); XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_HIGH_BIT); XTESTS_PRINT_RESULTS(); @@ -116,6 +136,13 @@ static void TEST_stlsoft_C_strnicmp_n_0(void) TEST_INT_EQ(0, stlsoft_C_strnicmp("", "abc", 0)); } +static void TEST_stlsoft_C_strnicmp_n_1(void) +{ + TEST_INT_EQ(0, stlsoft_C_strnicmp("aX", "Ay", 1)); + TEST_INT_LT(0, stlsoft_C_strnicmp("A", "b", 1)); + TEST_INT_GT(0, stlsoft_C_strnicmp("b", "A", 1)); +} + static void TEST_stlsoft_C_strnicmp_STOPS_AT_NUL(void) { char const s1[] = { 'a', '\0', 'x' }; @@ -124,12 +151,29 @@ static void TEST_stlsoft_C_strnicmp_STOPS_AT_NUL(void) TEST_INT_EQ(0, stlsoft_C_strnicmp(s1, s2, 3)); } +static void TEST_stlsoft_C_strnicmp_NUL_AT_START(void) +{ + char const both[] = { '\0', 'x' }; + char const only[] = { '\0', 'y' }; + + TEST_INT_EQ(0, stlsoft_C_strnicmp(both, only, 2)); + TEST_INT_LT(0, stlsoft_C_strnicmp(both, "a", 1)); + TEST_INT_GT(0, stlsoft_C_strnicmp("a", only, 1)); +} + static void TEST_stlsoft_C_strnicmp_IGNORES_BYTE_PAST_n(void) { TEST_INT_EQ(0, stlsoft_C_strnicmp("abX", "abY", 2)); TEST_INT_LT(0, stlsoft_C_strnicmp("abX", "abY", 3)); } +static void TEST_stlsoft_C_strnicmp_DIFFER_AT_LAST(void) +{ + TEST_INT_EQ(0, stlsoft_C_strnicmp("abcd", "abce", 3)); + TEST_INT_LT(0, stlsoft_C_strnicmp("abcd", "abce", 4)); + TEST_INT_GT(0, stlsoft_C_strnicmp("abce", "abcd", 4)); +} + static void TEST_stlsoft_C_strnicmp_ASCII_CASE_FOLD(void) { TEST_INT_EQ(0, stlsoft_C_strnicmp("AbC", "aBc", 3)); @@ -138,6 +182,20 @@ static void TEST_stlsoft_C_strnicmp_ASCII_CASE_FOLD(void) TEST_INT_GT(0, stlsoft_C_strnicmp("B", "a", 1)); } +static void TEST_stlsoft_C_strnicmp_CASE_THEN_DIFFER(void) +{ + TEST_INT_EQ(0, stlsoft_C_strnicmp("abcX", "ABCx", 4)); + TEST_INT_LT(0, stlsoft_C_strnicmp("abcX", "ABCY", 4)); + TEST_INT_GT(0, stlsoft_C_strnicmp("ABCY", "abcX", 4)); +} + +static void TEST_stlsoft_C_strnicmp_NON_LETTER(void) +{ + TEST_INT_EQ(0, stlsoft_C_strnicmp("a1!", "A1!", 3)); + TEST_INT_LT(0, stlsoft_C_strnicmp("a1!", "A1?", 3)); + TEST_INT_GT(0, stlsoft_C_strnicmp("A1?", "a1!", 3)); +} + static void TEST_stlsoft_C_strnicmp_HIGH_BIT(void) { unsigned char const same1_u[] = { 0xE9, 'A', 0 }; @@ -182,6 +240,13 @@ static void TEST_stlsoft_C_wcsnicmp_n_0(void) TEST_INT_EQ(0, stlsoft_C_wcsnicmp(L"", L"abc", 0)); } +static void TEST_stlsoft_C_wcsnicmp_n_1(void) +{ + TEST_INT_EQ(0, stlsoft_C_wcsnicmp(L"aX", L"Ay", 1)); + TEST_INT_LT(0, stlsoft_C_wcsnicmp(L"A", L"b", 1)); + TEST_INT_GT(0, stlsoft_C_wcsnicmp(L"b", L"A", 1)); +} + static void TEST_stlsoft_C_wcsnicmp_STOPS_AT_NUL(void) { wchar_t const s1[] = { L'a', L'\0', L'x' }; @@ -190,12 +255,29 @@ static void TEST_stlsoft_C_wcsnicmp_STOPS_AT_NUL(void) TEST_INT_EQ(0, stlsoft_C_wcsnicmp(s1, s2, 3)); } +static void TEST_stlsoft_C_wcsnicmp_NUL_AT_START(void) +{ + wchar_t const both[] = { L'\0', L'x' }; + wchar_t const only[] = { L'\0', L'y' }; + + TEST_INT_EQ(0, stlsoft_C_wcsnicmp(both, only, 2)); + TEST_INT_LT(0, stlsoft_C_wcsnicmp(both, L"a", 1)); + TEST_INT_GT(0, stlsoft_C_wcsnicmp(L"a", only, 1)); +} + static void TEST_stlsoft_C_wcsnicmp_IGNORES_BYTE_PAST_n(void) { TEST_INT_EQ(0, stlsoft_C_wcsnicmp(L"abX", L"abY", 2)); TEST_INT_LT(0, stlsoft_C_wcsnicmp(L"abX", L"abY", 3)); } +static void TEST_stlsoft_C_wcsnicmp_DIFFER_AT_LAST(void) +{ + TEST_INT_EQ(0, stlsoft_C_wcsnicmp(L"abcd", L"abce", 3)); + TEST_INT_LT(0, stlsoft_C_wcsnicmp(L"abcd", L"abce", 4)); + TEST_INT_GT(0, stlsoft_C_wcsnicmp(L"abce", L"abcd", 4)); +} + static void TEST_stlsoft_C_wcsnicmp_ASCII_CASE_FOLD(void) { TEST_INT_EQ(0, stlsoft_C_wcsnicmp(L"AbC", L"aBc", 3)); @@ -204,6 +286,20 @@ static void TEST_stlsoft_C_wcsnicmp_ASCII_CASE_FOLD(void) TEST_INT_GT(0, stlsoft_C_wcsnicmp(L"B", L"a", 1)); } +static void TEST_stlsoft_C_wcsnicmp_CASE_THEN_DIFFER(void) +{ + TEST_INT_EQ(0, stlsoft_C_wcsnicmp(L"abcX", L"ABCx", 4)); + TEST_INT_LT(0, stlsoft_C_wcsnicmp(L"abcX", L"ABCY", 4)); + TEST_INT_GT(0, stlsoft_C_wcsnicmp(L"ABCY", L"abcX", 4)); +} + +static void TEST_stlsoft_C_wcsnicmp_NON_LETTER(void) +{ + TEST_INT_EQ(0, stlsoft_C_wcsnicmp(L"a1!", L"A1!", 3)); + TEST_INT_LT(0, stlsoft_C_wcsnicmp(L"a1!", L"A1?", 3)); + TEST_INT_GT(0, stlsoft_C_wcsnicmp(L"A1?", L"a1!", 3)); +} + static void TEST_stlsoft_C_wcsnicmp_HIGH_BIT(void) { wchar_t const same1[] = { L'\x00E9', L'A', L'\0' }; diff --git a/test/unit/stlsoft/string/c_string.strnicmp/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnicmp/CMakeLists.txt similarity index 100% rename from test/unit/stlsoft/string/c_string.strnicmp/CMakeLists.txt rename to test/unit/stlsoft/string/c_string/strnicmp/CMakeLists.txt diff --git a/test/unit/stlsoft/string/c_string.strnicmp/entry.cpp b/test/unit/stlsoft/string/c_string/strnicmp/entry.cpp similarity index 68% rename from test/unit/stlsoft/string/c_string.strnicmp/entry.cpp rename to test/unit/stlsoft/string/c_string/strnicmp/entry.cpp index 35c7108ae..0d09744d6 100644 --- a/test/unit/stlsoft/string/c_string.strnicmp/entry.cpp +++ b/test/unit/stlsoft/string/c_string/strnicmp/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for stlsoft::c_string::strnicmp() and wcsnicmp(). * * Created: 29th September 2026 - * Updated: 29th September 2026 + * Updated: 23rd October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -37,17 +37,27 @@ namespace static void TEST_c_string_strnicmp_LESS(); static void TEST_c_string_strnicmp_GREATER(); static void TEST_c_string_strnicmp_n_0(); + static void TEST_c_string_strnicmp_n_1(); static void TEST_c_string_strnicmp_STOPS_AT_NUL(); + static void TEST_c_string_strnicmp_NUL_AT_START(); static void TEST_c_string_strnicmp_IGNORES_BYTE_PAST_n(); + static void TEST_c_string_strnicmp_DIFFER_AT_LAST(); static void TEST_c_string_strnicmp_ASCII_CASE_FOLD(); + static void TEST_c_string_strnicmp_CASE_THEN_DIFFER(); + static void TEST_c_string_strnicmp_NON_LETTER(); static void TEST_c_string_strnicmp_HIGH_BIT(); static void TEST_c_string_wcsnicmp_EQUAL(); static void TEST_c_string_wcsnicmp_LESS(); static void TEST_c_string_wcsnicmp_GREATER(); static void TEST_c_string_wcsnicmp_n_0(); + static void TEST_c_string_wcsnicmp_n_1(); static void TEST_c_string_wcsnicmp_STOPS_AT_NUL(); + static void TEST_c_string_wcsnicmp_NUL_AT_START(); static void TEST_c_string_wcsnicmp_IGNORES_BYTE_PAST_n(); + static void TEST_c_string_wcsnicmp_DIFFER_AT_LAST(); static void TEST_c_string_wcsnicmp_ASCII_CASE_FOLD(); + static void TEST_c_string_wcsnicmp_CASE_THEN_DIFFER(); + static void TEST_c_string_wcsnicmp_NON_LETTER(); static void TEST_c_string_wcsnicmp_HIGH_BIT(); static int wcsnicmp_both_(wchar_t const* s1, wchar_t const* s2, size_t n); @@ -72,17 +82,27 @@ int main(int argc, char* argv[]) XTESTS_RUN_CASE(TEST_c_string_strnicmp_LESS); XTESTS_RUN_CASE(TEST_c_string_strnicmp_GREATER); XTESTS_RUN_CASE(TEST_c_string_strnicmp_n_0); + XTESTS_RUN_CASE(TEST_c_string_strnicmp_n_1); XTESTS_RUN_CASE(TEST_c_string_strnicmp_STOPS_AT_NUL); + XTESTS_RUN_CASE(TEST_c_string_strnicmp_NUL_AT_START); XTESTS_RUN_CASE(TEST_c_string_strnicmp_IGNORES_BYTE_PAST_n); + XTESTS_RUN_CASE(TEST_c_string_strnicmp_DIFFER_AT_LAST); XTESTS_RUN_CASE(TEST_c_string_strnicmp_ASCII_CASE_FOLD); + XTESTS_RUN_CASE(TEST_c_string_strnicmp_CASE_THEN_DIFFER); + XTESTS_RUN_CASE(TEST_c_string_strnicmp_NON_LETTER); XTESTS_RUN_CASE(TEST_c_string_strnicmp_HIGH_BIT); XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_EQUAL); XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_LESS); XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_GREATER); XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_n_0); + XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_n_1); XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_STOPS_AT_NUL); + XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_NUL_AT_START); XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_IGNORES_BYTE_PAST_n); + XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_DIFFER_AT_LAST); XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_ASCII_CASE_FOLD); + XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_CASE_THEN_DIFFER); + XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_NON_LETTER); XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_HIGH_BIT); XTESTS_PRINT_RESULTS(); @@ -136,6 +156,13 @@ static void TEST_c_string_strnicmp_n_0() TEST_INT_EQ(0, stlsoft::c_string::strnicmp("", "abc", 0)); } +static void TEST_c_string_strnicmp_n_1() +{ + TEST_INT_EQ(0, stlsoft::c_string::strnicmp("aX", "Ay", 1)); + TEST_INT_LT(0, stlsoft::c_string::strnicmp("A", "b", 1)); + TEST_INT_GT(0, stlsoft::c_string::strnicmp("b", "A", 1)); +} + static void TEST_c_string_strnicmp_STOPS_AT_NUL() { char const s1[] = { 'a', '\0', 'x' }; @@ -144,12 +171,29 @@ static void TEST_c_string_strnicmp_STOPS_AT_NUL() TEST_INT_EQ(0, stlsoft::c_string::strnicmp(s1, s2, 3)); } +static void TEST_c_string_strnicmp_NUL_AT_START() +{ + char const both[] = { '\0', 'x' }; + char const only[] = { '\0', 'y' }; + + TEST_INT_EQ(0, stlsoft::c_string::strnicmp(both, only, 2)); + TEST_INT_LT(0, stlsoft::c_string::strnicmp(both, "a", 1)); + TEST_INT_GT(0, stlsoft::c_string::strnicmp("a", only, 1)); +} + static void TEST_c_string_strnicmp_IGNORES_BYTE_PAST_n() { TEST_INT_EQ(0, stlsoft::c_string::strnicmp("abX", "abY", 2)); TEST_INT_LT(0, stlsoft::c_string::strnicmp("abX", "abY", 3)); } +static void TEST_c_string_strnicmp_DIFFER_AT_LAST() +{ + TEST_INT_EQ(0, stlsoft::c_string::strnicmp("abcd", "abce", 3)); + TEST_INT_LT(0, stlsoft::c_string::strnicmp("abcd", "abce", 4)); + TEST_INT_GT(0, stlsoft::c_string::strnicmp("abce", "abcd", 4)); +} + static void TEST_c_string_strnicmp_ASCII_CASE_FOLD() { TEST_INT_EQ(0, stlsoft::c_string::strnicmp("AbC", "aBc", 3)); @@ -158,6 +202,20 @@ static void TEST_c_string_strnicmp_ASCII_CASE_FOLD() TEST_INT_GT(0, stlsoft::c_string::strnicmp("B", "a", 1)); } +static void TEST_c_string_strnicmp_CASE_THEN_DIFFER() +{ + TEST_INT_EQ(0, stlsoft::c_string::strnicmp("abcX", "ABCx", 4)); + TEST_INT_LT(0, stlsoft::c_string::strnicmp("abcX", "ABCY", 4)); + TEST_INT_GT(0, stlsoft::c_string::strnicmp("ABCY", "abcX", 4)); +} + +static void TEST_c_string_strnicmp_NON_LETTER() +{ + TEST_INT_EQ(0, stlsoft::c_string::strnicmp("a1!", "A1!", 3)); + TEST_INT_LT(0, stlsoft::c_string::strnicmp("a1!", "A1?", 3)); + TEST_INT_GT(0, stlsoft::c_string::strnicmp("A1?", "a1!", 3)); +} + static void TEST_c_string_strnicmp_HIGH_BIT() { unsigned char const same1_u[] = { 0xE9, 'A', 0 }; @@ -202,6 +260,13 @@ static void TEST_c_string_wcsnicmp_n_0() TEST_INT_EQ(0, wcsnicmp_both_(L"", L"abc", 0)); } +static void TEST_c_string_wcsnicmp_n_1() +{ + TEST_INT_EQ(0, wcsnicmp_both_(L"aX", L"Ay", 1)); + TEST_INT_LT(0, wcsnicmp_both_(L"A", L"b", 1)); + TEST_INT_GT(0, wcsnicmp_both_(L"b", L"A", 1)); +} + static void TEST_c_string_wcsnicmp_STOPS_AT_NUL() { wchar_t const s1[] = { L'a', L'\0', L'x' }; @@ -210,12 +275,29 @@ static void TEST_c_string_wcsnicmp_STOPS_AT_NUL() TEST_INT_EQ(0, wcsnicmp_both_(s1, s2, 3)); } +static void TEST_c_string_wcsnicmp_NUL_AT_START() +{ + wchar_t const both[] = { L'\0', L'x' }; + wchar_t const only[] = { L'\0', L'y' }; + + TEST_INT_EQ(0, wcsnicmp_both_(both, only, 2)); + TEST_INT_LT(0, wcsnicmp_both_(both, L"a", 1)); + TEST_INT_GT(0, wcsnicmp_both_(L"a", only, 1)); +} + static void TEST_c_string_wcsnicmp_IGNORES_BYTE_PAST_n() { TEST_INT_EQ(0, wcsnicmp_both_(L"abX", L"abY", 2)); TEST_INT_LT(0, wcsnicmp_both_(L"abX", L"abY", 3)); } +static void TEST_c_string_wcsnicmp_DIFFER_AT_LAST() +{ + TEST_INT_EQ(0, wcsnicmp_both_(L"abcd", L"abce", 3)); + TEST_INT_LT(0, wcsnicmp_both_(L"abcd", L"abce", 4)); + TEST_INT_GT(0, wcsnicmp_both_(L"abce", L"abcd", 4)); +} + static void TEST_c_string_wcsnicmp_ASCII_CASE_FOLD() { TEST_INT_EQ(0, wcsnicmp_both_(L"AbC", L"aBc", 3)); @@ -224,6 +306,20 @@ static void TEST_c_string_wcsnicmp_ASCII_CASE_FOLD() TEST_INT_GT(0, wcsnicmp_both_(L"B", L"a", 1)); } +static void TEST_c_string_wcsnicmp_CASE_THEN_DIFFER() +{ + TEST_INT_EQ(0, wcsnicmp_both_(L"abcX", L"ABCx", 4)); + TEST_INT_LT(0, wcsnicmp_both_(L"abcX", L"ABCY", 4)); + TEST_INT_GT(0, wcsnicmp_both_(L"ABCY", L"abcX", 4)); +} + +static void TEST_c_string_wcsnicmp_NON_LETTER() +{ + TEST_INT_EQ(0, wcsnicmp_both_(L"a1!", L"A1!", 3)); + TEST_INT_LT(0, wcsnicmp_both_(L"a1!", L"A1?", 3)); + TEST_INT_GT(0, wcsnicmp_both_(L"A1?", L"a1!", 3)); +} + static void TEST_c_string_wcsnicmp_HIGH_BIT() { wchar_t const same1[] = { L'\x00E9', L'A', L'\0' }; diff --git a/test/unit/stlsoft/string/c_string/strnistrn.C/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnistrn.C/CMakeLists.txt new file mode 100644 index 000000000..e891dadfb --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnistrn.C/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnistrn.C entry.c) diff --git a/test/unit/stlsoft/string/c_string/strnistrn.C/entry.c b/test/unit/stlsoft/string/c_string/strnistrn.C/entry.c new file mode 100644 index 000000000..5a7a14233 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnistrn.C/entry.c @@ -0,0 +1,351 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnistrn.C/entry.c + * + * Purpose: Unit-tests for stlsoft_C_strnistrn() and stlsoft_C_wcsnistrn(). + * + * Created: 23rd October 2026 + * Updated: 23rd October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +static void TEST_stlsoft_C_strnistrn_n2_0(void); +static void TEST_stlsoft_C_strnistrn_n1_0(void); +static void TEST_stlsoft_C_strnistrn_n2_GT_n1(void); +static void TEST_stlsoft_C_strnistrn_EXACT_MATCH(void); +static void TEST_stlsoft_C_strnistrn_CASE_FOLD_FULL(void); +static void TEST_stlsoft_C_strnistrn_CASE_FOLD_IN_MIDDLE(void); +static void TEST_stlsoft_C_strnistrn_CASE_FOLD_AT_END(void); +static void TEST_stlsoft_C_strnistrn_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_strnistrn_MATCH_AT_END(void); +static void TEST_stlsoft_C_strnistrn_MISS(void); +static void TEST_stlsoft_C_strnistrn_FIRST_CHAR_ONLY_THEN_MATCH(void); +static void TEST_stlsoft_C_strnistrn_DOES_NOT_READ_PAST_n1(void); +static void TEST_stlsoft_C_strnistrn_DOES_NOT_READ_PAST_n2(void); +static void TEST_stlsoft_C_strnistrn_SINGLE_BYTE(void); +static void TEST_stlsoft_C_strnistrn_HIGH_BIT(void); +static void TEST_stlsoft_C_wcsnistrn_n2_0(void); +static void TEST_stlsoft_C_wcsnistrn_n1_0(void); +static void TEST_stlsoft_C_wcsnistrn_n2_GT_n1(void); +static void TEST_stlsoft_C_wcsnistrn_EXACT_MATCH(void); +static void TEST_stlsoft_C_wcsnistrn_CASE_FOLD_FULL(void); +static void TEST_stlsoft_C_wcsnistrn_CASE_FOLD_IN_MIDDLE(void); +static void TEST_stlsoft_C_wcsnistrn_CASE_FOLD_AT_END(void); +static void TEST_stlsoft_C_wcsnistrn_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_wcsnistrn_MATCH_AT_END(void); +static void TEST_stlsoft_C_wcsnistrn_MISS(void); +static void TEST_stlsoft_C_wcsnistrn_FIRST_CHAR_ONLY_THEN_MATCH(void); +static void TEST_stlsoft_C_wcsnistrn_DOES_NOT_READ_PAST_n1(void); +static void TEST_stlsoft_C_wcsnistrn_DOES_NOT_READ_PAST_n2(void); +static void TEST_stlsoft_C_wcsnistrn_SINGLE_BYTE(void); +static void TEST_stlsoft_C_wcsnistrn_HIGH_BIT(void); + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnistrn.C", verbosity)) + { + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_n2_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_n1_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_n2_GT_n1); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_EXACT_MATCH); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_CASE_FOLD_FULL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_CASE_FOLD_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_CASE_FOLD_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_FIRST_CHAR_ONLY_THEN_MATCH); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_DOES_NOT_READ_PAST_n1); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_DOES_NOT_READ_PAST_n2); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_SINGLE_BYTE); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_HIGH_BIT); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_n2_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_n1_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_n2_GT_n1); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_EXACT_MATCH); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_CASE_FOLD_FULL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_CASE_FOLD_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_CASE_FOLD_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_FIRST_CHAR_ONLY_THEN_MATCH); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_DOES_NOT_READ_PAST_n1); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_DOES_NOT_READ_PAST_n2); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_SINGLE_BYTE); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_HIGH_BIT); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +static void TEST_stlsoft_C_strnistrn_n2_0(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft_C_strnistrn(s, 3, "", 0)); + TEST_PTR_EQ(s, stlsoft_C_strnistrn(s, 0, "xyz", 0)); +} + +static void TEST_stlsoft_C_strnistrn_n1_0(void) +{ + TEST_PTR_NULL(stlsoft_C_strnistrn("abc", 0, "a", 1)); +} + +static void TEST_stlsoft_C_strnistrn_n2_GT_n1(void) +{ + TEST_PTR_NULL(stlsoft_C_strnistrn("ab", 2, "abc", 3)); +} + +static void TEST_stlsoft_C_strnistrn_EXACT_MATCH(void) +{ + char const s[] = "abcdef"; + + TEST_PTR_EQ(s, stlsoft_C_strnistrn(s, 6, "abc", 3)); + TEST_PTR_EQ(s, stlsoft_C_strnistrn(s, 3, "abc", 3)); +} + +static void TEST_stlsoft_C_strnistrn_CASE_FOLD_FULL(void) +{ + char const s[] = "xxAbCxx"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnistrn(s, 7, "aBc", 3)); + TEST_PTR_EQ(s + 2, stlsoft_C_strnistrn(s, 7, "ABC", 3)); +} + +static void TEST_stlsoft_C_strnistrn_CASE_FOLD_IN_MIDDLE(void) +{ + char const s[] = "aBc"; + + TEST_PTR_EQ(s, stlsoft_C_strnistrn(s, 3, "abc", 3)); + TEST_PTR_NULL(stlsoft_C_strnistrn(s, 3, "axc", 3)); +} + +static void TEST_stlsoft_C_strnistrn_CASE_FOLD_AT_END(void) +{ + char const s[] = "zzAB"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnistrn(s, 4, "ab", 2)); + TEST_PTR_NULL(stlsoft_C_strnistrn(s, 3, "ab", 2)); +} + +static void TEST_stlsoft_C_strnistrn_MATCH_IN_MIDDLE(void) +{ + char const s[] = "xxabcxx"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnistrn(s, 7, "AbC", 3)); +} + +static void TEST_stlsoft_C_strnistrn_MATCH_AT_END(void) +{ + char const s[] = "xxabc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnistrn(s, 5, "ABC", 3)); +} + +static void TEST_stlsoft_C_strnistrn_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_strnistrn("abcdef", 6, "zzz", 3)); + TEST_PTR_NULL(stlsoft_C_strnistrn("abcdef", 6, "abx", 3)); + TEST_PTR_NULL(stlsoft_C_strnistrn("aXY", 3, "abc", 3)); +} + +static void TEST_stlsoft_C_strnistrn_FIRST_CHAR_ONLY_THEN_MATCH(void) +{ + char const s[] = "aXYabc"; + + TEST_PTR_EQ(s + 3, stlsoft_C_strnistrn(s, 6, "ABC", 3)); + TEST_PTR_NULL(stlsoft_C_strnistrn("aXY", 3, "ABC", 3)); +} + +static void TEST_stlsoft_C_strnistrn_DOES_NOT_READ_PAST_n1(void) +{ + char const s[] = "xxabc"; + + TEST_PTR_NULL(stlsoft_C_strnistrn(s, 4, "ABC", 3)); + TEST_PTR_EQ(s + 2, stlsoft_C_strnistrn(s, 5, "ABC", 3)); +} + +static void TEST_stlsoft_C_strnistrn_DOES_NOT_READ_PAST_n2(void) +{ + char const hay[] = "abX"; + char const needle[] = { 'A', 'B', 'Y' }; + + TEST_PTR_EQ(hay, stlsoft_C_strnistrn(hay, 3, needle, 2)); + TEST_PTR_NULL(stlsoft_C_strnistrn(hay, 3, needle, 3)); +} + +static void TEST_stlsoft_C_strnistrn_SINGLE_BYTE(void) +{ + char const s[] = "xxA"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnistrn(s, 3, "a", 1)); + TEST_PTR_NULL(stlsoft_C_strnistrn(s, 2, "a", 1)); +} + +static void TEST_stlsoft_C_strnistrn_HIGH_BIT(void) +{ + char const hay[] = { (char)0xE9, 'A', 'b' }; + char const needle[] = { (char)0xE9, 'a', 'B' }; + char const other[] = { (char)0xE2, 'a' }; + + TEST_PTR_EQ(hay, stlsoft_C_strnistrn(hay, 3, needle, 3)); + TEST_PTR_NULL(stlsoft_C_strnistrn(hay, 2, other, 2)); +} + +static void TEST_stlsoft_C_wcsnistrn_n2_0(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnistrn(s, 3, L"", 0)); + TEST_PTR_EQ(s, stlsoft_C_wcsnistrn(s, 0, L"xyz", 0)); +} + +static void TEST_stlsoft_C_wcsnistrn_n1_0(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnistrn(L"abc", 0, L"a", 1)); +} + +static void TEST_stlsoft_C_wcsnistrn_n2_GT_n1(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnistrn(L"ab", 2, L"abc", 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_EXACT_MATCH(void) +{ + wchar_t const s[] = L"abcdef"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnistrn(s, 6, L"abc", 3)); + TEST_PTR_EQ(s, stlsoft_C_wcsnistrn(s, 3, L"abc", 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_CASE_FOLD_FULL(void) +{ + wchar_t const s[] = L"xxAbCxx"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnistrn(s, 7, L"aBc", 3)); + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnistrn(s, 7, L"ABC", 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_CASE_FOLD_IN_MIDDLE(void) +{ + wchar_t const s[] = L"aBc"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnistrn(s, 3, L"abc", 3)); + TEST_PTR_NULL(stlsoft_C_wcsnistrn(s, 3, L"axc", 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_CASE_FOLD_AT_END(void) +{ + wchar_t const s[] = L"zzAB"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnistrn(s, 4, L"ab", 2)); + TEST_PTR_NULL(stlsoft_C_wcsnistrn(s, 3, L"ab", 2)); +} + +static void TEST_stlsoft_C_wcsnistrn_MATCH_IN_MIDDLE(void) +{ + wchar_t const s[] = L"xxabcxx"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnistrn(s, 7, L"AbC", 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_MATCH_AT_END(void) +{ + wchar_t const s[] = L"xxabc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnistrn(s, 5, L"ABC", 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnistrn(L"abcdef", 6, L"zzz", 3)); + TEST_PTR_NULL(stlsoft_C_wcsnistrn(L"abcdef", 6, L"abx", 3)); + TEST_PTR_NULL(stlsoft_C_wcsnistrn(L"aXY", 3, L"abc", 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_FIRST_CHAR_ONLY_THEN_MATCH(void) +{ + wchar_t const s[] = L"aXYabc"; + + TEST_PTR_EQ(s + 3, stlsoft_C_wcsnistrn(s, 6, L"ABC", 3)); + TEST_PTR_NULL(stlsoft_C_wcsnistrn(L"aXY", 3, L"ABC", 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_DOES_NOT_READ_PAST_n1(void) +{ + wchar_t const s[] = L"xxabc"; + + TEST_PTR_NULL(stlsoft_C_wcsnistrn(s, 4, L"ABC", 3)); + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnistrn(s, 5, L"ABC", 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_DOES_NOT_READ_PAST_n2(void) +{ + wchar_t const hay[] = L"abX"; + wchar_t const needle[] = { L'A', L'B', L'Y' }; + + TEST_PTR_EQ(hay, stlsoft_C_wcsnistrn(hay, 3, needle, 2)); + TEST_PTR_NULL(stlsoft_C_wcsnistrn(hay, 3, needle, 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_SINGLE_BYTE(void) +{ + wchar_t const s[] = L"xxA"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnistrn(s, 3, L"a", 1)); + TEST_PTR_NULL(stlsoft_C_wcsnistrn(s, 2, L"a", 1)); +} + +static void TEST_stlsoft_C_wcsnistrn_HIGH_BIT(void) +{ + wchar_t const hay[] = { L'\x00E9', L'A', L'b' }; + wchar_t const needle[] = { L'\x00E9', L'a', L'B' }; + wchar_t const other[] = { L'\x00E2', L'a' }; + + TEST_PTR_EQ(hay, stlsoft_C_wcsnistrn(hay, 3, needle, 3)); + TEST_PTR_NULL(stlsoft_C_wcsnistrn(hay, 2, other, 2)); +} + + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/test/unit/stlsoft/string/c_string/strnistrn/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnistrn/CMakeLists.txt new file mode 100644 index 000000000..c30c96bfc --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnistrn/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnistrn entry.cpp) diff --git a/test/unit/stlsoft/string/c_string/strnistrn/entry.cpp b/test/unit/stlsoft/string/c_string/strnistrn/entry.cpp new file mode 100644 index 000000000..5f4720206 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnistrn/entry.cpp @@ -0,0 +1,373 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnistrn/entry.cpp + * + * Purpose: Unit-tests for stlsoft::c_string::strnistrn() and wcsnistrn(). + * + * Created: 23rd October 2026 + * Updated: 23rd October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +namespace +{ + + static void TEST_c_string_strnistrn_n2_0(); + static void TEST_c_string_strnistrn_n1_0(); + static void TEST_c_string_strnistrn_n2_GT_n1(); + static void TEST_c_string_strnistrn_EXACT_MATCH(); + static void TEST_c_string_strnistrn_CASE_FOLD_FULL(); + static void TEST_c_string_strnistrn_CASE_FOLD_IN_MIDDLE(); + static void TEST_c_string_strnistrn_CASE_FOLD_AT_END(); + static void TEST_c_string_strnistrn_MATCH_IN_MIDDLE(); + static void TEST_c_string_strnistrn_MATCH_AT_END(); + static void TEST_c_string_strnistrn_MISS(); + static void TEST_c_string_strnistrn_FIRST_CHAR_ONLY_THEN_MATCH(); + static void TEST_c_string_strnistrn_DOES_NOT_READ_PAST_n1(); + static void TEST_c_string_strnistrn_DOES_NOT_READ_PAST_n2(); + static void TEST_c_string_strnistrn_SINGLE_BYTE(); + static void TEST_c_string_strnistrn_HIGH_BIT(); + static void TEST_c_string_wcsnistrn_n2_0(); + static void TEST_c_string_wcsnistrn_n1_0(); + static void TEST_c_string_wcsnistrn_n2_GT_n1(); + static void TEST_c_string_wcsnistrn_EXACT_MATCH(); + static void TEST_c_string_wcsnistrn_CASE_FOLD_FULL(); + static void TEST_c_string_wcsnistrn_CASE_FOLD_IN_MIDDLE(); + static void TEST_c_string_wcsnistrn_CASE_FOLD_AT_END(); + static void TEST_c_string_wcsnistrn_MATCH_IN_MIDDLE(); + static void TEST_c_string_wcsnistrn_MATCH_AT_END(); + static void TEST_c_string_wcsnistrn_MISS(); + static void TEST_c_string_wcsnistrn_FIRST_CHAR_ONLY_THEN_MATCH(); + static void TEST_c_string_wcsnistrn_DOES_NOT_READ_PAST_n1(); + static void TEST_c_string_wcsnistrn_DOES_NOT_READ_PAST_n2(); + static void TEST_c_string_wcsnistrn_SINGLE_BYTE(); + static void TEST_c_string_wcsnistrn_HIGH_BIT(); + + static wchar_t const* wcsnistrn_both_(wchar_t const* s1, size_t n1, wchar_t const* s2, size_t n2); + +} /* anonymous namespace */ + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnistrn", verbosity)) + { + XTESTS_RUN_CASE(TEST_c_string_strnistrn_n2_0); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_n1_0); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_n2_GT_n1); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_EXACT_MATCH); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_CASE_FOLD_FULL); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_CASE_FOLD_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_CASE_FOLD_AT_END); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_MISS); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_FIRST_CHAR_ONLY_THEN_MATCH); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_DOES_NOT_READ_PAST_n1); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_DOES_NOT_READ_PAST_n2); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_SINGLE_BYTE); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_HIGH_BIT); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_n2_0); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_n1_0); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_n2_GT_n1); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_EXACT_MATCH); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_CASE_FOLD_FULL); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_CASE_FOLD_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_CASE_FOLD_AT_END); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_MISS); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_FIRST_CHAR_ONLY_THEN_MATCH); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_DOES_NOT_READ_PAST_n1); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_DOES_NOT_READ_PAST_n2); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_SINGLE_BYTE); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_HIGH_BIT); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +namespace +{ + +static wchar_t const* wcsnistrn_both_(wchar_t const* s1, size_t n1, wchar_t const* s2, size_t n2) +{ + wchar_t const* const via_str = stlsoft::c_string::strnistrn(s1, n1, s2, n2); + wchar_t const* const via_wcs = stlsoft::c_string::wcsnistrn(s1, n1, s2, n2); + + TEST_PTR_EQ(via_wcs, via_str); + + return via_wcs; +} + +static void TEST_c_string_strnistrn_n2_0() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnistrn(s, 3, "", 0)); + TEST_PTR_EQ(s, stlsoft::c_string::strnistrn(s, 0, "xyz", 0)); +} + +static void TEST_c_string_strnistrn_n1_0() +{ + TEST_PTR_NULL(stlsoft::c_string::strnistrn("abc", 0, "a", 1)); +} + +static void TEST_c_string_strnistrn_n2_GT_n1() +{ + TEST_PTR_NULL(stlsoft::c_string::strnistrn("ab", 2, "abc", 3)); +} + +static void TEST_c_string_strnistrn_EXACT_MATCH() +{ + char const s[] = "abcdef"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnistrn(s, 6, "abc", 3)); + TEST_PTR_EQ(s, stlsoft::c_string::strnistrn(s, 3, "abc", 3)); +} + +static void TEST_c_string_strnistrn_CASE_FOLD_FULL() +{ + char const s[] = "xxAbCxx"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnistrn(s, 7, "aBc", 3)); + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnistrn(s, 7, "ABC", 3)); +} + +static void TEST_c_string_strnistrn_CASE_FOLD_IN_MIDDLE() +{ + char const s[] = "aBc"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnistrn(s, 3, "abc", 3)); + TEST_PTR_NULL(stlsoft::c_string::strnistrn(s, 3, "axc", 3)); +} + +static void TEST_c_string_strnistrn_CASE_FOLD_AT_END() +{ + char const s[] = "zzAB"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnistrn(s, 4, "ab", 2)); + TEST_PTR_NULL(stlsoft::c_string::strnistrn(s, 3, "ab", 2)); +} + +static void TEST_c_string_strnistrn_MATCH_IN_MIDDLE() +{ + char const s[] = "xxabcxx"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnistrn(s, 7, "AbC", 3)); +} + +static void TEST_c_string_strnistrn_MATCH_AT_END() +{ + char const s[] = "xxabc"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnistrn(s, 5, "ABC", 3)); +} + +static void TEST_c_string_strnistrn_MISS() +{ + TEST_PTR_NULL(stlsoft::c_string::strnistrn("abcdef", 6, "zzz", 3)); + TEST_PTR_NULL(stlsoft::c_string::strnistrn("abcdef", 6, "abx", 3)); + TEST_PTR_NULL(stlsoft::c_string::strnistrn("aXY", 3, "abc", 3)); +} + +static void TEST_c_string_strnistrn_FIRST_CHAR_ONLY_THEN_MATCH() +{ + char const s[] = "aXYabc"; + + TEST_PTR_EQ(s + 3, stlsoft::c_string::strnistrn(s, 6, "ABC", 3)); + TEST_PTR_NULL(stlsoft::c_string::strnistrn("aXY", 3, "ABC", 3)); +} + +static void TEST_c_string_strnistrn_DOES_NOT_READ_PAST_n1() +{ + char const s[] = "xxabc"; + + TEST_PTR_NULL(stlsoft::c_string::strnistrn(s, 4, "ABC", 3)); + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnistrn(s, 5, "ABC", 3)); +} + +static void TEST_c_string_strnistrn_DOES_NOT_READ_PAST_n2() +{ + char const hay[] = "abX"; + char const needle[] = { 'A', 'B', 'Y' }; + + TEST_PTR_EQ(hay, stlsoft::c_string::strnistrn(hay, 3, needle, 2)); + TEST_PTR_NULL(stlsoft::c_string::strnistrn(hay, 3, needle, 3)); +} + +static void TEST_c_string_strnistrn_SINGLE_BYTE() +{ + char const s[] = "xxA"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnistrn(s, 3, "a", 1)); + TEST_PTR_NULL(stlsoft::c_string::strnistrn(s, 2, "a", 1)); +} + +static void TEST_c_string_strnistrn_HIGH_BIT() +{ + char const hay[] = { (char)0xE9, 'A', 'b' }; + char const needle[] = { (char)0xE9, 'a', 'B' }; + char const other[] = { (char)0xE2, 'a' }; + + TEST_PTR_EQ(hay, stlsoft::c_string::strnistrn(hay, 3, needle, 3)); + TEST_PTR_NULL(stlsoft::c_string::strnistrn(hay, 2, other, 2)); +} + +static void TEST_c_string_wcsnistrn_n2_0() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, wcsnistrn_both_(s, 3, L"", 0)); + TEST_PTR_EQ(s, wcsnistrn_both_(s, 0, L"xyz", 0)); +} + +static void TEST_c_string_wcsnistrn_n1_0() +{ + TEST_PTR_NULL(wcsnistrn_both_(L"abc", 0, L"a", 1)); +} + +static void TEST_c_string_wcsnistrn_n2_GT_n1() +{ + TEST_PTR_NULL(wcsnistrn_both_(L"ab", 2, L"abc", 3)); +} + +static void TEST_c_string_wcsnistrn_EXACT_MATCH() +{ + wchar_t const s[] = L"abcdef"; + + TEST_PTR_EQ(s, wcsnistrn_both_(s, 6, L"abc", 3)); + TEST_PTR_EQ(s, wcsnistrn_both_(s, 3, L"abc", 3)); +} + +static void TEST_c_string_wcsnistrn_CASE_FOLD_FULL() +{ + wchar_t const s[] = L"xxAbCxx"; + + TEST_PTR_EQ(s + 2, wcsnistrn_both_(s, 7, L"aBc", 3)); + TEST_PTR_EQ(s + 2, wcsnistrn_both_(s, 7, L"ABC", 3)); +} + +static void TEST_c_string_wcsnistrn_CASE_FOLD_IN_MIDDLE() +{ + wchar_t const s[] = L"aBc"; + + TEST_PTR_EQ(s, wcsnistrn_both_(s, 3, L"abc", 3)); + TEST_PTR_NULL(wcsnistrn_both_(s, 3, L"axc", 3)); +} + +static void TEST_c_string_wcsnistrn_CASE_FOLD_AT_END() +{ + wchar_t const s[] = L"zzAB"; + + TEST_PTR_EQ(s + 2, wcsnistrn_both_(s, 4, L"ab", 2)); + TEST_PTR_NULL(wcsnistrn_both_(s, 3, L"ab", 2)); +} + +static void TEST_c_string_wcsnistrn_MATCH_IN_MIDDLE() +{ + wchar_t const s[] = L"xxabcxx"; + + TEST_PTR_EQ(s + 2, wcsnistrn_both_(s, 7, L"AbC", 3)); +} + +static void TEST_c_string_wcsnistrn_MATCH_AT_END() +{ + wchar_t const s[] = L"xxabc"; + + TEST_PTR_EQ(s + 2, wcsnistrn_both_(s, 5, L"ABC", 3)); +} + +static void TEST_c_string_wcsnistrn_MISS() +{ + TEST_PTR_NULL(wcsnistrn_both_(L"abcdef", 6, L"zzz", 3)); + TEST_PTR_NULL(wcsnistrn_both_(L"abcdef", 6, L"abx", 3)); + TEST_PTR_NULL(wcsnistrn_both_(L"aXY", 3, L"abc", 3)); +} + +static void TEST_c_string_wcsnistrn_FIRST_CHAR_ONLY_THEN_MATCH() +{ + wchar_t const s[] = L"aXYabc"; + + TEST_PTR_EQ(s + 3, wcsnistrn_both_(s, 6, L"ABC", 3)); + TEST_PTR_NULL(wcsnistrn_both_(L"aXY", 3, L"ABC", 3)); +} + +static void TEST_c_string_wcsnistrn_DOES_NOT_READ_PAST_n1() +{ + wchar_t const s[] = L"xxabc"; + + TEST_PTR_NULL(wcsnistrn_both_(s, 4, L"ABC", 3)); + TEST_PTR_EQ(s + 2, wcsnistrn_both_(s, 5, L"ABC", 3)); +} + +static void TEST_c_string_wcsnistrn_DOES_NOT_READ_PAST_n2() +{ + wchar_t const hay[] = L"abX"; + wchar_t const needle[] = { L'A', L'B', L'Y' }; + + TEST_PTR_EQ(hay, wcsnistrn_both_(hay, 3, needle, 2)); + TEST_PTR_NULL(wcsnistrn_both_(hay, 3, needle, 3)); +} + +static void TEST_c_string_wcsnistrn_SINGLE_BYTE() +{ + wchar_t const s[] = L"xxA"; + + TEST_PTR_EQ(s + 2, wcsnistrn_both_(s, 3, L"a", 1)); + TEST_PTR_NULL(wcsnistrn_both_(s, 2, L"a", 1)); +} + +static void TEST_c_string_wcsnistrn_HIGH_BIT() +{ + wchar_t const hay[] = { L'\x00E9', L'A', L'b' }; + wchar_t const needle[] = { L'\x00E9', L'a', L'B' }; + wchar_t const other[] = { L'\x00E2', L'a' }; + + TEST_PTR_EQ(hay, wcsnistrn_both_(hay, 3, needle, 3)); + TEST_PTR_NULL(wcsnistrn_both_(hay, 2, other, 2)); +} + +} /* anonymous namespace */ + + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/test/unit/stlsoft/string/c_string/strnpbrkn.C/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnpbrkn.C/CMakeLists.txt new file mode 100644 index 000000000..9b2707e8b --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnpbrkn.C/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnpbrkn.C entry.c) diff --git a/test/unit/stlsoft/string/c_string/strnpbrkn.C/entry.c b/test/unit/stlsoft/string/c_string/strnpbrkn.C/entry.c new file mode 100644 index 000000000..b43737693 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnpbrkn.C/entry.c @@ -0,0 +1,325 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnpbrkn.C/entry.c + * + * Purpose: Unit-tests for stlsoft_C_strnpbrkn() and stlsoft_C_wcsnpbrkn(). + * + * Created: 23rd October 2026 + * Updated: 23rd October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +static void TEST_stlsoft_C_strnpbrkn_cchStr_0(void); +static void TEST_stlsoft_C_strnpbrkn_cchCharSet_0(void); +static void TEST_stlsoft_C_strnpbrkn_MATCH_AT_START_FIRST_IN_SET(void); +static void TEST_stlsoft_C_strnpbrkn_MATCH_AT_START_LAST_IN_SET(void); +static void TEST_stlsoft_C_strnpbrkn_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_strnpbrkn_MATCH_AT_END(void); +static void TEST_stlsoft_C_strnpbrkn_FIRST_OF_SEVERAL(void); +static void TEST_stlsoft_C_strnpbrkn_MISS(void); +static void TEST_stlsoft_C_strnpbrkn_DOES_NOT_READ_PAST_cchStr(void); +static void TEST_stlsoft_C_strnpbrkn_DOES_NOT_READ_PAST_cchCharSet(void); +static void TEST_stlsoft_C_strnpbrkn_EMBEDDED_NUL_IN_STRING(void); +static void TEST_stlsoft_C_strnpbrkn_NUL_IN_SET(void); +static void TEST_stlsoft_C_strnpbrkn_SINGLE_BYTE_SET(void); +static void TEST_stlsoft_C_strnpbrkn_SET_LONGER_THAN_STRING(void); +static void TEST_stlsoft_C_wcsnpbrkn_cchStr_0(void); +static void TEST_stlsoft_C_wcsnpbrkn_cchCharSet_0(void); +static void TEST_stlsoft_C_wcsnpbrkn_MATCH_AT_START_FIRST_IN_SET(void); +static void TEST_stlsoft_C_wcsnpbrkn_MATCH_AT_START_LAST_IN_SET(void); +static void TEST_stlsoft_C_wcsnpbrkn_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_wcsnpbrkn_MATCH_AT_END(void); +static void TEST_stlsoft_C_wcsnpbrkn_FIRST_OF_SEVERAL(void); +static void TEST_stlsoft_C_wcsnpbrkn_MISS(void); +static void TEST_stlsoft_C_wcsnpbrkn_DOES_NOT_READ_PAST_cchStr(void); +static void TEST_stlsoft_C_wcsnpbrkn_DOES_NOT_READ_PAST_cchCharSet(void); +static void TEST_stlsoft_C_wcsnpbrkn_EMBEDDED_NUL_IN_STRING(void); +static void TEST_stlsoft_C_wcsnpbrkn_NUL_IN_SET(void); +static void TEST_stlsoft_C_wcsnpbrkn_SINGLE_BYTE_SET(void); +static void TEST_stlsoft_C_wcsnpbrkn_SET_LONGER_THAN_STRING(void); + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnpbrkn.C", verbosity)) + { + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_cchStr_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_cchCharSet_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_MATCH_AT_START_FIRST_IN_SET); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_MATCH_AT_START_LAST_IN_SET); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_FIRST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_DOES_NOT_READ_PAST_cchStr); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_DOES_NOT_READ_PAST_cchCharSet); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_EMBEDDED_NUL_IN_STRING); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_NUL_IN_SET); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_SINGLE_BYTE_SET); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_SET_LONGER_THAN_STRING); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_cchStr_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_cchCharSet_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_MATCH_AT_START_FIRST_IN_SET); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_MATCH_AT_START_LAST_IN_SET); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_FIRST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_DOES_NOT_READ_PAST_cchStr); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_DOES_NOT_READ_PAST_cchCharSet); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_EMBEDDED_NUL_IN_STRING); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_NUL_IN_SET); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_SINGLE_BYTE_SET); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_SET_LONGER_THAN_STRING); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +static void TEST_stlsoft_C_strnpbrkn_cchStr_0(void) +{ + TEST_PTR_NULL(stlsoft_C_strnpbrkn("abc", 0, "a", 1)); + TEST_PTR_NULL(stlsoft_C_strnpbrkn("", 0, "", 0)); +} + +static void TEST_stlsoft_C_strnpbrkn_cchCharSet_0(void) +{ + TEST_PTR_NULL(stlsoft_C_strnpbrkn("abc", 3, "xyz", 0)); + TEST_PTR_NULL(stlsoft_C_strnpbrkn("abc", 3, "", 0)); +} + +static void TEST_stlsoft_C_strnpbrkn_MATCH_AT_START_FIRST_IN_SET(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft_C_strnpbrkn(s, 3, "ax", 2)); +} + +static void TEST_stlsoft_C_strnpbrkn_MATCH_AT_START_LAST_IN_SET(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft_C_strnpbrkn(s, 3, "xya", 3)); +} + +static void TEST_stlsoft_C_strnpbrkn_MATCH_IN_MIDDLE(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnpbrkn(s, 3, "xb", 2)); +} + +static void TEST_stlsoft_C_strnpbrkn_MATCH_AT_END(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnpbrkn(s, 3, "zc", 2)); +} + +static void TEST_stlsoft_C_strnpbrkn_FIRST_OF_SEVERAL(void) +{ + char const s[] = "bXa"; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnpbrkn(s, 3, "aX", 2)); +} + +static void TEST_stlsoft_C_strnpbrkn_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_strnpbrkn("abc", 3, "xyz", 3)); +} + +static void TEST_stlsoft_C_strnpbrkn_DOES_NOT_READ_PAST_cchStr(void) +{ + char const s[] = "abcZ"; + + TEST_PTR_NULL(stlsoft_C_strnpbrkn(s, 3, "Z", 1)); + TEST_PTR_EQ(s + 3, stlsoft_C_strnpbrkn(s, 4, "Z", 1)); +} + +static void TEST_stlsoft_C_strnpbrkn_DOES_NOT_READ_PAST_cchCharSet(void) +{ + char const str[] = "Zzz"; + char const set[] = { 'x', 'y', 'Z' }; + + TEST_PTR_NULL(stlsoft_C_strnpbrkn(str, 3, set, 2)); + TEST_PTR_EQ(str, stlsoft_C_strnpbrkn(str, 3, set, 3)); +} + +static void TEST_stlsoft_C_strnpbrkn_EMBEDDED_NUL_IN_STRING(void) +{ + char const str[] = { 'a', '\0', 'b' }; + char const set[] = { 'b' }; + + TEST_PTR_EQ(str + 2, stlsoft_C_strnpbrkn(str, 3, set, 1)); + TEST_PTR_NULL(stlsoft_C_strnpbrkn(str, 2, set, 1)); +} + +static void TEST_stlsoft_C_strnpbrkn_NUL_IN_SET(void) +{ + char const str[] = { 'a', '\0', 'b' }; + char const set[] = { 'x', '\0', 'q' }; + + TEST_PTR_EQ(str + 1, stlsoft_C_strnpbrkn(str, 3, set, 3)); + TEST_PTR_NULL(stlsoft_C_strnpbrkn(str, 3, set, 1)); +} + +static void TEST_stlsoft_C_strnpbrkn_SINGLE_BYTE_SET(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnpbrkn(s, 3, "b", 1)); + TEST_PTR_NULL(stlsoft_C_strnpbrkn(s, 3, "z", 1)); +} + +static void TEST_stlsoft_C_strnpbrkn_SET_LONGER_THAN_STRING(void) +{ + char const s[] = "b"; + + TEST_PTR_EQ(s, stlsoft_C_strnpbrkn(s, 1, "xyzb", 4)); + TEST_PTR_NULL(stlsoft_C_strnpbrkn(s, 1, "xyza", 4)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_cchStr_0(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(L"abc", 0, L"a", 1)); + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(L"", 0, L"", 0)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_cchCharSet_0(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(L"abc", 3, L"xyz", 0)); + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(L"abc", 3, L"", 0)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_MATCH_AT_START_FIRST_IN_SET(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnpbrkn(s, 3, L"ax", 2)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_MATCH_AT_START_LAST_IN_SET(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnpbrkn(s, 3, L"xya", 3)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_MATCH_IN_MIDDLE(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnpbrkn(s, 3, L"xb", 2)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_MATCH_AT_END(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnpbrkn(s, 3, L"zc", 2)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_FIRST_OF_SEVERAL(void) +{ + wchar_t const s[] = L"bXa"; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnpbrkn(s, 3, L"aX", 2)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(L"abc", 3, L"xyz", 3)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_DOES_NOT_READ_PAST_cchStr(void) +{ + wchar_t const s[] = L"abcZ"; + + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(s, 3, L"Z", 1)); + TEST_PTR_EQ(s + 3, stlsoft_C_wcsnpbrkn(s, 4, L"Z", 1)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_DOES_NOT_READ_PAST_cchCharSet(void) +{ + wchar_t const str[] = L"Zzz"; + wchar_t const set[] = { L'x', L'y', L'Z' }; + + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(str, 3, set, 2)); + TEST_PTR_EQ(str, stlsoft_C_wcsnpbrkn(str, 3, set, 3)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_EMBEDDED_NUL_IN_STRING(void) +{ + wchar_t const str[] = { L'a', L'\0', L'b' }; + wchar_t const set[] = { L'b' }; + + TEST_PTR_EQ(str + 2, stlsoft_C_wcsnpbrkn(str, 3, set, 1)); + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(str, 2, set, 1)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_NUL_IN_SET(void) +{ + wchar_t const str[] = { L'a', L'\0', L'b' }; + wchar_t const set[] = { L'x', L'\0', L'q' }; + + TEST_PTR_EQ(str + 1, stlsoft_C_wcsnpbrkn(str, 3, set, 3)); + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(str, 3, set, 1)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_SINGLE_BYTE_SET(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnpbrkn(s, 3, L"b", 1)); + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(s, 3, L"z", 1)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_SET_LONGER_THAN_STRING(void) +{ + wchar_t const s[] = L"b"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnpbrkn(s, 1, L"xyzb", 4)); + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(s, 1, L"xyza", 4)); +} + + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/test/unit/stlsoft/string/c_string/strnpbrkn/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnpbrkn/CMakeLists.txt new file mode 100644 index 000000000..b345c981a --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnpbrkn/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnpbrkn entry.cpp) diff --git a/test/unit/stlsoft/string/c_string/strnpbrkn/entry.cpp b/test/unit/stlsoft/string/c_string/strnpbrkn/entry.cpp new file mode 100644 index 000000000..99c6cc499 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnpbrkn/entry.cpp @@ -0,0 +1,347 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnpbrkn/entry.cpp + * + * Purpose: Unit-tests for stlsoft::c_string::strnpbrkn() and wcsnpbrkn(). + * + * Created: 23rd October 2026 + * Updated: 23rd October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +namespace +{ + + static void TEST_c_string_strnpbrkn_cchStr_0(); + static void TEST_c_string_strnpbrkn_cchCharSet_0(); + static void TEST_c_string_strnpbrkn_MATCH_AT_START_FIRST_IN_SET(); + static void TEST_c_string_strnpbrkn_MATCH_AT_START_LAST_IN_SET(); + static void TEST_c_string_strnpbrkn_MATCH_IN_MIDDLE(); + static void TEST_c_string_strnpbrkn_MATCH_AT_END(); + static void TEST_c_string_strnpbrkn_FIRST_OF_SEVERAL(); + static void TEST_c_string_strnpbrkn_MISS(); + static void TEST_c_string_strnpbrkn_DOES_NOT_READ_PAST_cchStr(); + static void TEST_c_string_strnpbrkn_DOES_NOT_READ_PAST_cchCharSet(); + static void TEST_c_string_strnpbrkn_EMBEDDED_NUL_IN_STRING(); + static void TEST_c_string_strnpbrkn_NUL_IN_SET(); + static void TEST_c_string_strnpbrkn_SINGLE_BYTE_SET(); + static void TEST_c_string_strnpbrkn_SET_LONGER_THAN_STRING(); + static void TEST_c_string_wcsnpbrkn_cchStr_0(); + static void TEST_c_string_wcsnpbrkn_cchCharSet_0(); + static void TEST_c_string_wcsnpbrkn_MATCH_AT_START_FIRST_IN_SET(); + static void TEST_c_string_wcsnpbrkn_MATCH_AT_START_LAST_IN_SET(); + static void TEST_c_string_wcsnpbrkn_MATCH_IN_MIDDLE(); + static void TEST_c_string_wcsnpbrkn_MATCH_AT_END(); + static void TEST_c_string_wcsnpbrkn_FIRST_OF_SEVERAL(); + static void TEST_c_string_wcsnpbrkn_MISS(); + static void TEST_c_string_wcsnpbrkn_DOES_NOT_READ_PAST_cchStr(); + static void TEST_c_string_wcsnpbrkn_DOES_NOT_READ_PAST_cchCharSet(); + static void TEST_c_string_wcsnpbrkn_EMBEDDED_NUL_IN_STRING(); + static void TEST_c_string_wcsnpbrkn_NUL_IN_SET(); + static void TEST_c_string_wcsnpbrkn_SINGLE_BYTE_SET(); + static void TEST_c_string_wcsnpbrkn_SET_LONGER_THAN_STRING(); + + static wchar_t const* wcsnpbrkn_both_(wchar_t const* str, size_t cchStr, wchar_t const* charSet, size_t cchCharSet); + +} /* anonymous namespace */ + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnpbrkn", verbosity)) + { + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_cchStr_0); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_cchCharSet_0); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_MATCH_AT_START_FIRST_IN_SET); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_MATCH_AT_START_LAST_IN_SET); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_FIRST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_MISS); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_DOES_NOT_READ_PAST_cchStr); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_DOES_NOT_READ_PAST_cchCharSet); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_EMBEDDED_NUL_IN_STRING); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_NUL_IN_SET); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_SINGLE_BYTE_SET); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_SET_LONGER_THAN_STRING); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_cchStr_0); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_cchCharSet_0); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_MATCH_AT_START_FIRST_IN_SET); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_MATCH_AT_START_LAST_IN_SET); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_FIRST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_MISS); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_DOES_NOT_READ_PAST_cchStr); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_DOES_NOT_READ_PAST_cchCharSet); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_EMBEDDED_NUL_IN_STRING); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_NUL_IN_SET); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_SINGLE_BYTE_SET); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_SET_LONGER_THAN_STRING); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +namespace +{ + +static wchar_t const* wcsnpbrkn_both_(wchar_t const* str, size_t cchStr, wchar_t const* charSet, size_t cchCharSet) +{ + wchar_t const* const via_str = stlsoft::c_string::strnpbrkn(str, cchStr, charSet, cchCharSet); + wchar_t const* const via_wcs = stlsoft::c_string::wcsnpbrkn(str, cchStr, charSet, cchCharSet); + + TEST_PTR_EQ(via_wcs, via_str); + + return via_wcs; +} + +static void TEST_c_string_strnpbrkn_cchStr_0() +{ + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn("abc", 0, "a", 1)); + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn("", 0, "", 0)); +} + +static void TEST_c_string_strnpbrkn_cchCharSet_0() +{ + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn("abc", 3, "xyz", 0)); + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn("abc", 3, "", 0)); +} + +static void TEST_c_string_strnpbrkn_MATCH_AT_START_FIRST_IN_SET() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnpbrkn(s, 3, "ax", 2)); +} + +static void TEST_c_string_strnpbrkn_MATCH_AT_START_LAST_IN_SET() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnpbrkn(s, 3, "xya", 3)); +} + +static void TEST_c_string_strnpbrkn_MATCH_IN_MIDDLE() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnpbrkn(s, 3, "xb", 2)); +} + +static void TEST_c_string_strnpbrkn_MATCH_AT_END() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnpbrkn(s, 3, "zc", 2)); +} + +static void TEST_c_string_strnpbrkn_FIRST_OF_SEVERAL() +{ + char const s[] = "bXa"; + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnpbrkn(s, 3, "aX", 2)); +} + +static void TEST_c_string_strnpbrkn_MISS() +{ + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn("abc", 3, "xyz", 3)); +} + +static void TEST_c_string_strnpbrkn_DOES_NOT_READ_PAST_cchStr() +{ + char const s[] = "abcZ"; + + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn(s, 3, "Z", 1)); + TEST_PTR_EQ(s + 3, stlsoft::c_string::strnpbrkn(s, 4, "Z", 1)); +} + +static void TEST_c_string_strnpbrkn_DOES_NOT_READ_PAST_cchCharSet() +{ + char const str[] = "Zzz"; + char const set[] = { 'x', 'y', 'Z' }; + + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn(str, 3, set, 2)); + TEST_PTR_EQ(str, stlsoft::c_string::strnpbrkn(str, 3, set, 3)); +} + +static void TEST_c_string_strnpbrkn_EMBEDDED_NUL_IN_STRING() +{ + char const str[] = { 'a', '\0', 'b' }; + char const set[] = { 'b' }; + + TEST_PTR_EQ(str + 2, stlsoft::c_string::strnpbrkn(str, 3, set, 1)); + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn(str, 2, set, 1)); +} + +static void TEST_c_string_strnpbrkn_NUL_IN_SET() +{ + char const str[] = { 'a', '\0', 'b' }; + char const set[] = { 'x', '\0', 'q' }; + + TEST_PTR_EQ(str + 1, stlsoft::c_string::strnpbrkn(str, 3, set, 3)); + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn(str, 3, set, 1)); +} + +static void TEST_c_string_strnpbrkn_SINGLE_BYTE_SET() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnpbrkn(s, 3, "b", 1)); + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn(s, 3, "z", 1)); +} + +static void TEST_c_string_strnpbrkn_SET_LONGER_THAN_STRING() +{ + char const s[] = "b"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnpbrkn(s, 1, "xyzb", 4)); + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn(s, 1, "xyza", 4)); +} + +static void TEST_c_string_wcsnpbrkn_cchStr_0() +{ + TEST_PTR_NULL(wcsnpbrkn_both_(L"abc", 0, L"a", 1)); + TEST_PTR_NULL(wcsnpbrkn_both_(L"", 0, L"", 0)); +} + +static void TEST_c_string_wcsnpbrkn_cchCharSet_0() +{ + TEST_PTR_NULL(wcsnpbrkn_both_(L"abc", 3, L"xyz", 0)); + TEST_PTR_NULL(wcsnpbrkn_both_(L"abc", 3, L"", 0)); +} + +static void TEST_c_string_wcsnpbrkn_MATCH_AT_START_FIRST_IN_SET() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, wcsnpbrkn_both_(s, 3, L"ax", 2)); +} + +static void TEST_c_string_wcsnpbrkn_MATCH_AT_START_LAST_IN_SET() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, wcsnpbrkn_both_(s, 3, L"xya", 3)); +} + +static void TEST_c_string_wcsnpbrkn_MATCH_IN_MIDDLE() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, wcsnpbrkn_both_(s, 3, L"xb", 2)); +} + +static void TEST_c_string_wcsnpbrkn_MATCH_AT_END() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 2, wcsnpbrkn_both_(s, 3, L"zc", 2)); +} + +static void TEST_c_string_wcsnpbrkn_FIRST_OF_SEVERAL() +{ + wchar_t const s[] = L"bXa"; + + TEST_PTR_EQ(s + 1, wcsnpbrkn_both_(s, 3, L"aX", 2)); +} + +static void TEST_c_string_wcsnpbrkn_MISS() +{ + TEST_PTR_NULL(wcsnpbrkn_both_(L"abc", 3, L"xyz", 3)); +} + +static void TEST_c_string_wcsnpbrkn_DOES_NOT_READ_PAST_cchStr() +{ + wchar_t const s[] = L"abcZ"; + + TEST_PTR_NULL(wcsnpbrkn_both_(s, 3, L"Z", 1)); + TEST_PTR_EQ(s + 3, wcsnpbrkn_both_(s, 4, L"Z", 1)); +} + +static void TEST_c_string_wcsnpbrkn_DOES_NOT_READ_PAST_cchCharSet() +{ + wchar_t const str[] = L"Zzz"; + wchar_t const set[] = { L'x', L'y', L'Z' }; + + TEST_PTR_NULL(wcsnpbrkn_both_(str, 3, set, 2)); + TEST_PTR_EQ(str, wcsnpbrkn_both_(str, 3, set, 3)); +} + +static void TEST_c_string_wcsnpbrkn_EMBEDDED_NUL_IN_STRING() +{ + wchar_t const str[] = { L'a', L'\0', L'b' }; + wchar_t const set[] = { L'b' }; + + TEST_PTR_EQ(str + 2, wcsnpbrkn_both_(str, 3, set, 1)); + TEST_PTR_NULL(wcsnpbrkn_both_(str, 2, set, 1)); +} + +static void TEST_c_string_wcsnpbrkn_NUL_IN_SET() +{ + wchar_t const str[] = { L'a', L'\0', L'b' }; + wchar_t const set[] = { L'x', L'\0', L'q' }; + + TEST_PTR_EQ(str + 1, wcsnpbrkn_both_(str, 3, set, 3)); + TEST_PTR_NULL(wcsnpbrkn_both_(str, 3, set, 1)); +} + +static void TEST_c_string_wcsnpbrkn_SINGLE_BYTE_SET() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, wcsnpbrkn_both_(s, 3, L"b", 1)); + TEST_PTR_NULL(wcsnpbrkn_both_(s, 3, L"z", 1)); +} + +static void TEST_c_string_wcsnpbrkn_SET_LONGER_THAN_STRING() +{ + wchar_t const s[] = L"b"; + + TEST_PTR_EQ(s, wcsnpbrkn_both_(s, 1, L"xyzb", 4)); + TEST_PTR_NULL(wcsnpbrkn_both_(s, 1, L"xyza", 4)); +} + +} /* anonymous namespace */ + + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/test/unit/stlsoft/string/c_string/strnrchr.C/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnrchr.C/CMakeLists.txt new file mode 100644 index 000000000..7b30a40c0 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnrchr.C/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnrchr.C entry.c) diff --git a/test/unit/stlsoft/string/c_string/strnrchr.C/entry.c b/test/unit/stlsoft/string/c_string/strnrchr.C/entry.c new file mode 100644 index 000000000..ae851c44a --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnrchr.C/entry.c @@ -0,0 +1,253 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnrchr.C/entry.c + * + * Purpose: Unit-tests for stlsoft_C_strnrchr() and stlsoft_C_wcsnrchr(). + * + * Created: 23rd October 2026 + * Updated: 23rd October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +static void TEST_stlsoft_C_strnrchr_n_0(void); +static void TEST_stlsoft_C_strnrchr_MATCH_AT_END(void); +static void TEST_stlsoft_C_strnrchr_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_strnrchr_MATCH_AT_START(void); +static void TEST_stlsoft_C_strnrchr_LAST_OF_SEVERAL(void); +static void TEST_stlsoft_C_strnrchr_MISS(void); +static void TEST_stlsoft_C_strnrchr_DOES_NOT_READ_PAST_n(void); +static void TEST_stlsoft_C_strnrchr_FINDS_EMBEDDED_NUL(void); +static void TEST_stlsoft_C_strnrchr_CONTINUES_PAST_NUL(void); +static void TEST_stlsoft_C_strnrchr_HIGH_BIT(void); +static void TEST_stlsoft_C_wcsnrchr_n_0(void); +static void TEST_stlsoft_C_wcsnrchr_MATCH_AT_END(void); +static void TEST_stlsoft_C_wcsnrchr_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_wcsnrchr_MATCH_AT_START(void); +static void TEST_stlsoft_C_wcsnrchr_LAST_OF_SEVERAL(void); +static void TEST_stlsoft_C_wcsnrchr_MISS(void); +static void TEST_stlsoft_C_wcsnrchr_DOES_NOT_READ_PAST_n(void); +static void TEST_stlsoft_C_wcsnrchr_FINDS_EMBEDDED_NUL(void); +static void TEST_stlsoft_C_wcsnrchr_CONTINUES_PAST_NUL(void); +static void TEST_stlsoft_C_wcsnrchr_HIGH_BIT(void); + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnrchr.C", verbosity)) + { + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_n_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_LAST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_DOES_NOT_READ_PAST_n); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_FINDS_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_CONTINUES_PAST_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_HIGH_BIT); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_n_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_LAST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_DOES_NOT_READ_PAST_n); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_FINDS_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_CONTINUES_PAST_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_HIGH_BIT); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +static void TEST_stlsoft_C_strnrchr_n_0(void) +{ + TEST_PTR_NULL(stlsoft_C_strnrchr("abc", 0, 'a')); + TEST_PTR_NULL(stlsoft_C_strnrchr("", 0, '\0')); +} + +static void TEST_stlsoft_C_strnrchr_MATCH_AT_END(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnrchr(s, 3, 'c')); + TEST_PTR_EQ(s, stlsoft_C_strnrchr(s, 1, 'a')); +} + +static void TEST_stlsoft_C_strnrchr_MATCH_IN_MIDDLE(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnrchr(s, 3, 'b')); +} + +static void TEST_stlsoft_C_strnrchr_MATCH_AT_START(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft_C_strnrchr(s, 3, 'a')); +} + +static void TEST_stlsoft_C_strnrchr_LAST_OF_SEVERAL(void) +{ + char const s[] = "abaca"; + + TEST_PTR_EQ(s + 4, stlsoft_C_strnrchr(s, 5, 'a')); + TEST_PTR_EQ(s + 2, stlsoft_C_strnrchr(s, 4, 'a')); +} + +static void TEST_stlsoft_C_strnrchr_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_strnrchr("abc", 3, 'z')); + TEST_PTR_NULL(stlsoft_C_strnrchr("abc", 3, 'A')); +} + +static void TEST_stlsoft_C_strnrchr_DOES_NOT_READ_PAST_n(void) +{ + char const s[] = "abc"; + + TEST_PTR_NULL(stlsoft_C_strnrchr(s, 2, 'c')); + TEST_PTR_EQ(s + 2, stlsoft_C_strnrchr(s, 3, 'c')); +} + +static void TEST_stlsoft_C_strnrchr_FINDS_EMBEDDED_NUL(void) +{ + char const s[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnrchr(s, 3, '\0')); +} + +static void TEST_stlsoft_C_strnrchr_CONTINUES_PAST_NUL(void) +{ + char const s[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(s, stlsoft_C_strnrchr(s, 3, 'a')); + TEST_PTR_EQ(s + 2, stlsoft_C_strnrchr(s, 3, 'b')); + TEST_PTR_NULL(stlsoft_C_strnrchr(s, 1, 'b')); +} + +static void TEST_stlsoft_C_strnrchr_HIGH_BIT(void) +{ + char const s[] = { 'a', (char)0xE9, 'b' }; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnrchr(s, 3, s[1])); + TEST_PTR_EQ(s, stlsoft_C_strnrchr(s, 1, 'a')); + TEST_PTR_NULL(stlsoft_C_strnrchr(s, 3, 'x')); +} + +static void TEST_stlsoft_C_wcsnrchr_n_0(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnrchr(L"abc", 0, L'a')); + TEST_PTR_NULL(stlsoft_C_wcsnrchr(L"", 0, L'\0')); +} + +static void TEST_stlsoft_C_wcsnrchr_MATCH_AT_END(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnrchr(s, 3, L'c')); + TEST_PTR_EQ(s, stlsoft_C_wcsnrchr(s, 1, L'a')); +} + +static void TEST_stlsoft_C_wcsnrchr_MATCH_IN_MIDDLE(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnrchr(s, 3, L'b')); +} + +static void TEST_stlsoft_C_wcsnrchr_MATCH_AT_START(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnrchr(s, 3, L'a')); +} + +static void TEST_stlsoft_C_wcsnrchr_LAST_OF_SEVERAL(void) +{ + wchar_t const s[] = L"abaca"; + + TEST_PTR_EQ(s + 4, stlsoft_C_wcsnrchr(s, 5, L'a')); + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnrchr(s, 4, L'a')); +} + +static void TEST_stlsoft_C_wcsnrchr_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnrchr(L"abc", 3, L'z')); + TEST_PTR_NULL(stlsoft_C_wcsnrchr(L"abc", 3, L'A')); +} + +static void TEST_stlsoft_C_wcsnrchr_DOES_NOT_READ_PAST_n(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_NULL(stlsoft_C_wcsnrchr(s, 2, L'c')); + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnrchr(s, 3, L'c')); +} + +static void TEST_stlsoft_C_wcsnrchr_FINDS_EMBEDDED_NUL(void) +{ + wchar_t const s[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnrchr(s, 3, L'\0')); +} + +static void TEST_stlsoft_C_wcsnrchr_CONTINUES_PAST_NUL(void) +{ + wchar_t const s[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(s, stlsoft_C_wcsnrchr(s, 3, L'a')); + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnrchr(s, 3, L'b')); + TEST_PTR_NULL(stlsoft_C_wcsnrchr(s, 1, L'b')); +} + +static void TEST_stlsoft_C_wcsnrchr_HIGH_BIT(void) +{ + wchar_t const s[] = { L'a', L'\x00E9', L'b' }; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnrchr(s, 3, s[1])); + TEST_PTR_EQ(s, stlsoft_C_wcsnrchr(s, 1, L'a')); + TEST_PTR_NULL(stlsoft_C_wcsnrchr(s, 3, L'x')); +} + + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/test/unit/stlsoft/string/c_string/strnrchr/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnrchr/CMakeLists.txt new file mode 100644 index 000000000..82686f1a3 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnrchr/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnrchr entry.cpp) diff --git a/test/unit/stlsoft/string/c_string/strnrchr/entry.cpp b/test/unit/stlsoft/string/c_string/strnrchr/entry.cpp new file mode 100644 index 000000000..401c62bd0 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnrchr/entry.cpp @@ -0,0 +1,275 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnrchr/entry.cpp + * + * Purpose: Unit-tests for stlsoft::c_string::strnrchr() and wcsnrchr(). + * + * Created: 23rd October 2026 + * Updated: 23rd October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +namespace +{ + + static void TEST_c_string_strnrchr_n_0(); + static void TEST_c_string_strnrchr_MATCH_AT_END(); + static void TEST_c_string_strnrchr_MATCH_IN_MIDDLE(); + static void TEST_c_string_strnrchr_MATCH_AT_START(); + static void TEST_c_string_strnrchr_LAST_OF_SEVERAL(); + static void TEST_c_string_strnrchr_MISS(); + static void TEST_c_string_strnrchr_DOES_NOT_READ_PAST_n(); + static void TEST_c_string_strnrchr_FINDS_EMBEDDED_NUL(); + static void TEST_c_string_strnrchr_CONTINUES_PAST_NUL(); + static void TEST_c_string_strnrchr_HIGH_BIT(); + static void TEST_c_string_wcsnrchr_n_0(); + static void TEST_c_string_wcsnrchr_MATCH_AT_END(); + static void TEST_c_string_wcsnrchr_MATCH_IN_MIDDLE(); + static void TEST_c_string_wcsnrchr_MATCH_AT_START(); + static void TEST_c_string_wcsnrchr_LAST_OF_SEVERAL(); + static void TEST_c_string_wcsnrchr_MISS(); + static void TEST_c_string_wcsnrchr_DOES_NOT_READ_PAST_n(); + static void TEST_c_string_wcsnrchr_FINDS_EMBEDDED_NUL(); + static void TEST_c_string_wcsnrchr_CONTINUES_PAST_NUL(); + static void TEST_c_string_wcsnrchr_HIGH_BIT(); + + static wchar_t const* wcsnrchr_both_(wchar_t const* s, size_t n, int ch); + +} /* anonymous namespace */ + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnrchr", verbosity)) + { + XTESTS_RUN_CASE(TEST_c_string_strnrchr_n_0); + XTESTS_RUN_CASE(TEST_c_string_strnrchr_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_strnrchr_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_strnrchr_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_c_string_strnrchr_LAST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_c_string_strnrchr_MISS); + XTESTS_RUN_CASE(TEST_c_string_strnrchr_DOES_NOT_READ_PAST_n); + XTESTS_RUN_CASE(TEST_c_string_strnrchr_FINDS_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_c_string_strnrchr_CONTINUES_PAST_NUL); + XTESTS_RUN_CASE(TEST_c_string_strnrchr_HIGH_BIT); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_n_0); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_LAST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_MISS); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_DOES_NOT_READ_PAST_n); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_FINDS_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_CONTINUES_PAST_NUL); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_HIGH_BIT); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +namespace +{ + +static wchar_t const* wcsnrchr_both_(wchar_t const* s, size_t n, int ch) +{ + wchar_t const* const via_str = stlsoft::c_string::strnrchr(s, n, ch); + wchar_t const* const via_wcs = stlsoft::c_string::wcsnrchr(s, n, ch); + + TEST_PTR_EQ(via_wcs, via_str); + + return via_wcs; +} + +static void TEST_c_string_strnrchr_n_0() +{ + TEST_PTR_NULL(stlsoft::c_string::strnrchr("abc", 0, 'a')); + TEST_PTR_NULL(stlsoft::c_string::strnrchr("", 0, '\0')); +} + +static void TEST_c_string_strnrchr_MATCH_AT_END() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnrchr(s, 3, 'c')); + TEST_PTR_EQ(s, stlsoft::c_string::strnrchr(s, 1, 'a')); +} + +static void TEST_c_string_strnrchr_MATCH_IN_MIDDLE() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnrchr(s, 3, 'b')); +} + +static void TEST_c_string_strnrchr_MATCH_AT_START() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnrchr(s, 3, 'a')); +} + +static void TEST_c_string_strnrchr_LAST_OF_SEVERAL() +{ + char const s[] = "abaca"; + + TEST_PTR_EQ(s + 4, stlsoft::c_string::strnrchr(s, 5, 'a')); + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnrchr(s, 4, 'a')); +} + +static void TEST_c_string_strnrchr_MISS() +{ + TEST_PTR_NULL(stlsoft::c_string::strnrchr("abc", 3, 'z')); + TEST_PTR_NULL(stlsoft::c_string::strnrchr("abc", 3, 'A')); +} + +static void TEST_c_string_strnrchr_DOES_NOT_READ_PAST_n() +{ + char const s[] = "abc"; + + TEST_PTR_NULL(stlsoft::c_string::strnrchr(s, 2, 'c')); + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnrchr(s, 3, 'c')); +} + +static void TEST_c_string_strnrchr_FINDS_EMBEDDED_NUL() +{ + char const s[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnrchr(s, 3, '\0')); +} + +static void TEST_c_string_strnrchr_CONTINUES_PAST_NUL() +{ + char const s[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(s, stlsoft::c_string::strnrchr(s, 3, 'a')); + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnrchr(s, 3, 'b')); + TEST_PTR_NULL(stlsoft::c_string::strnrchr(s, 1, 'b')); +} + +static void TEST_c_string_strnrchr_HIGH_BIT() +{ + char const s[] = { 'a', (char)0xE9, 'b' }; + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnrchr(s, 3, s[1])); + TEST_PTR_EQ(s, stlsoft::c_string::strnrchr(s, 1, 'a')); + TEST_PTR_NULL(stlsoft::c_string::strnrchr(s, 3, 'x')); +} + +static void TEST_c_string_wcsnrchr_n_0() +{ + TEST_PTR_NULL(wcsnrchr_both_(L"abc", 0, L'a')); + TEST_PTR_NULL(wcsnrchr_both_(L"", 0, L'\0')); +} + +static void TEST_c_string_wcsnrchr_MATCH_AT_END() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 2, wcsnrchr_both_(s, 3, L'c')); + TEST_PTR_EQ(s, wcsnrchr_both_(s, 1, L'a')); +} + +static void TEST_c_string_wcsnrchr_MATCH_IN_MIDDLE() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, wcsnrchr_both_(s, 3, L'b')); +} + +static void TEST_c_string_wcsnrchr_MATCH_AT_START() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, wcsnrchr_both_(s, 3, L'a')); +} + +static void TEST_c_string_wcsnrchr_LAST_OF_SEVERAL() +{ + wchar_t const s[] = L"abaca"; + + TEST_PTR_EQ(s + 4, wcsnrchr_both_(s, 5, L'a')); + TEST_PTR_EQ(s + 2, wcsnrchr_both_(s, 4, L'a')); +} + +static void TEST_c_string_wcsnrchr_MISS() +{ + TEST_PTR_NULL(wcsnrchr_both_(L"abc", 3, L'z')); + TEST_PTR_NULL(wcsnrchr_both_(L"abc", 3, L'A')); +} + +static void TEST_c_string_wcsnrchr_DOES_NOT_READ_PAST_n() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_NULL(wcsnrchr_both_(s, 2, L'c')); + TEST_PTR_EQ(s + 2, wcsnrchr_both_(s, 3, L'c')); +} + +static void TEST_c_string_wcsnrchr_FINDS_EMBEDDED_NUL() +{ + wchar_t const s[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(s + 1, wcsnrchr_both_(s, 3, L'\0')); +} + +static void TEST_c_string_wcsnrchr_CONTINUES_PAST_NUL() +{ + wchar_t const s[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(s, wcsnrchr_both_(s, 3, L'a')); + TEST_PTR_EQ(s + 2, wcsnrchr_both_(s, 3, L'b')); + TEST_PTR_NULL(wcsnrchr_both_(s, 1, L'b')); +} + +static void TEST_c_string_wcsnrchr_HIGH_BIT() +{ + wchar_t const s[] = { L'a', L'\x00E9', L'b' }; + + TEST_PTR_EQ(s + 1, wcsnrchr_both_(s, 3, s[1])); + TEST_PTR_EQ(s, wcsnrchr_both_(s, 1, L'a')); + TEST_PTR_NULL(wcsnrchr_both_(s, 3, L'x')); +} + +} /* anonymous namespace */ + + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/test/unit/stlsoft/string/c_string/strnstrn.C/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnstrn.C/CMakeLists.txt new file mode 100644 index 000000000..52a7dbc2f --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnstrn.C/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnstrn.C entry.c) diff --git a/test/unit/stlsoft/string/c_string/strnstrn.C/entry.c b/test/unit/stlsoft/string/c_string/strnstrn.C/entry.c new file mode 100644 index 000000000..d9482ee77 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnstrn.C/entry.c @@ -0,0 +1,337 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnstrn.C/entry.c + * + * Purpose: Unit-tests for stlsoft_C_strnstrn() and stlsoft_C_wcsnstrn(). + * + * Created: 23rd October 2026 + * Updated: 23rd October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +static void TEST_stlsoft_C_strnstrn_n2_0(void); +static void TEST_stlsoft_C_strnstrn_n1_0(void); +static void TEST_stlsoft_C_strnstrn_n2_GT_n1(void); +static void TEST_stlsoft_C_strnstrn_MATCH_AT_START(void); +static void TEST_stlsoft_C_strnstrn_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_strnstrn_MATCH_AT_END(void); +static void TEST_stlsoft_C_strnstrn_MISS(void); +static void TEST_stlsoft_C_strnstrn_PARTIAL_THEN_MATCH(void); +static void TEST_stlsoft_C_strnstrn_REPEATED_FIRST_BYTE(void); +static void TEST_stlsoft_C_strnstrn_DOES_NOT_READ_PAST_n1(void); +static void TEST_stlsoft_C_strnstrn_DOES_NOT_READ_PAST_n2(void); +static void TEST_stlsoft_C_strnstrn_EMBEDDED_NUL(void); +static void TEST_stlsoft_C_strnstrn_SINGLE_BYTE(void); +static void TEST_stlsoft_C_strnstrn_FULL_SPAN(void); +static void TEST_stlsoft_C_wcsnstrn_n2_0(void); +static void TEST_stlsoft_C_wcsnstrn_n1_0(void); +static void TEST_stlsoft_C_wcsnstrn_n2_GT_n1(void); +static void TEST_stlsoft_C_wcsnstrn_MATCH_AT_START(void); +static void TEST_stlsoft_C_wcsnstrn_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_wcsnstrn_MATCH_AT_END(void); +static void TEST_stlsoft_C_wcsnstrn_MISS(void); +static void TEST_stlsoft_C_wcsnstrn_PARTIAL_THEN_MATCH(void); +static void TEST_stlsoft_C_wcsnstrn_REPEATED_FIRST_BYTE(void); +static void TEST_stlsoft_C_wcsnstrn_DOES_NOT_READ_PAST_n1(void); +static void TEST_stlsoft_C_wcsnstrn_DOES_NOT_READ_PAST_n2(void); +static void TEST_stlsoft_C_wcsnstrn_EMBEDDED_NUL(void); +static void TEST_stlsoft_C_wcsnstrn_SINGLE_BYTE(void); +static void TEST_stlsoft_C_wcsnstrn_FULL_SPAN(void); + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnstrn.C", verbosity)) + { + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_n2_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_n1_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_n2_GT_n1); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_PARTIAL_THEN_MATCH); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_REPEATED_FIRST_BYTE); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_DOES_NOT_READ_PAST_n1); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_DOES_NOT_READ_PAST_n2); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_SINGLE_BYTE); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_FULL_SPAN); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_n2_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_n1_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_n2_GT_n1); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_PARTIAL_THEN_MATCH); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_REPEATED_FIRST_BYTE); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_DOES_NOT_READ_PAST_n1); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_DOES_NOT_READ_PAST_n2); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_SINGLE_BYTE); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_FULL_SPAN); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +static void TEST_stlsoft_C_strnstrn_n2_0(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft_C_strnstrn(s, 3, "", 0)); + TEST_PTR_EQ(s, stlsoft_C_strnstrn(s, 0, "", 0)); + TEST_PTR_EQ(s, stlsoft_C_strnstrn(s, 3, "xyz", 0)); +} + +static void TEST_stlsoft_C_strnstrn_n1_0(void) +{ + char const s[] = "abc"; + + TEST_PTR_NULL(stlsoft_C_strnstrn(s, 0, "a", 1)); +} + +static void TEST_stlsoft_C_strnstrn_n2_GT_n1(void) +{ + TEST_PTR_NULL(stlsoft_C_strnstrn("ab", 2, "abc", 3)); + TEST_PTR_NULL(stlsoft_C_strnstrn("abcd", 4, "abcde", 5)); +} + +static void TEST_stlsoft_C_strnstrn_MATCH_AT_START(void) +{ + char const s[] = "abcdef"; + + TEST_PTR_EQ(s, stlsoft_C_strnstrn(s, 6, "abc", 3)); + TEST_PTR_EQ(s, stlsoft_C_strnstrn(s, 3, "abc", 3)); +} + +static void TEST_stlsoft_C_strnstrn_MATCH_IN_MIDDLE(void) +{ + char const s[] = "xxabcxx"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnstrn(s, 7, "abc", 3)); +} + +static void TEST_stlsoft_C_strnstrn_MATCH_AT_END(void) +{ + char const s[] = "xxabc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnstrn(s, 5, "abc", 3)); + TEST_PTR_NULL(stlsoft_C_strnstrn(s, 4, "abc", 3)); +} + +static void TEST_stlsoft_C_strnstrn_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_strnstrn("abcdef", 6, "zzz", 3)); + TEST_PTR_NULL(stlsoft_C_strnstrn("abcdef", 6, "abx", 3)); +} + +static void TEST_stlsoft_C_strnstrn_PARTIAL_THEN_MATCH(void) +{ + char const s[] = "abXabc"; + + TEST_PTR_EQ(s + 3, stlsoft_C_strnstrn(s, 6, "abc", 3)); +} + +static void TEST_stlsoft_C_strnstrn_REPEATED_FIRST_BYTE(void) +{ + char const s[] = "aaab"; + char const t[] = "aaa"; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnstrn(s, 4, "aab", 3)); + TEST_PTR_EQ(t, stlsoft_C_strnstrn(t, 3, "aa", 2)); +} + +static void TEST_stlsoft_C_strnstrn_DOES_NOT_READ_PAST_n1(void) +{ + char const s[] = "xxabc"; + + TEST_PTR_NULL(stlsoft_C_strnstrn(s, 4, "abc", 3)); + TEST_PTR_EQ(s + 2, stlsoft_C_strnstrn(s, 5, "abc", 3)); +} + +static void TEST_stlsoft_C_strnstrn_DOES_NOT_READ_PAST_n2(void) +{ + char const hay[] = "abX"; + char const needle[] = { 'a', 'b', 'Y' }; + + TEST_PTR_EQ(hay, stlsoft_C_strnstrn(hay, 3, needle, 2)); + TEST_PTR_NULL(stlsoft_C_strnstrn(hay, 3, needle, 3)); +} + +static void TEST_stlsoft_C_strnstrn_EMBEDDED_NUL(void) +{ + char const hay[] = { 'a', '\0', 'b', 'x', 'a', '\0', 'b' }; + char const needle[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(hay, stlsoft_C_strnstrn(hay, 7, needle, 3)); + TEST_PTR_EQ(hay + 4, stlsoft_C_strnstrn(hay + 1, 6, needle, 3)); +} + +static void TEST_stlsoft_C_strnstrn_SINGLE_BYTE(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnstrn(s, 3, "b", 1)); + TEST_PTR_NULL(stlsoft_C_strnstrn(s, 3, "z", 1)); +} + +static void TEST_stlsoft_C_strnstrn_FULL_SPAN(void) +{ + char const s[] = "abcd"; + + TEST_PTR_EQ(s, stlsoft_C_strnstrn(s, 4, "abcd", 4)); + TEST_PTR_NULL(stlsoft_C_strnstrn(s, 4, "abce", 4)); +} + +static void TEST_stlsoft_C_wcsnstrn_n2_0(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnstrn(s, 3, L"", 0)); + TEST_PTR_EQ(s, stlsoft_C_wcsnstrn(s, 0, L"", 0)); + TEST_PTR_EQ(s, stlsoft_C_wcsnstrn(s, 3, L"xyz", 0)); +} + +static void TEST_stlsoft_C_wcsnstrn_n1_0(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_NULL(stlsoft_C_wcsnstrn(s, 0, L"a", 1)); +} + +static void TEST_stlsoft_C_wcsnstrn_n2_GT_n1(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnstrn(L"ab", 2, L"abc", 3)); + TEST_PTR_NULL(stlsoft_C_wcsnstrn(L"abcd", 4, L"abcde", 5)); +} + +static void TEST_stlsoft_C_wcsnstrn_MATCH_AT_START(void) +{ + wchar_t const s[] = L"abcdef"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnstrn(s, 6, L"abc", 3)); + TEST_PTR_EQ(s, stlsoft_C_wcsnstrn(s, 3, L"abc", 3)); +} + +static void TEST_stlsoft_C_wcsnstrn_MATCH_IN_MIDDLE(void) +{ + wchar_t const s[] = L"xxabcxx"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnstrn(s, 7, L"abc", 3)); +} + +static void TEST_stlsoft_C_wcsnstrn_MATCH_AT_END(void) +{ + wchar_t const s[] = L"xxabc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnstrn(s, 5, L"abc", 3)); + TEST_PTR_NULL(stlsoft_C_wcsnstrn(s, 4, L"abc", 3)); +} + +static void TEST_stlsoft_C_wcsnstrn_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnstrn(L"abcdef", 6, L"zzz", 3)); + TEST_PTR_NULL(stlsoft_C_wcsnstrn(L"abcdef", 6, L"abx", 3)); +} + +static void TEST_stlsoft_C_wcsnstrn_PARTIAL_THEN_MATCH(void) +{ + wchar_t const s[] = L"abXabc"; + + TEST_PTR_EQ(s + 3, stlsoft_C_wcsnstrn(s, 6, L"abc", 3)); +} + +static void TEST_stlsoft_C_wcsnstrn_REPEATED_FIRST_BYTE(void) +{ + wchar_t const s[] = L"aaab"; + wchar_t const t[] = L"aaa"; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnstrn(s, 4, L"aab", 3)); + TEST_PTR_EQ(t, stlsoft_C_wcsnstrn(t, 3, L"aa", 2)); +} + +static void TEST_stlsoft_C_wcsnstrn_DOES_NOT_READ_PAST_n1(void) +{ + wchar_t const s[] = L"xxabc"; + + TEST_PTR_NULL(stlsoft_C_wcsnstrn(s, 4, L"abc", 3)); + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnstrn(s, 5, L"abc", 3)); +} + +static void TEST_stlsoft_C_wcsnstrn_DOES_NOT_READ_PAST_n2(void) +{ + wchar_t const hay[] = L"abX"; + wchar_t const needle[] = { L'a', L'b', L'Y' }; + + TEST_PTR_EQ(hay, stlsoft_C_wcsnstrn(hay, 3, needle, 2)); + TEST_PTR_NULL(stlsoft_C_wcsnstrn(hay, 3, needle, 3)); +} + +static void TEST_stlsoft_C_wcsnstrn_EMBEDDED_NUL(void) +{ + wchar_t const hay[] = { L'a', L'\0', L'b', L'x', L'a', L'\0', L'b' }; + wchar_t const needle[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(hay, stlsoft_C_wcsnstrn(hay, 7, needle, 3)); + TEST_PTR_EQ(hay + 4, stlsoft_C_wcsnstrn(hay + 1, 6, needle, 3)); +} + +static void TEST_stlsoft_C_wcsnstrn_SINGLE_BYTE(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnstrn(s, 3, L"b", 1)); + TEST_PTR_NULL(stlsoft_C_wcsnstrn(s, 3, L"z", 1)); +} + +static void TEST_stlsoft_C_wcsnstrn_FULL_SPAN(void) +{ + wchar_t const s[] = L"abcd"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnstrn(s, 4, L"abcd", 4)); + TEST_PTR_NULL(stlsoft_C_wcsnstrn(s, 4, L"abce", 4)); +} + + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/test/unit/stlsoft/string/c_string/strnstrn/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnstrn/CMakeLists.txt new file mode 100644 index 000000000..72fdc21fe --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnstrn/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnstrn entry.cpp) diff --git a/test/unit/stlsoft/string/c_string/strnstrn/entry.cpp b/test/unit/stlsoft/string/c_string/strnstrn/entry.cpp new file mode 100644 index 000000000..5fb7a47f6 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnstrn/entry.cpp @@ -0,0 +1,359 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnstrn/entry.cpp + * + * Purpose: Unit-tests for stlsoft::c_string::strnstrn() and wcsnstrn(). + * + * Created: 23rd October 2026 + * Updated: 23rd October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +namespace +{ + + static void TEST_c_string_strnstrn_n2_0(); + static void TEST_c_string_strnstrn_n1_0(); + static void TEST_c_string_strnstrn_n2_GT_n1(); + static void TEST_c_string_strnstrn_MATCH_AT_START(); + static void TEST_c_string_strnstrn_MATCH_IN_MIDDLE(); + static void TEST_c_string_strnstrn_MATCH_AT_END(); + static void TEST_c_string_strnstrn_MISS(); + static void TEST_c_string_strnstrn_PARTIAL_THEN_MATCH(); + static void TEST_c_string_strnstrn_REPEATED_FIRST_BYTE(); + static void TEST_c_string_strnstrn_DOES_NOT_READ_PAST_n1(); + static void TEST_c_string_strnstrn_DOES_NOT_READ_PAST_n2(); + static void TEST_c_string_strnstrn_EMBEDDED_NUL(); + static void TEST_c_string_strnstrn_SINGLE_BYTE(); + static void TEST_c_string_strnstrn_FULL_SPAN(); + static void TEST_c_string_wcsnstrn_n2_0(); + static void TEST_c_string_wcsnstrn_n1_0(); + static void TEST_c_string_wcsnstrn_n2_GT_n1(); + static void TEST_c_string_wcsnstrn_MATCH_AT_START(); + static void TEST_c_string_wcsnstrn_MATCH_IN_MIDDLE(); + static void TEST_c_string_wcsnstrn_MATCH_AT_END(); + static void TEST_c_string_wcsnstrn_MISS(); + static void TEST_c_string_wcsnstrn_PARTIAL_THEN_MATCH(); + static void TEST_c_string_wcsnstrn_REPEATED_FIRST_BYTE(); + static void TEST_c_string_wcsnstrn_DOES_NOT_READ_PAST_n1(); + static void TEST_c_string_wcsnstrn_DOES_NOT_READ_PAST_n2(); + static void TEST_c_string_wcsnstrn_EMBEDDED_NUL(); + static void TEST_c_string_wcsnstrn_SINGLE_BYTE(); + static void TEST_c_string_wcsnstrn_FULL_SPAN(); + + static wchar_t const* wcsnstrn_both_(wchar_t const* s1, size_t n1, wchar_t const* s2, size_t n2); + +} /* anonymous namespace */ + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnstrn", verbosity)) + { + XTESTS_RUN_CASE(TEST_c_string_strnstrn_n2_0); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_n1_0); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_n2_GT_n1); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_MISS); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_PARTIAL_THEN_MATCH); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_REPEATED_FIRST_BYTE); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_DOES_NOT_READ_PAST_n1); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_DOES_NOT_READ_PAST_n2); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_SINGLE_BYTE); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_FULL_SPAN); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_n2_0); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_n1_0); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_n2_GT_n1); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_MISS); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_PARTIAL_THEN_MATCH); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_REPEATED_FIRST_BYTE); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_DOES_NOT_READ_PAST_n1); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_DOES_NOT_READ_PAST_n2); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_SINGLE_BYTE); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_FULL_SPAN); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +namespace +{ + +static wchar_t const* wcsnstrn_both_(wchar_t const* s1, size_t n1, wchar_t const* s2, size_t n2) +{ + wchar_t const* const via_str = stlsoft::c_string::strnstrn(s1, n1, s2, n2); + wchar_t const* const via_wcs = stlsoft::c_string::wcsnstrn(s1, n1, s2, n2); + + TEST_PTR_EQ(via_wcs, via_str); + + return via_wcs; +} + +static void TEST_c_string_strnstrn_n2_0() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnstrn(s, 3, "", 0)); + TEST_PTR_EQ(s, stlsoft::c_string::strnstrn(s, 0, "", 0)); + TEST_PTR_EQ(s, stlsoft::c_string::strnstrn(s, 3, "xyz", 0)); +} + +static void TEST_c_string_strnstrn_n1_0() +{ + char const s[] = "abc"; + + TEST_PTR_NULL(stlsoft::c_string::strnstrn(s, 0, "a", 1)); +} + +static void TEST_c_string_strnstrn_n2_GT_n1() +{ + TEST_PTR_NULL(stlsoft::c_string::strnstrn("ab", 2, "abc", 3)); + TEST_PTR_NULL(stlsoft::c_string::strnstrn("abcd", 4, "abcde", 5)); +} + +static void TEST_c_string_strnstrn_MATCH_AT_START() +{ + char const s[] = "abcdef"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnstrn(s, 6, "abc", 3)); + TEST_PTR_EQ(s, stlsoft::c_string::strnstrn(s, 3, "abc", 3)); +} + +static void TEST_c_string_strnstrn_MATCH_IN_MIDDLE() +{ + char const s[] = "xxabcxx"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnstrn(s, 7, "abc", 3)); +} + +static void TEST_c_string_strnstrn_MATCH_AT_END() +{ + char const s[] = "xxabc"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnstrn(s, 5, "abc", 3)); + TEST_PTR_NULL(stlsoft::c_string::strnstrn(s, 4, "abc", 3)); +} + +static void TEST_c_string_strnstrn_MISS() +{ + TEST_PTR_NULL(stlsoft::c_string::strnstrn("abcdef", 6, "zzz", 3)); + TEST_PTR_NULL(stlsoft::c_string::strnstrn("abcdef", 6, "abx", 3)); +} + +static void TEST_c_string_strnstrn_PARTIAL_THEN_MATCH() +{ + char const s[] = "abXabc"; + + TEST_PTR_EQ(s + 3, stlsoft::c_string::strnstrn(s, 6, "abc", 3)); +} + +static void TEST_c_string_strnstrn_REPEATED_FIRST_BYTE() +{ + char const s[] = "aaab"; + char const t[] = "aaa"; + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnstrn(s, 4, "aab", 3)); + TEST_PTR_EQ(t, stlsoft::c_string::strnstrn(t, 3, "aa", 2)); +} + +static void TEST_c_string_strnstrn_DOES_NOT_READ_PAST_n1() +{ + char const s[] = "xxabc"; + + TEST_PTR_NULL(stlsoft::c_string::strnstrn(s, 4, "abc", 3)); + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnstrn(s, 5, "abc", 3)); +} + +static void TEST_c_string_strnstrn_DOES_NOT_READ_PAST_n2() +{ + char const hay[] = "abX"; + char const needle[] = { 'a', 'b', 'Y' }; + + TEST_PTR_EQ(hay, stlsoft::c_string::strnstrn(hay, 3, needle, 2)); + TEST_PTR_NULL(stlsoft::c_string::strnstrn(hay, 3, needle, 3)); +} + +static void TEST_c_string_strnstrn_EMBEDDED_NUL() +{ + char const hay[] = { 'a', '\0', 'b', 'x', 'a', '\0', 'b' }; + char const needle[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(hay, stlsoft::c_string::strnstrn(hay, 7, needle, 3)); + TEST_PTR_EQ(hay + 4, stlsoft::c_string::strnstrn(hay + 1, 6, needle, 3)); +} + +static void TEST_c_string_strnstrn_SINGLE_BYTE() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnstrn(s, 3, "b", 1)); + TEST_PTR_NULL(stlsoft::c_string::strnstrn(s, 3, "z", 1)); +} + +static void TEST_c_string_strnstrn_FULL_SPAN() +{ + char const s[] = "abcd"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnstrn(s, 4, "abcd", 4)); + TEST_PTR_NULL(stlsoft::c_string::strnstrn(s, 4, "abce", 4)); +} + +static void TEST_c_string_wcsnstrn_n2_0() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, wcsnstrn_both_(s, 3, L"", 0)); + TEST_PTR_EQ(s, wcsnstrn_both_(s, 0, L"", 0)); + TEST_PTR_EQ(s, wcsnstrn_both_(s, 3, L"xyz", 0)); +} + +static void TEST_c_string_wcsnstrn_n1_0() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_NULL(wcsnstrn_both_(s, 0, L"a", 1)); +} + +static void TEST_c_string_wcsnstrn_n2_GT_n1() +{ + TEST_PTR_NULL(wcsnstrn_both_(L"ab", 2, L"abc", 3)); + TEST_PTR_NULL(wcsnstrn_both_(L"abcd", 4, L"abcde", 5)); +} + +static void TEST_c_string_wcsnstrn_MATCH_AT_START() +{ + wchar_t const s[] = L"abcdef"; + + TEST_PTR_EQ(s, wcsnstrn_both_(s, 6, L"abc", 3)); + TEST_PTR_EQ(s, wcsnstrn_both_(s, 3, L"abc", 3)); +} + +static void TEST_c_string_wcsnstrn_MATCH_IN_MIDDLE() +{ + wchar_t const s[] = L"xxabcxx"; + + TEST_PTR_EQ(s + 2, wcsnstrn_both_(s, 7, L"abc", 3)); +} + +static void TEST_c_string_wcsnstrn_MATCH_AT_END() +{ + wchar_t const s[] = L"xxabc"; + + TEST_PTR_EQ(s + 2, wcsnstrn_both_(s, 5, L"abc", 3)); + TEST_PTR_NULL(wcsnstrn_both_(s, 4, L"abc", 3)); +} + +static void TEST_c_string_wcsnstrn_MISS() +{ + TEST_PTR_NULL(wcsnstrn_both_(L"abcdef", 6, L"zzz", 3)); + TEST_PTR_NULL(wcsnstrn_both_(L"abcdef", 6, L"abx", 3)); +} + +static void TEST_c_string_wcsnstrn_PARTIAL_THEN_MATCH() +{ + wchar_t const s[] = L"abXabc"; + + TEST_PTR_EQ(s + 3, wcsnstrn_both_(s, 6, L"abc", 3)); +} + +static void TEST_c_string_wcsnstrn_REPEATED_FIRST_BYTE() +{ + wchar_t const s[] = L"aaab"; + wchar_t const t[] = L"aaa"; + + TEST_PTR_EQ(s + 1, wcsnstrn_both_(s, 4, L"aab", 3)); + TEST_PTR_EQ(t, wcsnstrn_both_(t, 3, L"aa", 2)); +} + +static void TEST_c_string_wcsnstrn_DOES_NOT_READ_PAST_n1() +{ + wchar_t const s[] = L"xxabc"; + + TEST_PTR_NULL(wcsnstrn_both_(s, 4, L"abc", 3)); + TEST_PTR_EQ(s + 2, wcsnstrn_both_(s, 5, L"abc", 3)); +} + +static void TEST_c_string_wcsnstrn_DOES_NOT_READ_PAST_n2() +{ + wchar_t const hay[] = L"abX"; + wchar_t const needle[] = { L'a', L'b', L'Y' }; + + TEST_PTR_EQ(hay, wcsnstrn_both_(hay, 3, needle, 2)); + TEST_PTR_NULL(wcsnstrn_both_(hay, 3, needle, 3)); +} + +static void TEST_c_string_wcsnstrn_EMBEDDED_NUL() +{ + wchar_t const hay[] = { L'a', L'\0', L'b', L'x', L'a', L'\0', L'b' }; + wchar_t const needle[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(hay, wcsnstrn_both_(hay, 7, needle, 3)); + TEST_PTR_EQ(hay + 4, wcsnstrn_both_(hay + 1, 6, needle, 3)); +} + +static void TEST_c_string_wcsnstrn_SINGLE_BYTE() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, wcsnstrn_both_(s, 3, L"b", 1)); + TEST_PTR_NULL(wcsnstrn_both_(s, 3, L"z", 1)); +} + +static void TEST_c_string_wcsnstrn_FULL_SPAN() +{ + wchar_t const s[] = L"abcd"; + + TEST_PTR_EQ(s, wcsnstrn_both_(s, 4, L"abcd", 4)); + TEST_PTR_NULL(wcsnstrn_both_(s, 4, L"abce", 4)); +} + +} /* anonymous namespace */ + + +/* ///////////////////////////// end of file //////////////////////////// */ From a7af6b8a4b4dd71180717422533012c7998374e9 Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Fri, 23 Oct 2026 17:19:52 +1100 Subject: [PATCH 05/22] fix(stlsoft): compare each strnistrn character, not only the first The inner loops of stlsoft_C_strnistrn() and stlsoft_C_wcsnistrn() compared *s1 with *s2 on every index, so a first-character hit was treated as a full match. Index the pair, and fold the wide form with towupper. --- include/stlsoft/string/c_string/strnistrn.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/stlsoft/string/c_string/strnistrn.h b/include/stlsoft/string/c_string/strnistrn.h index 4eb48d7e7..eebd4b16b 100644 --- a/include/stlsoft/string/c_string/strnistrn.h +++ b/include/stlsoft/string/c_string/strnistrn.h @@ -4,11 +4,11 @@ * Purpose: Definition of stlsoft_C_strnistrn() and stlsoft_C_wcsnistrn() * * Created: 1st October 2020 - * Updated: 11th March 2024 + * Updated: 23rd October 2026 * * Home: http://stlsoft.org/ * - * Copyright (c) 2020-2024, Matthew Wilson and Synesis Information Systems + * Copyright (c) 2020-2026, Matthew Wilson and Synesis Information Systems * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -53,8 +53,8 @@ #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_MAJOR 1 # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_MINOR 0 -# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_REVISION 2 -# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_EDIT 3 +# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_REVISION 3 +# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_EDIT 4 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -116,7 +116,7 @@ stlsoft_C_strnistrn( for (i = 1; i != n2; ++i) { - if (STLSOFT_NS_GLOBAL(toupper)(*s1) != STLSOFT_NS_GLOBAL(toupper)(*s2)) + if (STLSOFT_NS_GLOBAL(toupper)(s1[i]) != STLSOFT_NS_GLOBAL(toupper)(s2[i])) { break; } @@ -165,7 +165,7 @@ stlsoft_C_wcsnistrn( for (i = 1; i != n2; ++i) { - if (STLSOFT_NS_GLOBAL(toupper)(*s1) != STLSOFT_NS_GLOBAL(toupper)(*s2)) + if (STLSOFT_NS_GLOBAL(towupper)(s1[i]) != STLSOFT_NS_GLOBAL(towupper)(s2[i])) { break; } From 922033247ab2b963078ea6fa3c2a2908d8e67543 Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Fri, 23 Oct 2026 18:10:04 +1100 Subject: [PATCH 06/22] fix(stlsoft): quiet MSVC C4310 and GCC 15 free-nonheap-object Store high-bit c_string test bytes in unsigned char so MSVC does not warn C4310. Keep auto_buffer's deallocate out of line on GCC 12+, and suppress -Wfree-nonheap-object, which mis-reports a delete of the internal buffer from simple_string's unit test. --- include/stlsoft/memory/auto_buffer.hpp | 27 +++++++++++++++++-- .../stlsoft/string/c_string/strnchr.C/entry.c | 3 ++- .../stlsoft/string/c_string/strnchr/entry.cpp | 3 ++- .../string/c_string/strnistrn.C/entry.c | 9 ++++--- .../string/c_string/strnistrn/entry.cpp | 9 ++++--- .../string/c_string/strnrchr.C/entry.c | 3 ++- .../string/c_string/strnrchr/entry.cpp | 3 ++- 7 files changed, 45 insertions(+), 12 deletions(-) diff --git a/include/stlsoft/memory/auto_buffer.hpp b/include/stlsoft/memory/auto_buffer.hpp index 92a66dcc9..9037637da 100644 --- a/include/stlsoft/memory/auto_buffer.hpp +++ b/include/stlsoft/memory/auto_buffer.hpp @@ -4,7 +4,7 @@ * Purpose: Contains the auto_buffer template class. * * Created: 19th January 2002 - * Updated: 15th October 2026 + * Updated: 23rd October 2026 * * Thanks: To Magnificent Imbecil for pointing out error in documentation, * and for suggesting swap() optimisation. To Thorsten Ottosen for @@ -58,7 +58,7 @@ # define STLSOFT_VER_STLSOFT_MEMORY_HPP_AUTO_BUFFER_MAJOR 5 # define STLSOFT_VER_STLSOFT_MEMORY_HPP_AUTO_BUFFER_MINOR 9 # define STLSOFT_VER_STLSOFT_MEMORY_HPP_AUTO_BUFFER_REVISION 1 -# define STLSOFT_VER_STLSOFT_MEMORY_HPP_AUTO_BUFFER_EDIT 234 +# define STLSOFT_VER_STLSOFT_MEMORY_HPP_AUTO_BUFFER_EDIT 235 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -574,6 +574,14 @@ class auto_buffer return allocate_(cItems, NULL); } +#if defined(STLSOFT_COMPILER_IS_GCC) && \ + __GNUC__ >= 12 + /* Keep operator delete out of the inlined destructor. GCC 12+ + * otherwise reports -Wfree-nonheap-object against the internal + * buffer. + */ + STLSOFT_NOINLINE +#endif /* GCC 12+ */ void deallocate_(pointer p, size_type cItems) { STLSOFT_ASSERT(NULL != p); @@ -1051,7 +1059,22 @@ class auto_buffer STLSOFT_ASSERT(0 != m_cExternal); STLSOFT_ASSERT(&m_internal[0] != m_buffer); + /* GCC 12+ cannot see that this pointer is the external + * array, and -Wfree-nonheap-object then reports a delete + * of the internal buffer. + */ +#if defined(STLSOFT_COMPILER_IS_GCC) && \ + __GNUC__ >= 12 + +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wfree-nonheap-object" +#endif /* GCC 12+ */ deallocate_(m_buffer, m_cItems); +#if defined(STLSOFT_COMPILER_IS_GCC) && \ + __GNUC__ >= 12 + +# pragma GCC diagnostic pop +#endif /* GCC 12+ */ } } private: diff --git a/test/unit/stlsoft/string/c_string/strnchr.C/entry.c b/test/unit/stlsoft/string/c_string/strnchr.C/entry.c index 5761035f3..73c2ffcaa 100644 --- a/test/unit/stlsoft/string/c_string/strnchr.C/entry.c +++ b/test/unit/stlsoft/string/c_string/strnchr.C/entry.c @@ -167,7 +167,8 @@ static void TEST_stlsoft_C_strnchr_CONTINUES_PAST_NUL(void) static void TEST_stlsoft_C_strnchr_HIGH_BIT(void) { - char const s[] = { (char)0xE9, 'b', 'c' }; + unsigned char const s_u[] = { 0xE9, 'b', 'c' }; + char const* const s = (char const*)s_u; TEST_PTR_EQ(s, stlsoft_C_strnchr(s, 3, s[0])); TEST_PTR_EQ(s + 1, stlsoft_C_strnchr(s, 3, 'b')); diff --git a/test/unit/stlsoft/string/c_string/strnchr/entry.cpp b/test/unit/stlsoft/string/c_string/strnchr/entry.cpp index 5e26fd389..45de98ed8 100644 --- a/test/unit/stlsoft/string/c_string/strnchr/entry.cpp +++ b/test/unit/stlsoft/string/c_string/strnchr/entry.cpp @@ -187,7 +187,8 @@ static void TEST_c_string_strnchr_CONTINUES_PAST_NUL() static void TEST_c_string_strnchr_HIGH_BIT() { - char const s[] = { (char)0xE9, 'b', 'c' }; + unsigned char const s_u[] = { 0xE9, 'b', 'c' }; + char const* const s = reinterpret_cast(s_u); TEST_PTR_EQ(s, stlsoft::c_string::strnchr(s, 3, s[0])); TEST_PTR_EQ(s + 1, stlsoft::c_string::strnchr(s, 3, 'b')); diff --git a/test/unit/stlsoft/string/c_string/strnistrn.C/entry.c b/test/unit/stlsoft/string/c_string/strnistrn.C/entry.c index 5a7a14233..90f22172e 100644 --- a/test/unit/stlsoft/string/c_string/strnistrn.C/entry.c +++ b/test/unit/stlsoft/string/c_string/strnistrn.C/entry.c @@ -225,9 +225,12 @@ static void TEST_stlsoft_C_strnistrn_SINGLE_BYTE(void) static void TEST_stlsoft_C_strnistrn_HIGH_BIT(void) { - char const hay[] = { (char)0xE9, 'A', 'b' }; - char const needle[] = { (char)0xE9, 'a', 'B' }; - char const other[] = { (char)0xE2, 'a' }; + unsigned char const hay_u[] = { 0xE9, 'A', 'b' }; + unsigned char const needle_u[] = { 0xE9, 'a', 'B' }; + unsigned char const other_u[] = { 0xE2, 'a' }; + char const* const hay = (char const*)hay_u; + char const* const needle = (char const*)needle_u; + char const* const other = (char const*)other_u; TEST_PTR_EQ(hay, stlsoft_C_strnistrn(hay, 3, needle, 3)); TEST_PTR_NULL(stlsoft_C_strnistrn(hay, 2, other, 2)); diff --git a/test/unit/stlsoft/string/c_string/strnistrn/entry.cpp b/test/unit/stlsoft/string/c_string/strnistrn/entry.cpp index 5f4720206..c2ac01dad 100644 --- a/test/unit/stlsoft/string/c_string/strnistrn/entry.cpp +++ b/test/unit/stlsoft/string/c_string/strnistrn/entry.cpp @@ -245,9 +245,12 @@ static void TEST_c_string_strnistrn_SINGLE_BYTE() static void TEST_c_string_strnistrn_HIGH_BIT() { - char const hay[] = { (char)0xE9, 'A', 'b' }; - char const needle[] = { (char)0xE9, 'a', 'B' }; - char const other[] = { (char)0xE2, 'a' }; + unsigned char const hay_u[] = { 0xE9, 'A', 'b' }; + unsigned char const needle_u[] = { 0xE9, 'a', 'B' }; + unsigned char const other_u[] = { 0xE2, 'a' }; + char const* const hay = reinterpret_cast(hay_u); + char const* const needle = reinterpret_cast(needle_u); + char const* const other = reinterpret_cast(other_u); TEST_PTR_EQ(hay, stlsoft::c_string::strnistrn(hay, 3, needle, 3)); TEST_PTR_NULL(stlsoft::c_string::strnistrn(hay, 2, other, 2)); diff --git a/test/unit/stlsoft/string/c_string/strnrchr.C/entry.c b/test/unit/stlsoft/string/c_string/strnrchr.C/entry.c index ae851c44a..32bd47a71 100644 --- a/test/unit/stlsoft/string/c_string/strnrchr.C/entry.c +++ b/test/unit/stlsoft/string/c_string/strnrchr.C/entry.c @@ -167,7 +167,8 @@ static void TEST_stlsoft_C_strnrchr_CONTINUES_PAST_NUL(void) static void TEST_stlsoft_C_strnrchr_HIGH_BIT(void) { - char const s[] = { 'a', (char)0xE9, 'b' }; + unsigned char const s_u[] = { 'a', 0xE9, 'b' }; + char const* const s = (char const*)s_u; TEST_PTR_EQ(s + 1, stlsoft_C_strnrchr(s, 3, s[1])); TEST_PTR_EQ(s, stlsoft_C_strnrchr(s, 1, 'a')); diff --git a/test/unit/stlsoft/string/c_string/strnrchr/entry.cpp b/test/unit/stlsoft/string/c_string/strnrchr/entry.cpp index 401c62bd0..d3ba225c8 100644 --- a/test/unit/stlsoft/string/c_string/strnrchr/entry.cpp +++ b/test/unit/stlsoft/string/c_string/strnrchr/entry.cpp @@ -187,7 +187,8 @@ static void TEST_c_string_strnrchr_CONTINUES_PAST_NUL() static void TEST_c_string_strnrchr_HIGH_BIT() { - char const s[] = { 'a', (char)0xE9, 'b' }; + unsigned char const s_u[] = { 'a', 0xE9, 'b' }; + char const* const s = reinterpret_cast(s_u); TEST_PTR_EQ(s + 1, stlsoft::c_string::strnrchr(s, 3, s[1])); TEST_PTR_EQ(s, stlsoft::c_string::strnrchr(s, 1, 'a')); From 1c39ac08be6a2a1a54abcab407da1279917e8034 Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Fri, 23 Oct 2026 18:22:51 +1100 Subject: [PATCH 07/22] version --- test/unit/versions/entry.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/versions/entry.cpp b/test/unit/versions/entry.cpp index e9d428540..a1638c42b 100644 --- a/test/unit/versions/entry.cpp +++ b/test/unit/versions/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for versions * * Created: 23rd August 2025 - * Updated: 21st October 2026 + * Updated: 23rd October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -133,7 +133,7 @@ namespace { static void TEST__STLSOFT_VER() { - TEST_INT_EQ(_STLSOFT_VER_1_11_1, _STLSOFT_VER); + TEST_INT_EQ(_STLSOFT_VER_1_11_2_A1, _STLSOFT_VER); } #ifdef STLSOFT_HAS_ACE From 7fffe4d3d5aae4c49888049bdeb9611a68361375 Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Fri, 23 Oct 2026 19:04:49 +1100 Subject: [PATCH 08/22] test(stlsoft): compare a full sun_path with a counted string A 108-character path fills Linux sun_path and is not NUL-terminated. TEST_MS_EQ then read past the array. Use TEST_MS_EQ_N when the path length is the capacity, as the 104-character case already does. --- test/component/inetstl/util/uds_helpers/entry.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/component/inetstl/util/uds_helpers/entry.cpp b/test/component/inetstl/util/uds_helpers/entry.cpp index 3dbea7e7f..dfe4bd5d8 100644 --- a/test/component/inetstl/util/uds_helpers/entry.cpp +++ b/test/component/inetstl/util/uds_helpers/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `inetstl::environment_variable`. * * Created: 21st February 2025 - * Updated: 9th August 2026 + * Updated: 23rd October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -414,7 +414,7 @@ static void TEST_VALID_paths() #endif TEST_INT_EQ(AF_UNIX, sa_un.sun_family); - if (104 == cb_sun_path) + if (108 == cb_sun_path) { TEST_MS_EQ_N("/tmp/sock/01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567", sa_un.sun_path, 108); } From 284a2a88b56423d5de30d318c56f847df47e4aba Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Fri, 23 Oct 2026 19:28:24 +1100 Subject: [PATCH 09/22] perf(stlsoft): fold ASCII case in strnistrn without toupper Replace per-byte toupper and towupper on the strnistrn hot path with an unsigned-char ASCII fold. The needle's first unit is folded once. wchar_t units outside 0-127 still use towupper. Non-ASCII bytes are no longer folded by the current locale. --- include/stlsoft/string/c_string/strnistrn.h | 113 +++++++++++++++----- 1 file changed, 85 insertions(+), 28 deletions(-) diff --git a/include/stlsoft/string/c_string/strnistrn.h b/include/stlsoft/string/c_string/strnistrn.h index eebd4b16b..681a1823c 100644 --- a/include/stlsoft/string/c_string/strnistrn.h +++ b/include/stlsoft/string/c_string/strnistrn.h @@ -53,8 +53,8 @@ #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_MAJOR 1 # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_MINOR 0 -# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_REVISION 3 -# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_EDIT 4 +# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_REVISION 4 +# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_EDIT 5 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -69,16 +69,54 @@ # pragma message(__FILE__) #endif /* STLSOFT_TRACE_INCLUDE */ -#ifndef STLSOFT_INCL_H_CTYPE -# define STLSOFT_INCL_H_CTYPE -# include -#endif /* !STLSOFT_INCL_H_CTYPE */ #ifndef STLSOFT_INCL_H_WCTYPE # define STLSOFT_INCL_H_WCTYPE # include #endif /* !STLSOFT_INCL_H_WCTYPE */ +/* ///////////////////////////////////////////////////////////////////////// + * helpers + */ + +/* ASCII letters fold by 32. Every other byte is returned unchanged. */ +STLSOFT_INLINE +int +stlsoft_C_strnistrn_fold_char_( + unsigned char ch +) +{ + if ('a' <= ch && + ch <= 'z') + { + ch = (unsigned char)(ch - ('a' - 'A')); + } + + return (int)ch; +} + +/* ASCII letters fold by 32. Units outside 0-127 use towupper. */ +STLSOFT_INLINE +int +stlsoft_C_wcsnistrn_fold_( + wchar_t ch +) +{ + if (L'a' <= ch && + ch <= L'z') + { + return (int)ch - (L'a' - L'A'); + } + + if ((unsigned long)ch <= 127ul) + { + return (int)ch; + } + + return (int)STLSOFT_NS_GLOBAL(towupper)(ch); +} + + /* ///////////////////////////////////////////////////////////////////////// * API functions */ @@ -107,24 +145,35 @@ stlsoft_C_strnistrn( return s1; } - for (; n1 >= n2; --n1, ++s1) { - if (*s1 == *s2 || - STLSOFT_NS_GLOBAL(toupper)(*s1) == STLSOFT_NS_GLOBAL(toupper)(*s2)) + unsigned char const ch0 = (unsigned char)s2[0]; + int const fc0 = stlsoft_C_strnistrn_fold_char_(ch0); + + for (; n1 >= n2; --n1, ++s1) { - size_t i; + unsigned char const h0 = (unsigned char)s1[0]; - for (i = 1; i != n2; ++i) + if (h0 == ch0 || + stlsoft_C_strnistrn_fold_char_(h0) == fc0) { - if (STLSOFT_NS_GLOBAL(toupper)(s1[i]) != STLSOFT_NS_GLOBAL(toupper)(s2[i])) + size_t i; + + for (i = 1; i != n2; ++i) { - break; + unsigned char const h = (unsigned char)s1[i]; + unsigned char const n = (unsigned char)s2[i]; + + if (stlsoft_C_strnistrn_fold_char_(h) != + stlsoft_C_strnistrn_fold_char_(n)) + { + break; + } } - } - if (i == n2) - { - return s1; + if (i == n2) + { + return s1; + } } } } @@ -156,24 +205,32 @@ stlsoft_C_wcsnistrn( return s1; } - for (; n1 >= n2; --n1, ++s1) { - if (*s1 == *s2 || - STLSOFT_NS_GLOBAL(towupper)(*s1) == STLSOFT_NS_GLOBAL(towupper)(*s2)) + wchar_t const ch0 = s2[0]; + int const fc0 = stlsoft_C_wcsnistrn_fold_(ch0); + + for (; n1 >= n2; --n1, ++s1) { - size_t i; + wchar_t const h0 = s1[0]; - for (i = 1; i != n2; ++i) + if (h0 == ch0 || + stlsoft_C_wcsnistrn_fold_(h0) == fc0) { - if (STLSOFT_NS_GLOBAL(towupper)(s1[i]) != STLSOFT_NS_GLOBAL(towupper)(s2[i])) + size_t i; + + for (i = 1; i != n2; ++i) { - break; + if (stlsoft_C_wcsnistrn_fold_(s1[i]) != + stlsoft_C_wcsnistrn_fold_(s2[i])) + { + break; + } } - } - if (i == n2) - { - return s1; + if (i == n2) + { + return s1; + } } } } From fc1d777ecd4285e152af1f08ec356512a4569330 Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Fri, 23 Oct 2026 19:33:46 +1100 Subject: [PATCH 10/22] perf(stlsoft): fold ASCII case in strnicmp without toupper Replace per-byte toupper and towupper on the strnicmp mismatch path with an unsigned-char ASCII fold. Equal bytes still skip the fold. wchar_t units outside 0-127 still use towupper. --- include/stlsoft/string/c_string/strnicmp.h | 92 +++++++++++++++------- 1 file changed, 64 insertions(+), 28 deletions(-) diff --git a/include/stlsoft/string/c_string/strnicmp.h b/include/stlsoft/string/c_string/strnicmp.h index d36b24a58..1f5d954cb 100644 --- a/include/stlsoft/string/c_string/strnicmp.h +++ b/include/stlsoft/string/c_string/strnicmp.h @@ -4,11 +4,11 @@ * Purpose: Definition of stlsoft_C_strnicmp() and stlsoft_C_wcsnicmp() * * Created: 25th November 2020 - * Updated: 11th March 2024 + * Updated: 23rd October 2026 * * Home: http://stlsoft.org/ * - * Copyright (c) 2020-2024, Matthew Wilson and Synesis Information Systems + * Copyright (c) 2020-2026, Matthew Wilson and Synesis Information Systems * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -53,8 +53,8 @@ #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNICMP_MAJOR 1 # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNICMP_MINOR 0 -# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNICMP_REVISION 2 -# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNICMP_EDIT 4 +# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNICMP_REVISION 3 +# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNICMP_EDIT 5 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -69,16 +69,54 @@ # pragma message(__FILE__) #endif /* STLSOFT_TRACE_INCLUDE */ -#ifndef STLSOFT_INCL_H_CTYPE -# define STLSOFT_INCL_H_CTYPE -# include -#endif /* !STLSOFT_INCL_H_CTYPE */ #ifndef STLSOFT_INCL_H_WCTYPE # define STLSOFT_INCL_H_WCTYPE # include #endif /* !STLSOFT_INCL_H_WCTYPE */ +/* ///////////////////////////////////////////////////////////////////////// + * helpers + */ + +/* ASCII letters fold by 32. Every other byte is returned unchanged. */ +STLSOFT_INLINE +int +stlsoft_C_strnicmp_fold_char_( + unsigned char ch +) +{ + if ('a' <= ch && + ch <= 'z') + { + ch = (unsigned char)(ch - ('a' - 'A')); + } + + return (int)ch; +} + +/* ASCII letters fold by 32. Units outside 0-127 use towupper. */ +STLSOFT_INLINE +int +stlsoft_C_wcsnicmp_fold_( + wchar_t ch +) +{ + if (L'a' <= ch && + ch <= L'z') + { + return (int)ch - (L'a' - L'A'); + } + + if ((unsigned long)ch <= 127ul) + { + return (int)ch; + } + + return (int)STLSOFT_NS_GLOBAL(towupper)(ch); +} + + /* ///////////////////////////////////////////////////////////////////////// * API functions */ @@ -103,23 +141,22 @@ stlsoft_C_strnicmp( { for (; 0 != n; --n, ++s1, ++s2) { - int d = stlsoft_static_cast(int, *s1) - stlsoft_static_cast(int, *s2); + unsigned char const c1 = (unsigned char)*s1; + unsigned char const c2 = (unsigned char)*s2; - if (0 != d) + if (c1 != c2) { - d = toupper(*s1) - toupper(*s2); - } + int const d = stlsoft_C_strnicmp_fold_char_(c1) - + stlsoft_C_strnicmp_fold_char_(c2); - if (0 == d) - { - if ('\0' == *s1) + if (0 != d) { - return 0; + return d; } } - else + else if ('\0' == *s1) { - return d; + return 0; } } @@ -146,23 +183,22 @@ stlsoft_C_wcsnicmp( { for (; 0 != n; --n, ++s1, ++s2) { - int d = stlsoft_static_cast(int, *s1) - stlsoft_static_cast(int, *s2); + wchar_t const c1 = *s1; + wchar_t const c2 = *s2; - if (0 != d) + if (c1 != c2) { - d = towupper(*s1) - towupper(*s2); - } + int const d = stlsoft_C_wcsnicmp_fold_(c1) - + stlsoft_C_wcsnicmp_fold_(c2); - if (0 == d) - { - if ('\0' == *s1) + if (0 != d) { - return 0; + return d; } } - else + else if (L'\0' == c1) { - return d; + return 0; } } From 3d864341bae6e60e5f146ca047ffa4e377b09a9e Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Fri, 23 Oct 2026 19:35:27 +1100 Subject: [PATCH 11/22] tidy --- include/stlsoft/string/c_string/strnicmp.h | 10 +++++----- include/stlsoft/string/c_string/strnistrn.h | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/stlsoft/string/c_string/strnicmp.h b/include/stlsoft/string/c_string/strnicmp.h index 1f5d954cb..6021c95ce 100644 --- a/include/stlsoft/string/c_string/strnicmp.h +++ b/include/stlsoft/string/c_string/strnicmp.h @@ -1,12 +1,12 @@ /* ///////////////////////////////////////////////////////////////////////// - * File: stlsoft/string/c_string/strnicmp.h + * File: stlsoft/string/c_string/strnicmp.h * - * Purpose: Definition of stlsoft_C_strnicmp() and stlsoft_C_wcsnicmp() + * Purpose: Definition of stlsoft_C_strnicmp() and stlsoft_C_wcsnicmp() * - * Created: 25th November 2020 - * Updated: 23rd October 2026 + * Created: 25th November 2020 + * Updated: 23rd October 2026 * - * Home: http://stlsoft.org/ + * Home: http://stlsoft.org/ * * Copyright (c) 2020-2026, Matthew Wilson and Synesis Information Systems * All rights reserved. diff --git a/include/stlsoft/string/c_string/strnistrn.h b/include/stlsoft/string/c_string/strnistrn.h index 681a1823c..6abfc18b1 100644 --- a/include/stlsoft/string/c_string/strnistrn.h +++ b/include/stlsoft/string/c_string/strnistrn.h @@ -1,12 +1,12 @@ /* ///////////////////////////////////////////////////////////////////////// - * File: stlsoft/string/c_string/strnistrn.h + * File: stlsoft/string/c_string/strnistrn.h * - * Purpose: Definition of stlsoft_C_strnistrn() and stlsoft_C_wcsnistrn() + * Purpose: Definition of stlsoft_C_strnistrn() and stlsoft_C_wcsnistrn() * - * Created: 1st October 2020 - * Updated: 23rd October 2026 + * Created: 1st October 2020 + * Updated: 23rd October 2026 * - * Home: http://stlsoft.org/ + * Home: http://stlsoft.org/ * * Copyright (c) 2020-2026, Matthew Wilson and Synesis Information Systems * All rights reserved. From 8de0dd7b03d11a25785eb1eba96793f2a65ec839 Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Fri, 23 Oct 2026 19:37:48 +1100 Subject: [PATCH 12/22] perf(stlsoft): search ASCII strnchr with memchr Call memchr and wmemchr when the search value is in 0-127. Values outside that range stay on the scalar loop, so a high byte still compares as a promoted char. --- include/stlsoft/string/c_string/strnchr.h | 31 +++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/include/stlsoft/string/c_string/strnchr.h b/include/stlsoft/string/c_string/strnchr.h index fd2a876ec..1c729b04b 100644 --- a/include/stlsoft/string/c_string/strnchr.h +++ b/include/stlsoft/string/c_string/strnchr.h @@ -4,7 +4,7 @@ * Purpose: Definition of stlsoft_C_strnchr() and stlsoft_C_wcsnchr() * * Created: 1st October 2020 - * Updated: 20th October 2020 + * Updated: 23rd October 2026 * * Home: http://stlsoft.org/ * @@ -54,7 +54,7 @@ # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNCHR_MAJOR 1 # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNCHR_MINOR 0 # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNCHR_REVISION 2 -# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNCHR_EDIT 4 +# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNCHR_EDIT 5 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -69,6 +69,15 @@ # pragma message(__FILE__) #endif /* STLSOFT_TRACE_INCLUDE */ +#ifndef STLSOFT_INCL_H_STRING +# define STLSOFT_INCL_H_STRING +# include +#endif /* !STLSOFT_INCL_H_STRING */ +#ifndef STLSOFT_INCL_H_WCHAR +# define STLSOFT_INCL_H_WCHAR +# include +#endif /* !STLSOFT_INCL_H_WCHAR */ + /* ///////////////////////////////////////////////////////////////////////// * API functions @@ -82,6 +91,13 @@ stlsoft_C_strnchr( , int ch ) { + /* memchr matches char promotion only when ch is in 0-127. */ + if (0 <= ch && + ch <= 127) + { + return STLSOFT_C_CAST(char const*, STLSOFT_NS_GLOBAL(memchr)(s, ch, n)); + } + for (; 0 != n; --n, ++s) { if (ch == *s) @@ -101,6 +117,17 @@ stlsoft_C_wcsnchr( , int ch ) { + /* wmemchr matches the int comparison only when ch is in 0-127. */ + if (0 <= ch && + ch <= 127) + { + return STLSOFT_NS_GLOBAL(wmemchr)( + s + , STLSOFT_C_CAST(wchar_t, ch) + , n + ); + } + for (; 0 != n; --n, ++s) { if (ch == STLSOFT_C_CAST(int, *s)) From f48acf66b6194c97e01514588ae900b427911343 Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Fri, 23 Oct 2026 19:44:33 +1100 Subject: [PATCH 13/22] perf(stlsoft): search strnstrn with memchr and memcmp Find the first needle byte with memchr over the positions that can still hold the needle, then memcmp the remaining bytes. A partial hit resumes one past that byte. wchar_t uses wmemchr and wmemcmp. An empty needle still returns the haystack. --- include/stlsoft/string/c_string/strnstrn.h | 83 +++++++++++++++------- 1 file changed, 56 insertions(+), 27 deletions(-) diff --git a/include/stlsoft/string/c_string/strnstrn.h b/include/stlsoft/string/c_string/strnstrn.h index 19490d058..27f9c9be1 100644 --- a/include/stlsoft/string/c_string/strnstrn.h +++ b/include/stlsoft/string/c_string/strnstrn.h @@ -1,14 +1,14 @@ /* ///////////////////////////////////////////////////////////////////////// - * File: stlsoft/string/c_string/strnstrn.h + * File: stlsoft/string/c_string/strnstrn.h * - * Purpose: Definition of stlsoft_C_strnstrn() and stlsoft_C_wcsnstrn() + * Purpose: Definition of stlsoft_C_strnstrn() and stlsoft_C_wcsnstrn() * - * Created: 1st October 2020 - * Updated: 11th March 2024 + * Created: 1st October 2020 + * Updated: 23rd October 2026 * - * Home: http://stlsoft.org/ + * Home: http://stlsoft.org/ * - * Copyright (c) 2020, Matthew Wilson and Synesis Information Systems + * Copyright (c) 2020-2026, Matthew Wilson and Synesis Information Systems * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -54,7 +54,7 @@ # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNSTRN_MAJOR 1 # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNSTRN_MINOR 0 # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNSTRN_REVISION 1 -# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNSTRN_EDIT 2 +# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNSTRN_EDIT 3 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -69,6 +69,15 @@ # pragma message(__FILE__) #endif /* STLSOFT_TRACE_INCLUDE */ +#ifndef STLSOFT_INCL_H_STRING +# define STLSOFT_INCL_H_STRING +# include +#endif /* !STLSOFT_INCL_H_STRING */ +#ifndef STLSOFT_INCL_H_WCHAR +# define STLSOFT_INCL_H_WCHAR +# include +#endif /* !STLSOFT_INCL_H_WCHAR */ + /* ///////////////////////////////////////////////////////////////////////// * API functions @@ -98,23 +107,33 @@ stlsoft_C_strnstrn( return s1; } - for (; n1 >= n2; --n1, ++s1) { - if (*s1 == *s2) + unsigned char const n0 = (unsigned char)s2[0]; + + /* First byte via memchr. The remaining n2-1 bytes via memcmp. */ + while (n1 >= n2) { - size_t i; + size_t const span = n1 - n2 + 1; + char const* hit; - for (i = 1; i != n2; ++i) + hit = STLSOFT_C_CAST(char const*, STLSOFT_NS_GLOBAL(memchr)(s1, n0, span)); + + if (ss_nullptr_k == hit) { - if (s1[i] != s2[i]) - { - break; - } + break; } - if (i == n2) + if (1 == n2 || + 0 == STLSOFT_NS_GLOBAL(memcmp)(hit + 1, s2 + 1, n2 - 1)) { - return s1; + return hit; + } + + { + size_t const skipped = STLSOFT_C_CAST(size_t, hit - s1) + 1; + + s1 += skipped; + n1 -= skipped; } } } @@ -146,23 +165,33 @@ stlsoft_C_wcsnstrn( return s1; } - for (; n1 >= n2; --n1, ++s1) { - if (*s1 == *s2) + wchar_t const n0 = s2[0]; + + /* First unit via wmemchr. The remaining n2-1 units via wmemcmp. */ + while (n1 >= n2) { - size_t i; + size_t const span = n1 - n2 + 1; + wchar_t const* hit; + + hit = STLSOFT_NS_GLOBAL(wmemchr)(s1, n0, span); + + if (ss_nullptr_k == hit) + { + break; + } - for (i = 1; i != n2; ++i) + if (1 == n2 || + 0 == STLSOFT_NS_GLOBAL(wmemcmp)(hit + 1, s2 + 1, n2 - 1)) { - if (s1[i] != s2[i]) - { - break; - } + return hit; } - if (i == n2) { - return s1; + size_t const skipped = STLSOFT_C_CAST(size_t, hit - s1) + 1; + + s1 += skipped; + n1 -= skipped; } } } From db98252af6c8d1f4c46cb4515c33e13d2a4470aa Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Fri, 23 Oct 2026 19:47:03 +1100 Subject: [PATCH 14/22] tidy --- include/stlsoft/string/c_string/strnstrn.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/stlsoft/string/c_string/strnstrn.h b/include/stlsoft/string/c_string/strnstrn.h index 27f9c9be1..e981e8ac1 100644 --- a/include/stlsoft/string/c_string/strnstrn.h +++ b/include/stlsoft/string/c_string/strnstrn.h @@ -108,7 +108,7 @@ stlsoft_C_strnstrn( } { - unsigned char const n0 = (unsigned char)s2[0]; + unsigned char const ch0 = (unsigned char)s2[0]; /* First byte via memchr. The remaining n2-1 bytes via memcmp. */ while (n1 >= n2) @@ -116,7 +116,7 @@ stlsoft_C_strnstrn( size_t const span = n1 - n2 + 1; char const* hit; - hit = STLSOFT_C_CAST(char const*, STLSOFT_NS_GLOBAL(memchr)(s1, n0, span)); + hit = STLSOFT_C_CAST(char const*, STLSOFT_NS_GLOBAL(memchr)(s1, ch0, span)); if (ss_nullptr_k == hit) { @@ -166,7 +166,7 @@ stlsoft_C_wcsnstrn( } { - wchar_t const n0 = s2[0]; + wchar_t const ch0 = s2[0]; /* First unit via wmemchr. The remaining n2-1 units via wmemcmp. */ while (n1 >= n2) @@ -174,7 +174,7 @@ stlsoft_C_wcsnstrn( size_t const span = n1 - n2 + 1; wchar_t const* hit; - hit = STLSOFT_NS_GLOBAL(wmemchr)(s1, n0, span); + hit = STLSOFT_NS_GLOBAL(wmemchr)(s1, ch0, span); if (ss_nullptr_k == hit) { From 291db12f1abe90991f617ecb1aeae9f6498b88af Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Fri, 23 Oct 2026 20:20:14 +1100 Subject: [PATCH 15/22] canonicalisation --- include/stlsoft/string/c_string/strnistrn.h | 12 ++++++------ include/stlsoft/string/c_string/strnstrn.h | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/stlsoft/string/c_string/strnistrn.h b/include/stlsoft/string/c_string/strnistrn.h index 6abfc18b1..cc9e92690 100644 --- a/include/stlsoft/string/c_string/strnistrn.h +++ b/include/stlsoft/string/c_string/strnistrn.h @@ -144,7 +144,7 @@ stlsoft_C_strnistrn( { return s1; } - + else { unsigned char const ch0 = (unsigned char)s2[0]; int const fc0 = stlsoft_C_strnistrn_fold_char_(ch0); @@ -176,9 +176,9 @@ stlsoft_C_strnistrn( } } } - } - return ss_nullptr_k; + return ss_nullptr_k; + } } /** Finds a specific-length (slice of a) string within a specific-length @@ -204,7 +204,7 @@ stlsoft_C_wcsnistrn( { return s1; } - + else { wchar_t const ch0 = s2[0]; int const fc0 = stlsoft_C_wcsnistrn_fold_(ch0); @@ -233,9 +233,9 @@ stlsoft_C_wcsnistrn( } } } - } - return ss_nullptr_k; + return ss_nullptr_k; + } } diff --git a/include/stlsoft/string/c_string/strnstrn.h b/include/stlsoft/string/c_string/strnstrn.h index e981e8ac1..d632c02bc 100644 --- a/include/stlsoft/string/c_string/strnstrn.h +++ b/include/stlsoft/string/c_string/strnstrn.h @@ -106,7 +106,7 @@ stlsoft_C_strnstrn( { return s1; } - + else { unsigned char const ch0 = (unsigned char)s2[0]; @@ -136,9 +136,9 @@ stlsoft_C_strnstrn( n1 -= skipped; } } - } - return ss_nullptr_k; + return ss_nullptr_k; + } } /** Finds a specific-length (slice of a) string within a specific-length @@ -164,7 +164,7 @@ stlsoft_C_wcsnstrn( { return s1; } - + else { wchar_t const ch0 = s2[0]; @@ -194,9 +194,9 @@ stlsoft_C_wcsnstrn( n1 -= skipped; } } - } - return ss_nullptr_k; + return ss_nullptr_k; + } } From ed5f72b4a30ca88fdd4e22f381e76b2bf5bffafa Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Fri, 23 Oct 2026 20:26:11 +1100 Subject: [PATCH 16/22] tidy --- include/platformstl/filesystem/path.hpp | 122 +++++++++++++++--------- 1 file changed, 78 insertions(+), 44 deletions(-) diff --git a/include/platformstl/filesystem/path.hpp b/include/platformstl/filesystem/path.hpp index 87d1e4ae9..b690185de 100644 --- a/include/platformstl/filesystem/path.hpp +++ b/include/platformstl/filesystem/path.hpp @@ -1,14 +1,14 @@ /* ///////////////////////////////////////////////////////////////////////// - * File: platformstl/filesystem/path.hpp + * File: platformstl/filesystem/path.hpp * - * Purpose: Platform header for the path components. + * Purpose: Platform header for the path components. * - * Created: 20th March 2005 - * Updated: 21st March 2025 + * Created: 20th March 2005 + * Updated: 23rd October 2026 * - * Home: http://stlsoft.org/ + * Home: http://stlsoft.org/ * - * Copyright (c) 2019-2025, Matthew Wilson and Synesis Information Systems + * Copyright (c) 2019-2026, Matthew Wilson and Synesis Information Systems * Copyright (c) 2005-2019, Matthew Wilson and Synesis Software * All rights reserved. * @@ -56,7 +56,7 @@ # define PLATFORMSTL_VER_PLATFORMSTL_FILESYSTEM_HPP_PATH_MAJOR 2 # define PLATFORMSTL_VER_PLATFORMSTL_FILESYSTEM_HPP_PATH_MINOR 2 # define PLATFORMSTL_VER_PLATFORMSTL_FILESYSTEM_HPP_PATH_REVISION 6 -# define PLATFORMSTL_VER_PLATFORMSTL_FILESYSTEM_HPP_PATH_EDIT 45 +# define PLATFORMSTL_VER_PLATFORMSTL_FILESYSTEM_HPP_PATH_EDIT 46 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -120,19 +120,29 @@ namespace platformstl_project * platforms it resolves to the winstl::basic_path class. It * is not defined for other platforms. */ - template< ss_typename_param_k C - , ss_typename_param_k T = filesystem_traits - , ss_typename_param_k A = ss_typename_type_def_k stlsoft::allocator_selector::allocator_type - > + template< + ss_typename_param_k C + , ss_typename_param_k T = filesystem_traits + , ss_typename_param_k A = ss_typename_type_def_k stlsoft::allocator_selector::allocator_type + > class basic_path {}; /// Specialisation of the basic_path template for the ANSI character type \c char - typedef basic_path > path_a; + typedef basic_path< + char + , filesystem_traits + > path_a; /// Specialisation of the basic_path template for the Unicode character type \c wchar_t - typedef basic_path > path_w; + typedef basic_path< + wchar_t + , filesystem_traits + > path_w; /// Specialisation of the basic_path template for the ANSI character type \c char on UNIX, and for the \c TCHAR type on Windows - typedef basic_path > path; + typedef basic_path< + tchar + , filesystem_traits + > path; #elif defined(PLATFORMSTL_OS_IS_UNIX) @@ -150,26 +160,29 @@ namespace platformstl_project # if defined(STLSOFT_COMPILER_IS_MSVC) && \ _MSC_VER < 1310 - template< ss_typename_param_k C + template< + ss_typename_param_k C # ifdef STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT - , ss_typename_param_k T = UNIXSTL_NS_QUAL(filesystem_traits) - , ss_typename_param_k A = ss_typename_type_def_k stlsoft::allocator_selector::allocator_type + , ss_typename_param_k T = UNIXSTL_NS_QUAL(filesystem_traits) + , ss_typename_param_k A = ss_typename_type_def_k stlsoft::allocator_selector::allocator_type # else /* ? STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */ - , ss_typename_param_k T /* = filesystem_traits */ - , ss_typename_param_k A /* = processheap_allocator */ + , ss_typename_param_k T /* = filesystem_traits */ + , ss_typename_param_k A /* = processheap_allocator */ # endif /* STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */ - > + > class basic_path : public UNIXSTL_NS_QUAL(basic_path__) { private: - typedef UNIXSTL_NS_QUAL(basic_path__) parent_class_type; - typedef basic_path class_type; + typedef UNIXSTL_NS_QUAL(basic_path__) parent_class_type; + typedef basic_path class_type; public: - typedef ss_typename_type_k parent_class_type::char_type char_type; - typedef ss_typename_type_k parent_class_type::traits_type traits_type; - typedef ss_typename_type_k parent_class_type::allocator_type allocator_type; - typedef ss_typename_type_k parent_class_type::size_type size_type; + typedef ss_typename_type_k parent_class_type::char_type char_type; + typedef ss_typename_type_k parent_class_type::traits_type + traits_type; + typedef ss_typename_type_k parent_class_type::allocator_type + allocator_type; + typedef ss_typename_type_k parent_class_type::size_type size_type; public: basic_path() @@ -224,9 +237,18 @@ namespace platformstl_project # endif /* STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT */ }; - typedef basic_path > path_a; - typedef basic_path > path_w; - typedef basic_path > path; + typedef basic_path< + ss_char_a_t + , UNIXSTL_NS_QUAL(filesystem_traits) + > path_a; + typedef basic_path< + ss_char_w_t + , UNIXSTL_NS_QUAL(filesystem_traits) + > path_w; + typedef basic_path< + ss_char_a_t + , UNIXSTL_NS_QUAL(filesystem_traits) + > path; # else /* ? compiler */ @@ -257,26 +279,29 @@ namespace platformstl_project # if defined(STLSOFT_COMPILER_IS_MSVC) && \ _MSC_VER < 1310 - template< ss_typename_param_k C + template< + ss_typename_param_k C # ifdef STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT - , ss_typename_param_k T = WINSTL_NS_QUAL(filesystem_traits) - , ss_typename_param_k A = WINSTL_NS_QUAL(processheap_allocator) + , ss_typename_param_k T = WINSTL_NS_QUAL(filesystem_traits) + , ss_typename_param_k A = WINSTL_NS_QUAL(processheap_allocator) # else /* ? STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */ - , ss_typename_param_k T /* = filesystem_traits */ - , ss_typename_param_k A /* = processheap_allocator */ + , ss_typename_param_k T /* = filesystem_traits */ + , ss_typename_param_k A /* = processheap_allocator */ # endif /* STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT */ - > + > class basic_path : public WINSTL_NS_QUAL(basic_path__) { private: - typedef WINSTL_NS_QUAL(basic_path__) parent_class_type; - typedef basic_path class_type; + typedef WINSTL_NS_QUAL(basic_path__) parent_class_type; + typedef basic_path class_type; public: - typedef ss_typename_type_k parent_class_type::char_type char_type; - typedef ss_typename_type_k parent_class_type::traits_type traits_type; - typedef ss_typename_type_k parent_class_type::allocator_type allocator_type; - typedef ss_typename_type_k parent_class_type::size_type size_type; + typedef ss_typename_type_k parent_class_type::char_type char_type; + typedef ss_typename_type_k parent_class_type::traits_type + traits_type; + typedef ss_typename_type_k parent_class_type::allocator_type + allocator_type; + typedef ss_typename_type_k parent_class_type::size_type size_type; public: basic_path() @@ -331,9 +356,18 @@ namespace platformstl_project # endif /* STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT */ }; - typedef basic_path > path_a; - typedef basic_path > path_w; - typedef basic_path > path; + typedef basic_path< + ss_char_a_t + , WINSTL_NS_QUAL(filesystem_traits) + > path_a; + typedef basic_path< + ss_char_w_t + , WINSTL_NS_QUAL(filesystem_traits) + > path_w; + typedef basic_path< + TCHAR + , WINSTL_NS_QUAL(filesystem_traits) + > path; # else /* ? compiler */ From 96d8490cf2201e13efda4254d8f03ad8d8b95348 Mon Sep 17 00:00:00 2001 From: synesissoftware Date: Sun, 25 Oct 2026 12:01:45 +1100 Subject: [PATCH 17/22] `auto_buffer` extraneous warning (#74) * 1.11.2 version elements * fix(stlsoft): silence GCC 12+ free-nonheap warning in auto_buffer Mark `deallocate_()` `STLSOFT_NOINLINE` on GCC 12+ so `operator delete` stays out of the inlined destructor, and suppress `-Wfree-nonheap-object` around the external-buffer `delete`, which GCC misattributes to the internal buffer. * test(stlsoft): compare a full sun_path with a counted string A 108-character path fills Linux sun_path and is not NUL-terminated. TEST_MS_EQ then read past the array. Use TEST_MS_EQ_N when the path length is the capacity, as the 104-character case already does. --------- Co-authored-by: Matt Wilson --- CHANGES.md | 5 ++++ INSTALL.md | 18 ++++++------ NEWS.md | 1 + include/stlsoft/memory/auto_buffer.hpp | 29 +++++++++++++++++-- include/stlsoft/stlsoft.h | 11 +++---- .../unixstl/filesystem/filesystem_traits.hpp | 8 ++--- .../inetstl/util/uds_helpers/entry.cpp | 4 +-- test/unit/versions/entry.cpp | 2 +- 8 files changed, 55 insertions(+), 23 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f4a527ce1..adc4a1cb8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,11 @@ # STLSoft - CHANGES +## 1.11.2 - 25th October 2026 + +* **stlsoft/memory/auto_buffer.hpp** — on GCC 12+, marked `deallocate_()` `STLSOFT_NOINLINE` and suppressed `-Wfree-nonheap-object` around the external-buffer `delete`, which GCC misattributes to the internal buffer; + + ## 1.11.1 - 21st October 2026 * Consolidates **1.11.1-alpha1** through **1.11.1-rc10** (20th February 2024 – 20th October 2026); diff --git a/INSTALL.md b/INSTALL.md index 068835b66..8dea259ff 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -23,17 +23,17 @@ There are three options for installing **STLSoft**, depending on how you obtain If you obtain the latest release as an archive from the [**STLSoft** GitHub Releases](https://github.com/synesissoftware/STLSoft/releases) page (legacy archives may also still appear on [SourceForge](https://sourceforge.net/projects/stlsoft/)): -1. Download the latest distribution, e.g. [**STLSoft-1.11.1.zip**](https://github.com/synesissoftware/STLSoft/archive/refs/tags/1.11.1.zip); +1. Download the latest distribution, e.g. [**STLSoft-1.11.2.zip**](https://github.com/synesissoftware/STLSoft/archive/refs/tags/1.11.2.zip); 2. Unzip it to a directory of your choice, as in: ```bash $ mkdir -p ~/open-source $ cd ~/open-source -$ unzip STLSoft-1.11.1.zip +$ unzip STLSoft-1.11.2.zip ``` -3. Define an environment variable `STLSOFT`, whose value is the directory in which you unzipped it, e.g. `STLSOFT=~/open-source/STLSoft-1.11.1`, and then specify `$(STLSOFT)/include` (**UNIX**) or `%STLSOFT%\include` (**Windows**) in your project files and makefiles; +3. Define an environment variable `STLSOFT`, whose value is the directory in which you unzipped it, e.g. `STLSOFT=~/open-source/STLSoft-1.11.2`, and then specify `$(STLSOFT)/include` (**UNIX**) or `%STLSOFT%\include` (**Windows**) in your project files and makefiles; ### Cloning project, using environment variables @@ -100,16 +100,16 @@ $ sudo cmake --install ${SIS_CMAKE_BUILD_DIR:-./_build} --config Release Unless you are certain that your projects, and all the projects upon which they depend, all use **STLSoft** via **CMake** then it is recommended that you define an `STLSOFT` environment variable. For example, if you're using **UNIX** and you install to -**/usr/local/stlsoft/STLSoft-1.11.1** +**/usr/local/stlsoft/STLSoft-1.11.2** then you should set the environment variable `STLSOFT` to -**/usr/local/stlsoft/STLSoft-1.11.1** -in which case the file `stlsoft/stlsoft.h`, for example, will be located in `/usr/local/stlsoft/STLSoft-1.11.1/include/stlsoft/stlsoft.h`. +**/usr/local/stlsoft/STLSoft-1.11.2** +in which case the file `stlsoft/stlsoft.h`, for example, will be located in `/usr/local/stlsoft/STLSoft-1.11.2/include/stlsoft/stlsoft.h`. Conversely, if you're using **Windows** and you install to -**C:\3pty\STLSoft\STLSoft-1.11.1** +**C:\3pty\STLSoft\STLSoft-1.11.2** then you should set the environment variable `STLSOFT` to -**C:\3pty\STLSoft\STLSoft-1.11.1** -in which case the file `stlsoft/stlsoft.h`, for example, will be located in `C:\3pty\STLSoft\STLSoft-1.11.1\include\stlsoft\stlsoft.h`. +**C:\3pty\STLSoft\STLSoft-1.11.2** +in which case the file `stlsoft/stlsoft.h`, for example, will be located in `C:\3pty\STLSoft\STLSoft-1.11.2\include\stlsoft\stlsoft.h`. The makefiles / project files of several other open-source projects expect this symbol, including: diff --git a/NEWS.md b/NEWS.md index f010be404..b214f3cb8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,7 @@ | Date | News Item | Details | | ------------------- | ----------------------------------- | ------- | +| 25th October 2026 | Release of [STLSoft 1.11.2-alpha1](https://github.com/synesissoftware/STLSoft/releases/tag/1.11.2-alpha1) | `auto_buffer` GCC 12+ `-Wfree-nonheap-object` on the external-buffer `delete` | | 21st October 2026 | Release of [STLSoft 1.11.1](https://github.com/synesissoftware/STLSoft/releases/tag/1.11.1) | **1.11.1-alpha1** through **1.11.1-rc10**: process and path APIs; Resizeable Buffer concept; `module` renamed `dl_module`; CI and docs | | 20th October 2026 | Release of [STLSoft 1.11.1-rc10](https://github.com/synesissoftware/STLSoft/releases/tag/1.11.1-rc10) | Resizeable Buffer concept & traits `rb` hardening; **CONCEPTS.md**; `get_module_directory(rb)`; `resizeable_buffer_resize` docs; example **by_concept/resizeable_buffer**; C1–C5 `rb` / `dir_end` fixes; unixstl strip-all `remove_dir_end`; `readdir_sequence` no-exception soft-fail; full-path OOB size fix; `resizeable_buffer_resize` default-arg `resize` (G5); scratch **test.scratch.versions.format** (`std::format`) | | 18th October 2026 | Release of [STLSoft 1.11.1-rc9](https://github.com/synesissoftware/STLSoft/releases/tag/1.11.1-rc9) | `get_current_process_path()` (+ resizeable-buffer overloads) on **unixstl** / **winstl** `system_traits` with component tests; zero-first optional buffers; **unixstl** `wchar_t` path classification and separators; `path_str_*`; wide `get_home_directory()` and `get_environment_variable()`; `\pre` normalised to bare exprs with `nullptr`; subproject version bumps | diff --git a/include/stlsoft/memory/auto_buffer.hpp b/include/stlsoft/memory/auto_buffer.hpp index 92a66dcc9..70678cb8b 100644 --- a/include/stlsoft/memory/auto_buffer.hpp +++ b/include/stlsoft/memory/auto_buffer.hpp @@ -4,7 +4,7 @@ * Purpose: Contains the auto_buffer template class. * * Created: 19th January 2002 - * Updated: 15th October 2026 + * Updated: 23rd October 2026 * * Thanks: To Magnificent Imbecil for pointing out error in documentation, * and for suggesting swap() optimisation. To Thorsten Ottosen for @@ -58,7 +58,7 @@ # define STLSOFT_VER_STLSOFT_MEMORY_HPP_AUTO_BUFFER_MAJOR 5 # define STLSOFT_VER_STLSOFT_MEMORY_HPP_AUTO_BUFFER_MINOR 9 # define STLSOFT_VER_STLSOFT_MEMORY_HPP_AUTO_BUFFER_REVISION 1 -# define STLSOFT_VER_STLSOFT_MEMORY_HPP_AUTO_BUFFER_EDIT 234 +# define STLSOFT_VER_STLSOFT_MEMORY_HPP_AUTO_BUFFER_EDIT 235 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -574,6 +574,14 @@ class auto_buffer return allocate_(cItems, NULL); } +#if defined(STLSOFT_COMPILER_IS_GCC) && \ + __GNUC__ >= 12 + /* Keep operator delete out of the inlined destructor. GCC 12+ + * otherwise reports -Wfree-nonheap-object against the internal + * buffer. + */ + STLSOFT_NOINLINE +#endif /* GCC 12+ */ void deallocate_(pointer p, size_type cItems) { STLSOFT_ASSERT(NULL != p); @@ -1051,7 +1059,24 @@ class auto_buffer STLSOFT_ASSERT(0 != m_cExternal); STLSOFT_ASSERT(&m_internal[0] != m_buffer); + /* GCC 12+ cannot see that this pointer is the external + * array, and -Wfree-nonheap-object then reports a delete + * of the internal buffer. + */ +#if defined(STLSOFT_COMPILER_IS_GCC) && \ + __GNUC__ >= 12 + +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wfree-nonheap-object" +#endif /* GCC 12+ */ + deallocate_(m_buffer, m_cItems); + +#if defined(STLSOFT_COMPILER_IS_GCC) && \ + __GNUC__ >= 12 + +# pragma GCC diagnostic pop +#endif /* GCC 12+ */ } } private: diff --git a/include/stlsoft/stlsoft.h b/include/stlsoft/stlsoft.h index 552c711f4..4489c2e76 100644 --- a/include/stlsoft/stlsoft.h +++ b/include/stlsoft/stlsoft.h @@ -5,7 +5,7 @@ * and platform discriminations, and definitions of types. * * Created: 15th January 2002 - * Updated: 21st October 2026 + * Updated: 25th October 2026 * * Home: http://stlsoft.org/ * @@ -55,8 +55,8 @@ #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION # define STLSOFT_VER_STLSOFT_H_STLSOFT_MAJOR 3 # define STLSOFT_VER_STLSOFT_H_STLSOFT_MINOR 57 -# define STLSOFT_VER_STLSOFT_H_STLSOFT_REVISION 22 -# define STLSOFT_VER_STLSOFT_H_STLSOFT_EDIT 612 +# define STLSOFT_VER_STLSOFT_H_STLSOFT_REVISION 23 +# define STLSOFT_VER_STLSOFT_H_STLSOFT_EDIT 613 #else /* ? STLSOFT_DOCUMENTATION_SKIP_SECTION */ /* # include "./internal/doxygen_defs.h" */ #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -426,12 +426,13 @@ # define _STLSOFT_VER_1_11_1_RC9 0x010B01C9 /*!< Version 1.11.1 rc 9 (18th October 2026) */ # define _STLSOFT_VER_1_11_1_RC10 0x010B01CA /*!< Version 1.11.1 rc 10 (20th October 2026) */ # define _STLSOFT_VER_1_11_1 0x010B01FF /*!< Version 1.11.1 (21st October 2026) */ +# define _STLSOFT_VER_1_11_2_A1 0x010B0241 /*!< Version 1.11.2 alpha 1 (25th October 2026) */ #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ #define _STLSOFT_VER_MAJOR 1 #define _STLSOFT_VER_MINOR 11 -#define _STLSOFT_VER_PATCH 1 -#define _STLSOFT_VER_RELSTATUS 0xFF +#define _STLSOFT_VER_PATCH 2 +#define _STLSOFT_VER_RELSTATUS 0x41 #define _STLSOFT_VER \ (0\ diff --git a/include/unixstl/filesystem/filesystem_traits.hpp b/include/unixstl/filesystem/filesystem_traits.hpp index 2bc63d6d2..ff4b3de32 100644 --- a/include/unixstl/filesystem/filesystem_traits.hpp +++ b/include/unixstl/filesystem/filesystem_traits.hpp @@ -5,7 +5,7 @@ * Unicode specialisations thereof. * * Created: 15th November 2002 - * Updated: 21st October 2026 + * Updated: 25th October 2026 * * Thanks: To Sergey Nikulov, for spotting a preprocessor typo that broke * GCC -pedantic; to Michal Makowski and Zar Eindl for reporting @@ -60,8 +60,8 @@ #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION # define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_MAJOR 5 # define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_MINOR 0 -# define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_REVISION 3 -# define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_EDIT 195 +# define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_REVISION 4 +# define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_EDIT 196 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -1757,7 +1757,7 @@ struct filesystem_traits } private: -#if _STLSOFT_VER >= 0x010b0200 +#if _STLSOFT_VER >= 0x010b0280 # error Sort get_root_len_() properly #endif diff --git a/test/component/inetstl/util/uds_helpers/entry.cpp b/test/component/inetstl/util/uds_helpers/entry.cpp index 3dbea7e7f..dfe4bd5d8 100644 --- a/test/component/inetstl/util/uds_helpers/entry.cpp +++ b/test/component/inetstl/util/uds_helpers/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `inetstl::environment_variable`. * * Created: 21st February 2025 - * Updated: 9th August 2026 + * Updated: 23rd October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -414,7 +414,7 @@ static void TEST_VALID_paths() #endif TEST_INT_EQ(AF_UNIX, sa_un.sun_family); - if (104 == cb_sun_path) + if (108 == cb_sun_path) { TEST_MS_EQ_N("/tmp/sock/01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567", sa_un.sun_path, 108); } diff --git a/test/unit/versions/entry.cpp b/test/unit/versions/entry.cpp index e9d428540..3702a03d9 100644 --- a/test/unit/versions/entry.cpp +++ b/test/unit/versions/entry.cpp @@ -133,7 +133,7 @@ namespace { static void TEST__STLSOFT_VER() { - TEST_INT_EQ(_STLSOFT_VER_1_11_1, _STLSOFT_VER); + TEST_INT_EQ(_STLSOFT_VER_1_11_2_A1, _STLSOFT_VER); } #ifdef STLSOFT_HAS_ACE From 7fa5410fe25a241135c029b625e2ba7abb34b3cd Mon Sep 17 00:00:00 2001 From: Matt Wilson <152443343+mwsis@users.noreply.github.com> Date: Sun, 25 Oct 2026 13:16:41 +1100 Subject: [PATCH 18/22] refactor(unit-tests): applying xTests' null macros (#70) * refactor(unit-tests): applying xTests' null macros * 1.11.2-alpha1 * `auto_buffer` extraneous warning (#74) * 1.11.2 version elements * fix(stlsoft): silence GCC 12+ free-nonheap warning in auto_buffer Mark `deallocate_()` `STLSOFT_NOINLINE` on GCC 12+ so `operator delete` stays out of the inlined destructor, and suppress `-Wfree-nonheap-object` around the external-buffer `delete`, which GCC misattributes to the internal buffer. * test(stlsoft): compare a full sun_path with a counted string A 108-character path fills Linux sun_path and is not NUL-terminated. TEST_MS_EQ then read past the array. Use TEST_MS_EQ_N when the path length is the capacity, as the 104-character case already does. --------- Co-authored-by: Matt Wilson --------- Co-authored-by: synesissoftware --- CHANGES.md | 8 ++ CMakeLists.txt | 2 +- INSTALL.md | 18 ++-- NEWS.md | 1 + include/stlsoft/memory/auto_buffer.hpp | 29 +++++- include/stlsoft/stlsoft.h | 11 ++- .../unixstl/filesystem/filesystem_traits.hpp | 8 +- .../inetstl/util/uds_helpers/entry.cpp | 4 +- .../environment_variable_traits/entry.cpp | 4 +- .../environment_variable_exists/entry.cpp | 6 +- .../unixstl/system/process_paths/entry.cpp | 10 +- .../filesystem/memory_map_functions.C/entry.c | 8 +- .../winstl/system/process_paths/entry.cpp | 18 ++-- .../shims/access/string/string_base/entry.cpp | 8 +- .../comstl/memory/task_allocator/entry.cpp | 6 +- .../comstl/string/BSTR_functions.C/entry.c | 12 +-- .../comstl/string/BSTR_functions/entry.cpp | 4 +- .../shims/access/string/std.in_addr/entry.cpp | 8 +- .../mfcstl/memory/afx_allocator/entry.cpp | 6 +- .../system/commandline_parser/entry.cpp | 24 ++--- .../conversion/string_to_integer/entry.cpp | 52 +++++------ .../stlsoft/conversion/try_parse_to/entry.cpp | 4 +- .../unit/stlsoft/memory/auto_buffer.C/entry.c | 20 ++-- .../stlsoft/memory/malloc_allocator/entry.cpp | 6 +- .../stlsoft/memory/new_allocator/entry.cpp | 6 +- .../stlsoft/smartptr/shared_ptr/entry.cpp | 92 +++++++++---------- .../unit/stlsoft/string/shim_string/entry.cpp | 24 ++--- .../stlsoft/string/simple_string/entry.cpp | 26 +++--- .../stlsoft/string/static_string/entry.cpp | 26 +++--- .../stlsoft/string/string_slice/entry.cpp | 26 +++--- .../unit/stlsoft/string/string_view/entry.cpp | 26 +++--- .../filesystem/filesystem_traits/entry.cpp | 14 +-- test/unit/unixstl/filesystem/path/entry.cpp | 18 ++-- test/unit/versions/entry.cpp | 2 +- .../filesystem/filesystem_traits/entry.cpp | 34 +++---- .../winstl/memory/global_allocator/entry.cpp | 6 +- .../winstl/memory/netapi_allocator/entry.cpp | 6 +- .../memory/processheap_allocator/entry.cpp | 6 +- .../winstl/memory/shell_allocator/entry.cpp | 6 +- .../winstl/util/struct_initialisers/entry.cpp | 20 ++-- 40 files changed, 325 insertions(+), 290 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f4a527ce1..b58bcd34a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,14 @@ # STLSoft - CHANGES +## 1.11.2 - 25th October 2026 + +* fixes: + * **stlsoft/memory/auto_buffer.hpp** — on GCC 12+, marked `deallocate_()` `STLSOFT_NOINLINE` and suppressed `-Wfree-nonheap-object` around the external-buffer `delete`, which GCC misattributes to the internal buffer; +* testing: + * applies xTests' null-ptr macros; + + ## 1.11.1 - 21st October 2026 * Consolidates **1.11.1-alpha1** through **1.11.1-rc10** (20th February 2024 – 20th October 2026); diff --git a/CMakeLists.txt b/CMakeLists.txt index f8d841bab..3f220a11f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -291,7 +291,7 @@ endif() if(BUILD_TESTING) - set(xTests_REQUIRED_VERSION_ 0.26.4) + set(xTests_REQUIRED_VERSION_ 0.28) find_package(xTests ${xTests_REQUIRED_VERSION_} REQUIRED) diff --git a/INSTALL.md b/INSTALL.md index 068835b66..8dea259ff 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -23,17 +23,17 @@ There are three options for installing **STLSoft**, depending on how you obtain If you obtain the latest release as an archive from the [**STLSoft** GitHub Releases](https://github.com/synesissoftware/STLSoft/releases) page (legacy archives may also still appear on [SourceForge](https://sourceforge.net/projects/stlsoft/)): -1. Download the latest distribution, e.g. [**STLSoft-1.11.1.zip**](https://github.com/synesissoftware/STLSoft/archive/refs/tags/1.11.1.zip); +1. Download the latest distribution, e.g. [**STLSoft-1.11.2.zip**](https://github.com/synesissoftware/STLSoft/archive/refs/tags/1.11.2.zip); 2. Unzip it to a directory of your choice, as in: ```bash $ mkdir -p ~/open-source $ cd ~/open-source -$ unzip STLSoft-1.11.1.zip +$ unzip STLSoft-1.11.2.zip ``` -3. Define an environment variable `STLSOFT`, whose value is the directory in which you unzipped it, e.g. `STLSOFT=~/open-source/STLSoft-1.11.1`, and then specify `$(STLSOFT)/include` (**UNIX**) or `%STLSOFT%\include` (**Windows**) in your project files and makefiles; +3. Define an environment variable `STLSOFT`, whose value is the directory in which you unzipped it, e.g. `STLSOFT=~/open-source/STLSoft-1.11.2`, and then specify `$(STLSOFT)/include` (**UNIX**) or `%STLSOFT%\include` (**Windows**) in your project files and makefiles; ### Cloning project, using environment variables @@ -100,16 +100,16 @@ $ sudo cmake --install ${SIS_CMAKE_BUILD_DIR:-./_build} --config Release Unless you are certain that your projects, and all the projects upon which they depend, all use **STLSoft** via **CMake** then it is recommended that you define an `STLSOFT` environment variable. For example, if you're using **UNIX** and you install to -**/usr/local/stlsoft/STLSoft-1.11.1** +**/usr/local/stlsoft/STLSoft-1.11.2** then you should set the environment variable `STLSOFT` to -**/usr/local/stlsoft/STLSoft-1.11.1** -in which case the file `stlsoft/stlsoft.h`, for example, will be located in `/usr/local/stlsoft/STLSoft-1.11.1/include/stlsoft/stlsoft.h`. +**/usr/local/stlsoft/STLSoft-1.11.2** +in which case the file `stlsoft/stlsoft.h`, for example, will be located in `/usr/local/stlsoft/STLSoft-1.11.2/include/stlsoft/stlsoft.h`. Conversely, if you're using **Windows** and you install to -**C:\3pty\STLSoft\STLSoft-1.11.1** +**C:\3pty\STLSoft\STLSoft-1.11.2** then you should set the environment variable `STLSOFT` to -**C:\3pty\STLSoft\STLSoft-1.11.1** -in which case the file `stlsoft/stlsoft.h`, for example, will be located in `C:\3pty\STLSoft\STLSoft-1.11.1\include\stlsoft\stlsoft.h`. +**C:\3pty\STLSoft\STLSoft-1.11.2** +in which case the file `stlsoft/stlsoft.h`, for example, will be located in `C:\3pty\STLSoft\STLSoft-1.11.2\include\stlsoft\stlsoft.h`. The makefiles / project files of several other open-source projects expect this symbol, including: diff --git a/NEWS.md b/NEWS.md index f010be404..6949a43cd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,7 @@ | Date | News Item | Details | | ------------------- | ----------------------------------- | ------- | +| 25th October 2026 | Release of [STLSoft 1.11.2](https://github.com/synesissoftware/STLSoft/releases/tag/1.11.2) | `auto_buffer` GCC 12+ `-Wfree-nonheap-object` on the external-buffer `delete`; xTests' null-ptr macros; | | 21st October 2026 | Release of [STLSoft 1.11.1](https://github.com/synesissoftware/STLSoft/releases/tag/1.11.1) | **1.11.1-alpha1** through **1.11.1-rc10**: process and path APIs; Resizeable Buffer concept; `module` renamed `dl_module`; CI and docs | | 20th October 2026 | Release of [STLSoft 1.11.1-rc10](https://github.com/synesissoftware/STLSoft/releases/tag/1.11.1-rc10) | Resizeable Buffer concept & traits `rb` hardening; **CONCEPTS.md**; `get_module_directory(rb)`; `resizeable_buffer_resize` docs; example **by_concept/resizeable_buffer**; C1–C5 `rb` / `dir_end` fixes; unixstl strip-all `remove_dir_end`; `readdir_sequence` no-exception soft-fail; full-path OOB size fix; `resizeable_buffer_resize` default-arg `resize` (G5); scratch **test.scratch.versions.format** (`std::format`) | | 18th October 2026 | Release of [STLSoft 1.11.1-rc9](https://github.com/synesissoftware/STLSoft/releases/tag/1.11.1-rc9) | `get_current_process_path()` (+ resizeable-buffer overloads) on **unixstl** / **winstl** `system_traits` with component tests; zero-first optional buffers; **unixstl** `wchar_t` path classification and separators; `path_str_*`; wide `get_home_directory()` and `get_environment_variable()`; `\pre` normalised to bare exprs with `nullptr`; subproject version bumps | diff --git a/include/stlsoft/memory/auto_buffer.hpp b/include/stlsoft/memory/auto_buffer.hpp index 92a66dcc9..70678cb8b 100644 --- a/include/stlsoft/memory/auto_buffer.hpp +++ b/include/stlsoft/memory/auto_buffer.hpp @@ -4,7 +4,7 @@ * Purpose: Contains the auto_buffer template class. * * Created: 19th January 2002 - * Updated: 15th October 2026 + * Updated: 23rd October 2026 * * Thanks: To Magnificent Imbecil for pointing out error in documentation, * and for suggesting swap() optimisation. To Thorsten Ottosen for @@ -58,7 +58,7 @@ # define STLSOFT_VER_STLSOFT_MEMORY_HPP_AUTO_BUFFER_MAJOR 5 # define STLSOFT_VER_STLSOFT_MEMORY_HPP_AUTO_BUFFER_MINOR 9 # define STLSOFT_VER_STLSOFT_MEMORY_HPP_AUTO_BUFFER_REVISION 1 -# define STLSOFT_VER_STLSOFT_MEMORY_HPP_AUTO_BUFFER_EDIT 234 +# define STLSOFT_VER_STLSOFT_MEMORY_HPP_AUTO_BUFFER_EDIT 235 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -574,6 +574,14 @@ class auto_buffer return allocate_(cItems, NULL); } +#if defined(STLSOFT_COMPILER_IS_GCC) && \ + __GNUC__ >= 12 + /* Keep operator delete out of the inlined destructor. GCC 12+ + * otherwise reports -Wfree-nonheap-object against the internal + * buffer. + */ + STLSOFT_NOINLINE +#endif /* GCC 12+ */ void deallocate_(pointer p, size_type cItems) { STLSOFT_ASSERT(NULL != p); @@ -1051,7 +1059,24 @@ class auto_buffer STLSOFT_ASSERT(0 != m_cExternal); STLSOFT_ASSERT(&m_internal[0] != m_buffer); + /* GCC 12+ cannot see that this pointer is the external + * array, and -Wfree-nonheap-object then reports a delete + * of the internal buffer. + */ +#if defined(STLSOFT_COMPILER_IS_GCC) && \ + __GNUC__ >= 12 + +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wfree-nonheap-object" +#endif /* GCC 12+ */ + deallocate_(m_buffer, m_cItems); + +#if defined(STLSOFT_COMPILER_IS_GCC) && \ + __GNUC__ >= 12 + +# pragma GCC diagnostic pop +#endif /* GCC 12+ */ } } private: diff --git a/include/stlsoft/stlsoft.h b/include/stlsoft/stlsoft.h index 552c711f4..4489c2e76 100644 --- a/include/stlsoft/stlsoft.h +++ b/include/stlsoft/stlsoft.h @@ -5,7 +5,7 @@ * and platform discriminations, and definitions of types. * * Created: 15th January 2002 - * Updated: 21st October 2026 + * Updated: 25th October 2026 * * Home: http://stlsoft.org/ * @@ -55,8 +55,8 @@ #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION # define STLSOFT_VER_STLSOFT_H_STLSOFT_MAJOR 3 # define STLSOFT_VER_STLSOFT_H_STLSOFT_MINOR 57 -# define STLSOFT_VER_STLSOFT_H_STLSOFT_REVISION 22 -# define STLSOFT_VER_STLSOFT_H_STLSOFT_EDIT 612 +# define STLSOFT_VER_STLSOFT_H_STLSOFT_REVISION 23 +# define STLSOFT_VER_STLSOFT_H_STLSOFT_EDIT 613 #else /* ? STLSOFT_DOCUMENTATION_SKIP_SECTION */ /* # include "./internal/doxygen_defs.h" */ #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -426,12 +426,13 @@ # define _STLSOFT_VER_1_11_1_RC9 0x010B01C9 /*!< Version 1.11.1 rc 9 (18th October 2026) */ # define _STLSOFT_VER_1_11_1_RC10 0x010B01CA /*!< Version 1.11.1 rc 10 (20th October 2026) */ # define _STLSOFT_VER_1_11_1 0x010B01FF /*!< Version 1.11.1 (21st October 2026) */ +# define _STLSOFT_VER_1_11_2_A1 0x010B0241 /*!< Version 1.11.2 alpha 1 (25th October 2026) */ #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ #define _STLSOFT_VER_MAJOR 1 #define _STLSOFT_VER_MINOR 11 -#define _STLSOFT_VER_PATCH 1 -#define _STLSOFT_VER_RELSTATUS 0xFF +#define _STLSOFT_VER_PATCH 2 +#define _STLSOFT_VER_RELSTATUS 0x41 #define _STLSOFT_VER \ (0\ diff --git a/include/unixstl/filesystem/filesystem_traits.hpp b/include/unixstl/filesystem/filesystem_traits.hpp index 2bc63d6d2..ff4b3de32 100644 --- a/include/unixstl/filesystem/filesystem_traits.hpp +++ b/include/unixstl/filesystem/filesystem_traits.hpp @@ -5,7 +5,7 @@ * Unicode specialisations thereof. * * Created: 15th November 2002 - * Updated: 21st October 2026 + * Updated: 25th October 2026 * * Thanks: To Sergey Nikulov, for spotting a preprocessor typo that broke * GCC -pedantic; to Michal Makowski and Zar Eindl for reporting @@ -60,8 +60,8 @@ #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION # define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_MAJOR 5 # define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_MINOR 0 -# define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_REVISION 3 -# define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_EDIT 195 +# define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_REVISION 4 +# define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS_EDIT 196 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -1757,7 +1757,7 @@ struct filesystem_traits } private: -#if _STLSOFT_VER >= 0x010b0200 +#if _STLSOFT_VER >= 0x010b0280 # error Sort get_root_len_() properly #endif diff --git a/test/component/inetstl/util/uds_helpers/entry.cpp b/test/component/inetstl/util/uds_helpers/entry.cpp index 3dbea7e7f..dfe4bd5d8 100644 --- a/test/component/inetstl/util/uds_helpers/entry.cpp +++ b/test/component/inetstl/util/uds_helpers/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `inetstl::environment_variable`. * * Created: 21st February 2025 - * Updated: 9th August 2026 + * Updated: 23rd October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -414,7 +414,7 @@ static void TEST_VALID_paths() #endif TEST_INT_EQ(AF_UNIX, sa_un.sun_family); - if (104 == cb_sun_path) + if (108 == cb_sun_path) { TEST_MS_EQ_N("/tmp/sock/01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567", sa_un.sun_path, 108); } diff --git a/test/component/platformstl/system/environment_variable_traits/entry.cpp b/test/component/platformstl/system/environment_variable_traits/entry.cpp index 1aebcba68..f13248f26 100644 --- a/test/component/platformstl/system/environment_variable_traits/entry.cpp +++ b/test/component/platformstl/system/environment_variable_traits/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `platformstl::environment_variable_traits`. * * Created: 30th December 2024 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -105,7 +105,7 @@ static void TEST_set_variable() { char const* ev_value = environment_variable_traits::get_variable("EV_2C4D392B_22CD_4452_9525_382043AD2611"); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, ev_value)); + REQUIRE(TEST_PTR_NOT_NULL(ev_value)); TEST_MS_EQ("some-value", ev_value); } diff --git a/test/component/stlsoft/system/environment_variable_exists/entry.cpp b/test/component/stlsoft/system/environment_variable_exists/entry.cpp index 6fbb2d096..2fb204fc3 100644 --- a/test/component/stlsoft/system/environment_variable_exists/entry.cpp +++ b/test/component/stlsoft/system/environment_variable_exists/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Component-tests for `stlsoft::environment_variable_exists()`. * * Created: 28th September 2026 - * Updated: 8th October 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -231,7 +231,7 @@ static void TEST_environment_variable_exists_WHEN_EMPTY() char const* const value = ::getenv(name); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, value)); + REQUIRE(TEST_PTR_NOT_NULL(value)); TEST_MS_EQ("", value); TEST_BOOLEAN_TRUE(stlsoft::stlsoft_C_environment_variable_exists_m(name)); @@ -250,7 +250,7 @@ static void TEST_environment_variable_exists_WHEN_EMPTY() char const* const value = ::getenv(name); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, value)); + REQUIRE(TEST_PTR_NOT_NULL(value)); TEST_MS_EQ("", value); TEST_BOOLEAN_TRUE(stlsoft::stlsoft_C_environment_variable_exists_m(name)); diff --git a/test/component/unixstl/system/process_paths/entry.cpp b/test/component/unixstl/system/process_paths/entry.cpp index f32271f41..80d6a8cf3 100644 --- a/test/component/unixstl/system/process_paths/entry.cpp +++ b/test/component/unixstl/system/process_paths/entry.cpp @@ -6,7 +6,7 @@ * including resizeable-buffer overloads. * * Created: 15th October 2026 - * Updated: 18th October 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -345,7 +345,7 @@ static void TEST_SIZE_QUERY() size_t const cch = traits_m_t::get_current_process_path(0, NULL, &pFile); TEST_INT_EQ(expected.size() + 1, cch); - TEST_PTR_EQ(NULL, pFile); + TEST_PTR_NULL(pFile); } static void TEST_EXACT_FIT() @@ -402,7 +402,7 @@ static void TEST_INSUFFICIENT_SPACE() size_t const cch = traits_m_t::get_current_process_path(buff.size(), &buff[0], &pFile); TEST_INT_EQ(len + 1, cch); - TEST_PTR_EQ(NULL, pFile); + TEST_PTR_NULL(pFile); TEST_CHAR_EQ('\0', buff[cchBuff - 1]); TEST_MS_EQ_N(expected.c_str(), &buff[0], cchBuff - 1); } @@ -414,7 +414,7 @@ static void TEST_INSUFFICIENT_SPACE() size_t const cch = traits_m_t::get_current_process_path(STLSOFT_NUM_ELEMENTS(buff), buff, &pFile); TEST_INT_EQ(len + 1, cch); - TEST_PTR_EQ(NULL, pFile); + TEST_PTR_NULL(pFile); TEST_CHAR_EQ('\0', buff[0]); } } @@ -467,7 +467,7 @@ static void TEST_ppFile_NULL_WHEN_INSUFFICIENT() size_t const cch = traits_m_t::get_current_process_path(buff.size(), &buff[0], &pFile); TEST_INT_EQ(len + 1, cch); - TEST_PTR_EQ(NULL, pFile); + TEST_PTR_NULL(pFile); } static void TEST_RESIZEABLE_auto_buffer_SUCCESS() diff --git a/test/component/winstl/filesystem/memory_map_functions.C/entry.c b/test/component/winstl/filesystem/memory_map_functions.C/entry.c index 6e5ef2b84..1e51395c8 100644 --- a/test/component/winstl/filesystem/memory_map_functions.C/entry.c +++ b/test/component/winstl/filesystem/memory_map_functions.C/entry.c @@ -4,7 +4,7 @@ * Purpose: Scratch test for memory-map functions. * * Created: 26th August 2010 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -161,7 +161,7 @@ static void test_1_0() ws_uintptr_t viewSize = 0; void* view = winstl_C_map_readonly_view_of_file_by_name_a(TEST_FILE_NAME, GENERIC_READ, 0, 0, 0, &viewSize); - TEST_PTR_NE(NULL, view); + TEST_PTR_NOT_NULL(view); if (NULL != view) { @@ -195,7 +195,7 @@ static void test_1_1() STLSOFT_SUPPRESS_UNUSED(err); - TEST_PTR_NE(NULL, view); + TEST_PTR_NOT_NULL(view); TEST_INT_EQ(requestSize, viewSize); if (NULL != view) @@ -232,7 +232,7 @@ static void test_1_2() STLSOFT_SUPPRESS_UNUSED(err); - TEST_PTR_NE(NULL, view); + TEST_PTR_NOT_NULL(view); if (0 == requestSize) { TEST_INT_EQ(TEST_FILE_SIZE - offset, viewSize); diff --git a/test/component/winstl/system/process_paths/entry.cpp b/test/component/winstl/system/process_paths/entry.cpp index c4360129e..33d9f65ed 100644 --- a/test/component/winstl/system/process_paths/entry.cpp +++ b/test/component/winstl/system/process_paths/entry.cpp @@ -6,7 +6,7 @@ * and wide-character), including resizeable-buffer overloads. * * Created: 15th October 2026 - * Updated: 18th October 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -246,7 +246,7 @@ static void TEST_size_QUERY_m() /* Demand may exceed len+1 (WinSTL GetModuleFileName size protocol). */ TEST_INT_GE(expected.size() + 1, cch); - TEST_PTR_EQ(NULL, pFile); + TEST_PTR_NULL(pFile); } static void TEST_size_QUERY_w() @@ -259,7 +259,7 @@ static void TEST_size_QUERY_w() size_t const cch = traits_w_t::get_current_process_path(0, NULL, &pFile); TEST_INT_GE(expected.size() + 1, cch); - TEST_PTR_EQ(NULL, pFile); + TEST_PTR_NULL(pFile); } static void TEST_size_THEN_SUFFICIENT_m() @@ -361,7 +361,7 @@ static void TEST_INSUFFICIENT_SPACE_m() size_t const cch = traits_m_t::get_current_process_path(buff.size(), &buff[0], &pFile); TEST_INT_GE(len + 1, cch); - TEST_PTR_EQ(NULL, pFile); + TEST_PTR_NULL(pFile); TEST_CHAR_EQ('\0', buff[cchBuff - 1]); TEST_MS_EQ_N(expected.c_str(), &buff[0], cchBuff - 1); } @@ -372,7 +372,7 @@ static void TEST_INSUFFICIENT_SPACE_m() size_t const cch = traits_m_t::get_current_process_path(STLSOFT_NUM_ELEMENTS(buff), buff, &pFile); TEST_INT_GE(len + 1, cch); - TEST_PTR_EQ(NULL, pFile); + TEST_PTR_NULL(pFile); TEST_CHAR_EQ('\0', buff[0]); } } @@ -398,7 +398,7 @@ static void TEST_INSUFFICIENT_SPACE_w() size_t const cch = traits_w_t::get_current_process_path(buff.size(), &buff[0], &pFile); TEST_INT_GE(len + 1, cch); - TEST_PTR_EQ(NULL, pFile); + TEST_PTR_NULL(pFile); TEST_CHAR_EQ(L'\0', buff[cchBuff - 1]); TEST_WS_EQ_N(expected.c_str(), &buff[0], cchBuff - 1); } @@ -409,7 +409,7 @@ static void TEST_INSUFFICIENT_SPACE_w() size_t const cch = traits_w_t::get_current_process_path(STLSOFT_NUM_ELEMENTS(buff), buff, &pFile); TEST_INT_GE(len + 1, cch); - TEST_PTR_EQ(NULL, pFile); + TEST_PTR_NULL(pFile); TEST_CHAR_EQ(L'\0', buff[0]); } } @@ -514,7 +514,7 @@ static void TEST_ppFile_NULL_WHEN_INSUFFICIENT_m() size_t const cch = traits_m_t::get_current_process_path(buff.size(), &buff[0], &pFile); TEST_INT_GE(len + 1, cch); - TEST_PTR_EQ(NULL, pFile); + TEST_PTR_NULL(pFile); } static void TEST_ppFile_NULL_WHEN_INSUFFICIENT_w() @@ -529,7 +529,7 @@ static void TEST_ppFile_NULL_WHEN_INSUFFICIENT_w() size_t const cch = traits_w_t::get_current_process_path(buff.size(), &buff[0], &pFile); TEST_INT_GE(len + 1, cch); - TEST_PTR_EQ(NULL, pFile); + TEST_PTR_NULL(pFile); } static void TEST_RESIZEABLE_auto_buffer_SUCCESS_m() diff --git a/test/unit/acestl/shims/access/string/string_base/entry.cpp b/test/unit/acestl/shims/access/string/string_base/entry.cpp index b94440922..d100aeee1 100644 --- a/test/unit/acestl/shims/access/string/string_base/entry.cpp +++ b/test/unit/acestl/shims/access/string/string_base/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for string-access-shims for `ACE_String_Base`. * * Created: 7th August 2026 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -110,8 +110,8 @@ static void TEST_empty_string() TEST_INT_EQ(0u, stlsoft::c_str_len_a(s)); TEST_INT_EQ(0u, stlsoft::c_str_len(s)); - TEST_PTR_EQ(NULL, stlsoft::c_str_ptr_null_a(s)); - TEST_PTR_EQ(NULL, stlsoft::c_str_ptr_null(s)); + TEST_PTR_NULL(stlsoft::c_str_ptr_null_a(s)); + TEST_PTR_NULL(stlsoft::c_str_ptr_null(s)); TEST_MS_EQ("", stlsoft::c_str_ptr_a(s)); TEST_MS_EQ("", stlsoft::c_str_ptr(s)); @@ -131,7 +131,7 @@ static void TEST_non_empty_string() TEST_MS_EQ(expected, stlsoft::c_str_data_a(s)); TEST_MS_EQ(expected, stlsoft::c_str_data(s)); - TEST_PTR_NE(NULL, stlsoft::c_str_ptr_null_a(s)); + TEST_PTR_NOT_NULL(stlsoft::c_str_ptr_null_a(s)); TEST_MS_EQ(expected, stlsoft::c_str_ptr_null_a(s)); } diff --git a/test/unit/comstl/memory/task_allocator/entry.cpp b/test/unit/comstl/memory/task_allocator/entry.cpp index 8f0728582..a2f05da87 100644 --- a/test/unit/comstl/memory/task_allocator/entry.cpp +++ b/test/unit/comstl/memory/task_allocator/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `comstl::task_allocator`. * * Created: 18th October 2024 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -102,7 +102,7 @@ static void exercise_allocate(allocator_t::size_type n) allocator_t ator; allocator_t::pointer p = ator.allocate(n); - TEST_PTR_NE(NULL, p); + TEST_PTR_NOT_NULL(p); for (allocator_t::size_type i = 0; i != n; ++i) { @@ -129,7 +129,7 @@ static void test_alloc_0() allocator_t::pointer p = a1.allocate(0); - TEST_PTR_NE(NULL, p); + TEST_PTR_NOT_NULL(p); a1.deallocate(p); } diff --git a/test/unit/comstl/string/BSTR_functions.C/entry.c b/test/unit/comstl/string/BSTR_functions.C/entry.c index b657d3149..ac1e92401 100644 --- a/test/unit/comstl/string/BSTR_functions.C/entry.c +++ b/test/unit/comstl/string/BSTR_functions.C/entry.c @@ -4,7 +4,7 @@ * Purpose: Scratch test for BSTR functions. * * Created: 31st May 2010 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -104,7 +104,7 @@ static void test_comstl_C_BSTR_create_w_1() { BSTR s = comstl_C_BSTR_create_w(NULL); - TEST_PTR_EQ(NULL, s); + TEST_PTR_NULL(s); TEST_INT_EQ(0u, SysStringLen(s)); TEST_INT_EQ(SysStringLen(s), comstl_C_BSTR_len(s)); } @@ -112,7 +112,7 @@ static void test_comstl_C_BSTR_create_w_1() { BSTR s = comstl_C_BSTR_create_w(L""); - TEST_PTR_NE(NULL, s); + TEST_PTR_NOT_NULL(s); TEST_INT_EQ(0u, SysStringLen(s)); TEST_INT_EQ(SysStringLen(s), comstl_C_BSTR_len(s)); @@ -148,13 +148,13 @@ static void test_comstl_C_BSTR_create_a_1() { BSTR s = comstl_C_BSTR_create_a(NULL); - TEST_PTR_EQ(NULL, s); + TEST_PTR_NULL(s); } { BSTR s = comstl_C_BSTR_create_a(""); - TEST_PTR_NE(NULL, s); + TEST_PTR_NOT_NULL(s); TEST_INT_EQ(0u, SysStringLen(s)); comstl_C_BSTR_destroy(s); @@ -242,7 +242,7 @@ static void TEST_comstl_C_BSTR_compare_EMPTY() BSTR const empty = comstl_C_BSTR_create_w(L""); BSTR const a = comstl_C_BSTR_create_w(L"a"); - TEST_PTR_NE(NULL, empty); + TEST_PTR_NOT_NULL(empty); TEST_INT_EQ(0u, SysStringLen(empty)); TEST_INT_EQ(0, comstl_C_BSTR_compare(empty, empty)); diff --git a/test/unit/comstl/string/BSTR_functions/entry.cpp b/test/unit/comstl/string/BSTR_functions/entry.cpp index db231fec4..b90499bb2 100644 --- a/test/unit/comstl/string/BSTR_functions/entry.cpp +++ b/test/unit/comstl/string/BSTR_functions/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for comstl BSTR comparison. * * Created: 29th September 2026 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -105,7 +105,7 @@ static void TEST_comstl_C_BSTR_compare_EMPTY() BSTR const empty = comstl::comstl_C_BSTR_create_w(L""); BSTR const a = comstl::comstl_C_BSTR_create_w(L"a"); - TEST_PTR_NE(NULL, empty); + TEST_PTR_NOT_NULL(empty); TEST_INT_EQ(0u, SysStringLen(empty)); TEST_INT_EQ(0, comstl::BSTR_compare(empty, empty)); diff --git a/test/unit/inetstl/shims/access/string/std.in_addr/entry.cpp b/test/unit/inetstl/shims/access/string/std.in_addr/entry.cpp index c763b4fec..c4e7111dd 100644 --- a/test/unit/inetstl/shims/access/string/std.in_addr/entry.cpp +++ b/test/unit/inetstl/shims/access/string/std.in_addr/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for string-access-shims for `struct in_addr`. * * Created: ... - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -151,11 +151,11 @@ static void TEST_nullptr() /* c_str_ptr(|_a|_w) */ { - TEST_PTR_EQ(NULL, stlsoft::c_str_ptr_null_a(stlsoft::c_str_ptr_null_a(addr))); + TEST_PTR_NULL(stlsoft::c_str_ptr_null_a(stlsoft::c_str_ptr_null_a(addr))); # ifdef PLATFORMSTL_OS_IS_WINDOWS - TEST_PTR_EQ(NULL, stlsoft::c_str_ptr_null_w(stlsoft::c_str_ptr_null_w(addr))); - TEST_PTR_EQ(NULL, stlsoft::c_str_ptr_null(stlsoft::c_str_ptr_null(addr))); + TEST_PTR_NULL(stlsoft::c_str_ptr_null_w(stlsoft::c_str_ptr_null_w(addr))); + TEST_PTR_NULL(stlsoft::c_str_ptr_null(stlsoft::c_str_ptr_null(addr))); # endif } #endif diff --git a/test/unit/mfcstl/memory/afx_allocator/entry.cpp b/test/unit/mfcstl/memory/afx_allocator/entry.cpp index 8742fed2b..17bce492e 100644 --- a/test/unit/mfcstl/memory/afx_allocator/entry.cpp +++ b/test/unit/mfcstl/memory/afx_allocator/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `mfcstl::afx_allocator`. * * Created: 18th October 2024 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -102,7 +102,7 @@ static void exercise_allocate(allocator_t::size_type n) allocator_t ator; allocator_t::pointer p = ator.allocate(n); - TEST_PTR_NE(NULL, p); + TEST_PTR_NOT_NULL(p); for (allocator_t::size_type i = 0; i != n; ++i) { @@ -129,7 +129,7 @@ static void test_alloc_0() allocator_t::pointer p = a1.allocate(0); - TEST_PTR_NE(NULL, p); + TEST_PTR_NOT_NULL(p); a1.deallocate(p); } diff --git a/test/unit/platformstl/system/commandline_parser/entry.cpp b/test/unit/platformstl/system/commandline_parser/entry.cpp index b86494f28..7eeae23de 100644 --- a/test/unit/platformstl/system/commandline_parser/entry.cpp +++ b/test/unit/platformstl/system/commandline_parser/entry.cpp @@ -5,7 +5,7 @@ * Purpose: Unit-tests for `stlsoft::commandline_parser` / `winstl::commandline_parser`. * * Created: 29th December 2024 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -126,7 +126,7 @@ static void TEST_EMPTY_STRING() TEST_INT_EQ(0u, clp.size()); TEST_INT_EQ(0, std::distance(clp.begin(), clp.end())); - TEST_PTR_EQ(NULL, clp[0]); + TEST_PTR_NULL(clp[0]); } static void TEST_WHITESPACE_ONLY_STRING() @@ -136,7 +136,7 @@ static void TEST_WHITESPACE_ONLY_STRING() TEST_INT_EQ(0u, clp.size()); TEST_INT_EQ(0, std::distance(clp.begin(), clp.end())); - TEST_PTR_EQ(NULL, clp[0]); + TEST_PTR_NULL(clp[0]); } static void TEST_ONE_VALUE() @@ -147,7 +147,7 @@ static void TEST_ONE_VALUE() TEST_INT_EQ(1, std::distance(clp.begin(), clp.end())); TEST_MS_EQ("abc", clp[0]); - TEST_PTR_EQ(NULL, clp[1]); + TEST_PTR_NULL(clp[1]); } static void TEST_TWO_VALUES() @@ -159,7 +159,7 @@ static void TEST_TWO_VALUES() TEST_MS_EQ("abc", clp[0]); TEST_MS_EQ("def", clp[1]); - TEST_PTR_EQ(NULL, clp[2]); + TEST_PTR_NULL(clp[2]); } static void TEST_ONE_FLAG() @@ -170,7 +170,7 @@ static void TEST_ONE_FLAG() TEST_INT_EQ(1, std::distance(clp.begin(), clp.end())); TEST_MS_EQ("--flag1", clp[0]); - TEST_PTR_EQ(NULL, clp[1]); + TEST_PTR_NULL(clp[1]); } static void TEST_TWO_FLAGS() @@ -182,7 +182,7 @@ static void TEST_TWO_FLAGS() TEST_MS_EQ("--flag1", clp[0]); TEST_MS_EQ("-f2", clp[1]); - TEST_PTR_EQ(NULL, clp[2]); + TEST_PTR_NULL(clp[2]); } static void TEST_ONE_OPTION() @@ -193,7 +193,7 @@ static void TEST_ONE_OPTION() TEST_INT_EQ(1, std::distance(clp.begin(), clp.end())); TEST_MS_EQ("--option1=abc", clp[0]); - TEST_PTR_EQ(NULL, clp[1]); + TEST_PTR_NULL(clp[1]); } static void TEST_DOC_EXAMPLE() @@ -206,7 +206,7 @@ static void TEST_DOC_EXAMPLE() TEST_MS_EQ("abc", clp[0]); TEST_MS_EQ("d e f", clp[1]); TEST_MS_EQ("ghi", clp[2]); - TEST_PTR_EQ(NULL, clp[3]); + TEST_PTR_NULL(clp[3]); } static void TEST_ONE_OPTION_WITH_SPACES_1() @@ -217,7 +217,7 @@ static void TEST_ONE_OPTION_WITH_SPACES_1() TEST_INT_EQ(1, std::distance(clp.begin(), clp.end())); TEST_MS_EQ("--option1=a b c", clp[0]); - TEST_PTR_EQ(NULL, clp[1]); + TEST_PTR_NULL(clp[1]); } static void TEST_ONE_OPTION_WITH_SPACES_2() @@ -228,7 +228,7 @@ static void TEST_ONE_OPTION_WITH_SPACES_2() TEST_INT_EQ(1, std::distance(clp.begin(), clp.end())); TEST_MS_EQ("--option1=a b c", clp[0]); - TEST_PTR_EQ(NULL, clp[1]); + TEST_PTR_NULL(clp[1]); } static void TEST_ONE_OPTION_WITH_MANY_STRING_SECTIONS() @@ -239,7 +239,7 @@ static void TEST_ONE_OPTION_WITH_MANY_STRING_SECTIONS() TEST_INT_EQ(1, std::distance(clp.begin(), clp.end())); TEST_MS_EQ("--option1=a b c", clp[0]); - TEST_PTR_EQ(NULL, clp[1]); + TEST_PTR_NULL(clp[1]); } } // anonymous namespace diff --git a/test/unit/stlsoft/conversion/string_to_integer/entry.cpp b/test/unit/stlsoft/conversion/string_to_integer/entry.cpp index c4471e1f4..11262b51a 100644 --- a/test/unit/stlsoft/conversion/string_to_integer/entry.cpp +++ b/test/unit/stlsoft/conversion/string_to_integer/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `stlsoft::string_to_integer`. * * Created: 18th November 2008 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -148,13 +148,13 @@ static void test_specialisations_1() { char const* endptr; stlsoft::string_to_integer( "0", &endptr); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_MS_EQ("0", endptr - 1); } { wchar_t const* endptr; stlsoft::string_to_integer(L"0", &endptr); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_WS_EQ(L"0", endptr - 1); } @@ -162,13 +162,13 @@ static void test_specialisations_1() { char const* endptr; stlsoft::string_to_integer( "0", 1u, &endptr); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_MS_EQ("0", endptr - 1); } { wchar_t const* endptr; stlsoft::string_to_integer(L"0", 1u, &endptr); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_WS_EQ(L"0", endptr - 1); } @@ -176,13 +176,13 @@ static void test_specialisations_1() { char const* endptr; stlsoft::string_to_integer( "0", 1, &endptr); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_MS_EQ("0", endptr - 1); } { wchar_t const* endptr; stlsoft::string_to_integer(L"0", 1, &endptr); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_WS_EQ(L"0", endptr - 1); } @@ -190,12 +190,12 @@ static void test_specialisations_1() { char const* endptr; stlsoft::string_to_integer( "0", 0, &endptr); - XTESTS_REQUIRE(TEST_PTR_EQ(NULL, endptr)); + REQUIRE(TEST_PTR_NULL(endptr)); } { wchar_t const* endptr; stlsoft::string_to_integer(L"0", 0, &endptr); - XTESTS_REQUIRE(TEST_PTR_EQ(NULL, endptr)); + REQUIRE(TEST_PTR_NULL(endptr)); } @@ -510,39 +510,39 @@ static void test_len_truncated() TEST_INT_EQ(7, stlsoft::string_to_integer("7abc", 2, &endptr)); TEST_MS_EQ("abc", endptr); TEST_INT_EQ(10, stlsoft::string_to_integer("10abc", 2, &endptr)); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_INT_EQ(11, stlsoft::string_to_integer("11abc", 2, &endptr)); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_INT_EQ(12, stlsoft::string_to_integer("123456abc", 2, &endptr)); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_INT_EQ(65, stlsoft::string_to_integer("654321abc", 2, &endptr)); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_INT_EQ(+1, stlsoft::string_to_integer("+1abc", 2, &endptr)); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_INT_EQ(+7, stlsoft::string_to_integer("+7abc", 2, &endptr)); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_INT_EQ(+1, stlsoft::string_to_integer("+10abc", 2, &endptr)); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_INT_EQ(+1, stlsoft::string_to_integer("+11abc", 2, &endptr)); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_INT_EQ(+1, stlsoft::string_to_integer("+123456abc", 2, &endptr)); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_INT_EQ(+6, stlsoft::string_to_integer("+654321abc", 2, &endptr)); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_INT_EQ(-1, stlsoft::string_to_integer("-1abc", 2, &endptr)); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_INT_EQ(-7, stlsoft::string_to_integer("-7abc", 2, &endptr)); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_INT_EQ(-1, stlsoft::string_to_integer("-10abc", 2, &endptr)); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_INT_EQ(-1, stlsoft::string_to_integer("-11abc", 2, &endptr)); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_INT_EQ(-1, stlsoft::string_to_integer("-123456abc", 2, &endptr)); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_INT_EQ(-6, stlsoft::string_to_integer("-654321abc", 2, &endptr)); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); } static void test_increasing_length() @@ -611,7 +611,7 @@ static void test_endptr() { char const* endptr; stlsoft::string_to_integer("0", 0, &endptr); - XTESTS_REQUIRE(TEST_PTR_EQ(NULL, endptr)); + REQUIRE(TEST_PTR_NULL(endptr)); } } diff --git a/test/unit/stlsoft/conversion/try_parse_to/entry.cpp b/test/unit/stlsoft/conversion/try_parse_to/entry.cpp index 78fe4af41..c3455c77f 100644 --- a/test/unit/stlsoft/conversion/try_parse_to/entry.cpp +++ b/test/unit/stlsoft/conversion/try_parse_to/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `stlsoft::try_parse_to`. * * Created: 18th November 2008 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -679,7 +679,7 @@ static void test_try_8_uint64() XTESTS_REQUIRE(TEST_BOOLEAN_FALSE(stlsoft::try_parse_to("10a", 3, "", &i, &endptr))); TEST_INT_EQ(10, i); - XTESTS_REQUIRE(TEST_PTR_NE(NULL, endptr)); + REQUIRE(TEST_PTR_NOT_NULL(endptr)); TEST_CHAR_EQ('a', *endptr); } diff --git a/test/unit/stlsoft/memory/auto_buffer.C/entry.c b/test/unit/stlsoft/memory/auto_buffer.C/entry.c index 24e5e6e75..0136f9f44 100644 --- a/test/unit/stlsoft/memory/auto_buffer.C/entry.c +++ b/test/unit/stlsoft/memory/auto_buffer.C/entry.c @@ -4,7 +4,7 @@ * Purpose: Scratch test for `STLSOFT_C_AUTO_BUFFER()`, etc. * * Created: 5th August 2011 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -183,7 +183,7 @@ static void test_value_type_of_char_internal_1(void) else { TEST_INT_EQ(8u, buff.size); - TEST_PTR_NE(NULL, buff.ptr); + TEST_PTR_NOT_NULL(buff.ptr); STLSOFT_C_AUTO_BUFFER_FREE(buff); } @@ -203,7 +203,7 @@ static void test_value_type_of_char_internal_2(void) else { TEST_INT_EQ(8u, size); - TEST_PTR_NE(NULL, ptr); + TEST_PTR_NOT_NULL(ptr); TEST_PTR_EQ(buff, ptr); stlsoft_C_auto_buffer_free(sizeof(char), &buff[0], STLSOFT_NUM_ELEMENTS(buff), size, ptr); @@ -223,7 +223,7 @@ static void test_value_type_of_char_external_1(void) else { TEST_INT_EQ(16u, size); - TEST_PTR_NE(NULL, ptr); + TEST_PTR_NOT_NULL(ptr); TEST_PTR_NE(buff, ptr); stlsoft_C_auto_buffer_free(sizeof(char), &buff[0], STLSOFT_NUM_ELEMENTS(buff), size, ptr); @@ -241,7 +241,7 @@ static void test_value_type_of_char_internal_3(void) else { TEST_INT_EQ(8u, XXXX.size); - TEST_PTR_NE(NULL, XXXX.ptr); + TEST_PTR_NOT_NULL(XXXX.ptr); STLSOFT_C_AUTO_BUFFER_FREE(XXXX); } @@ -257,7 +257,7 @@ static void test_value_type_of_char_external_2(void) else { TEST_INT_EQ(16u, buff1.size); - TEST_PTR_NE(NULL, buff1.ptr); + TEST_PTR_NOT_NULL(buff1.ptr); TEST_PTR_NE(buff1.internal_, buff1.ptr); STLSOFT_C_AUTO_BUFFER_FREE(buff1); @@ -277,7 +277,7 @@ static void test_value_type_of_char_external_then_internal_1(void) else { TEST_INT_EQ(16u, buff1.size); - TEST_PTR_NE(NULL, buff1.ptr); + TEST_PTR_NOT_NULL(buff1.ptr); TEST_PTR_NE(buff1.internal_, buff1.ptr); STLSOFT_C_AUTO_BUFFER_FREE(buff1); @@ -290,7 +290,7 @@ static void test_value_type_of_char_external_then_internal_1(void) else { TEST_INT_EQ(10u, buff2.size); - TEST_PTR_NE(NULL, buff2.ptr); + TEST_PTR_NOT_NULL(buff2.ptr); TEST_PTR_EQ(buff2.internal_, buff2.ptr); STLSOFT_C_AUTO_BUFFER_FREE(buff2); @@ -308,7 +308,7 @@ static void test_value_type_of_int_internal_1(void) else { TEST_INT_EQ(8u, buff.size); - TEST_PTR_NE(NULL, buff.ptr); + TEST_PTR_NOT_NULL(buff.ptr); STLSOFT_C_AUTO_BUFFER_FREE(buff); } @@ -324,7 +324,7 @@ static void test_value_type_of_int_external_1(void) else { TEST_INT_EQ(16u, buff1.size); - TEST_PTR_NE(NULL, buff1.ptr); + TEST_PTR_NOT_NULL(buff1.ptr); TEST_PTR_NE(buff1.internal_, buff1.ptr); STLSOFT_C_AUTO_BUFFER_FREE(buff1); diff --git a/test/unit/stlsoft/memory/malloc_allocator/entry.cpp b/test/unit/stlsoft/memory/malloc_allocator/entry.cpp index 60d6493b6..29ce4adf8 100644 --- a/test/unit/stlsoft/memory/malloc_allocator/entry.cpp +++ b/test/unit/stlsoft/memory/malloc_allocator/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `stlsoft::malloc_allocator`. * * Created: 18th October 2024 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -102,7 +102,7 @@ static void exercise_allocate(allocator_t::size_type n) allocator_t ator; allocator_t::pointer p = ator.allocate(n); - TEST_PTR_NE(NULL, p); + TEST_PTR_NOT_NULL(p); for (allocator_t::size_type i = 0; i != n; ++i) { @@ -129,7 +129,7 @@ static void test_alloc_0() allocator_t::pointer p = a1.allocate(0); - TEST_PTR_NE(NULL, p); + TEST_PTR_NOT_NULL(p); a1.deallocate(p); } diff --git a/test/unit/stlsoft/memory/new_allocator/entry.cpp b/test/unit/stlsoft/memory/new_allocator/entry.cpp index 65725c027..a66cd7ae8 100644 --- a/test/unit/stlsoft/memory/new_allocator/entry.cpp +++ b/test/unit/stlsoft/memory/new_allocator/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `stlsoft::new_allocator`. * * Created: 18th October 2024 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -102,7 +102,7 @@ static void exercise_allocate(allocator_t::size_type n) allocator_t ator; allocator_t::pointer p = ator.allocate(n); - TEST_PTR_NE(NULL, p); + TEST_PTR_NOT_NULL(p); for (allocator_t::size_type i = 0; i != n; ++i) { @@ -129,7 +129,7 @@ static void test_alloc_0() allocator_t::pointer p = a1.allocate(0); - TEST_PTR_NE(NULL, p); + TEST_PTR_NOT_NULL(p); a1.deallocate(p); } diff --git a/test/unit/stlsoft/smartptr/shared_ptr/entry.cpp b/test/unit/stlsoft/smartptr/shared_ptr/entry.cpp index d71335e74..85c0e78d5 100644 --- a/test/unit/stlsoft/smartptr/shared_ptr/entry.cpp +++ b/test/unit/stlsoft/smartptr/shared_ptr/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `stlsoft::shared_ptr`. * * Created: 7th October 2024 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -141,7 +141,7 @@ static void test_ctor_default() TEST_INT_EQ(0, ptr.count()); TEST_INT_EQ(0, ptr.use_count()); - TEST_PTR_EQ(NULL, ptr.get()); + TEST_PTR_NULL(ptr.get()); } { @@ -149,7 +149,7 @@ static void test_ctor_default() TEST_INT_EQ(0, ptr.count()); TEST_INT_EQ(0, ptr.use_count()); - TEST_PTR_EQ(NULL, ptr.get()); + TEST_PTR_NULL(ptr.get()); } { @@ -157,7 +157,7 @@ static void test_ctor_default() TEST_INT_EQ(0, ptr.count()); TEST_INT_EQ(0, ptr.use_count()); - TEST_PTR_EQ(NULL, ptr.get()); + TEST_PTR_NULL(ptr.get()); } } @@ -168,7 +168,7 @@ static void test_ctor_nullptr() TEST_INT_EQ(0, ptr.count()); TEST_INT_EQ(0, ptr.use_count()); - TEST_PTR_EQ(NULL, ptr.get()); + TEST_PTR_NULL(ptr.get()); } { @@ -176,7 +176,7 @@ static void test_ctor_nullptr() TEST_INT_EQ(0, ptr.count()); TEST_INT_EQ(0, ptr.use_count()); - TEST_PTR_EQ(NULL, ptr.get()); + TEST_PTR_NULL(ptr.get()); } { @@ -184,7 +184,7 @@ static void test_ctor_nullptr() TEST_INT_EQ(0, ptr.count()); TEST_INT_EQ(0, ptr.use_count()); - TEST_PTR_EQ(NULL, ptr.get()); + TEST_PTR_NULL(ptr.get()); } } @@ -195,7 +195,7 @@ static void test_ctor_conversion() TEST_INT_EQ(1, ptr.count()); TEST_INT_EQ(1, ptr.use_count()); - TEST_PTR_NE(NULL, ptr.get()); + TEST_PTR_NOT_NULL(ptr.get()); TEST_INT_EQ(123, *ptr); } @@ -205,7 +205,7 @@ static void test_ctor_conversion() TEST_INT_EQ(1, ptr.count()); TEST_INT_EQ(1, ptr.use_count()); - TEST_PTR_NE(NULL, ptr.get()); + TEST_PTR_NOT_NULL(ptr.get()); TEST_MS_EQ("123", *ptr); TEST_INT_EQ(3u, ptr->size()); @@ -219,7 +219,7 @@ static void test_ctor_conversion() TEST_INT_EQ(1, ptr.count()); TEST_INT_EQ(1, ptr.use_count()); - TEST_PTR_NE(NULL, ptr.get()); + TEST_PTR_NOT_NULL(ptr.get()); TEST_INT_EQ(124, ptr->i()); } @@ -235,7 +235,7 @@ static void test_ctor_copy() TEST_INT_EQ(1, ptr.count()); TEST_INT_EQ(1, ptr.use_count()); - TEST_PTR_NE(NULL, ptr.get()); + TEST_PTR_NOT_NULL(ptr.get()); TEST_INT_EQ(123, *ptr); @@ -243,13 +243,13 @@ static void test_ctor_copy() TEST_INT_EQ(2, ptr.count()); TEST_INT_EQ(2, ptr.use_count()); - TEST_PTR_NE(NULL, ptr.get()); + TEST_PTR_NOT_NULL(ptr.get()); TEST_INT_EQ(123, *ptr); TEST_INT_EQ(2, ptr2.count()); TEST_INT_EQ(2, ptr2.use_count()); - TEST_PTR_NE(NULL, ptr2.get()); + TEST_PTR_NOT_NULL(ptr2.get()); TEST_INT_EQ(123, *ptr2); } @@ -259,7 +259,7 @@ static void test_ctor_copy() TEST_INT_EQ(1, ptr.count()); TEST_INT_EQ(1, ptr.use_count()); - TEST_PTR_NE(NULL, ptr.get()); + TEST_PTR_NOT_NULL(ptr.get()); TEST_MS_EQ("123", *ptr); @@ -267,14 +267,14 @@ static void test_ctor_copy() TEST_INT_EQ(2, ptr.count()); TEST_INT_EQ(2, ptr.use_count()); - TEST_PTR_NE(NULL, ptr.get()); + TEST_PTR_NOT_NULL(ptr.get()); TEST_MS_EQ("123", *ptr); TEST_INT_EQ(3u, ptr->size()); TEST_INT_EQ(2, ptr2.count()); TEST_INT_EQ(2, ptr2.use_count()); - TEST_PTR_NE(NULL, ptr2.get()); + TEST_PTR_NOT_NULL(ptr2.get()); TEST_MS_EQ("123", *ptr2); TEST_INT_EQ(3u, ptr2->size()); @@ -288,7 +288,7 @@ static void test_ctor_copy() TEST_INT_EQ(1, ptr.count()); TEST_INT_EQ(1, ptr.use_count()); - TEST_PTR_NE(NULL, ptr.get()); + TEST_PTR_NOT_NULL(ptr.get()); TEST_INT_EQ(124, ptr->i()); @@ -297,20 +297,20 @@ static void test_ctor_copy() TEST_INT_EQ(2, ptr.count()); TEST_INT_EQ(2, ptr.use_count()); - TEST_PTR_NE(NULL, ptr.get()); + TEST_PTR_NOT_NULL(ptr.get()); TEST_INT_EQ(124, ptr->i()); TEST_INT_EQ(2, ptr2.count()); TEST_INT_EQ(2, ptr2.use_count()); - TEST_PTR_NE(NULL, ptr2.get()); + TEST_PTR_NOT_NULL(ptr2.get()); TEST_INT_EQ(124, ptr2->i()); } TEST_INT_EQ(1, ptr.count()); TEST_INT_EQ(1, ptr.use_count()); - TEST_PTR_NE(NULL, ptr.get()); + TEST_PTR_NOT_NULL(ptr.get()); TEST_INT_EQ(124, ptr->i()); } @@ -328,7 +328,7 @@ static void test_ctor_move() TEST_INT_EQ(1, ptr.count()); TEST_INT_EQ(1, ptr.use_count()); - TEST_PTR_NE(NULL, ptr.get()); + TEST_PTR_NOT_NULL(ptr.get()); TEST_INT_EQ(123, *ptr); @@ -336,11 +336,11 @@ static void test_ctor_move() TEST_INT_EQ(0, ptr.count()); TEST_INT_EQ(0, ptr.use_count()); - TEST_PTR_EQ(NULL, ptr.get()); + TEST_PTR_NULL(ptr.get()); TEST_INT_EQ(1, ptr2.count()); TEST_INT_EQ(1, ptr2.use_count()); - TEST_PTR_NE(NULL, ptr2.get()); + TEST_PTR_NOT_NULL(ptr2.get()); TEST_INT_EQ(123, *ptr2); } @@ -350,7 +350,7 @@ static void test_ctor_move() TEST_INT_EQ(1, ptr.count()); TEST_INT_EQ(1, ptr.use_count()); - TEST_PTR_NE(NULL, ptr.get()); + TEST_PTR_NOT_NULL(ptr.get()); TEST_MS_EQ("123", *ptr); @@ -358,11 +358,11 @@ static void test_ctor_move() TEST_INT_EQ(0, ptr.count()); TEST_INT_EQ(0, ptr.use_count()); - TEST_PTR_EQ(NULL, ptr.get()); + TEST_PTR_NULL(ptr.get()); TEST_INT_EQ(1, ptr2.count()); TEST_INT_EQ(1, ptr2.use_count()); - TEST_PTR_NE(NULL, ptr2.get()); + TEST_PTR_NOT_NULL(ptr2.get()); TEST_MS_EQ("123", *ptr2); TEST_INT_EQ(3u, ptr2->size()); @@ -376,7 +376,7 @@ static void test_ctor_move() TEST_INT_EQ(1, ptr.count()); TEST_INT_EQ(1, ptr.use_count()); - TEST_PTR_NE(NULL, ptr.get()); + TEST_PTR_NOT_NULL(ptr.get()); TEST_INT_EQ(124, ptr->i()); @@ -385,18 +385,18 @@ static void test_ctor_move() TEST_INT_EQ(0, ptr.count()); TEST_INT_EQ(0, ptr.use_count()); - TEST_PTR_EQ(NULL, ptr.get()); + TEST_PTR_NULL(ptr.get()); TEST_INT_EQ(1, ptr2.count()); TEST_INT_EQ(1, ptr2.use_count()); - TEST_PTR_NE(NULL, ptr2.get()); + TEST_PTR_NOT_NULL(ptr2.get()); TEST_INT_EQ(124, ptr2->i()); } TEST_INT_EQ(0, ptr.count()); TEST_INT_EQ(0, ptr.use_count()); - TEST_PTR_EQ(NULL, ptr.get()); + TEST_PTR_NULL(ptr.get()); } TEST_INT_EQ(123, i); @@ -411,7 +411,7 @@ static void test_swap() TEST_INT_EQ(1, ptr.count()); TEST_INT_EQ(1, ptr.use_count()); - TEST_PTR_NE(NULL, ptr.get()); + TEST_PTR_NOT_NULL(ptr.get()); TEST_INT_EQ(123, *ptr); @@ -421,11 +421,11 @@ static void test_swap() TEST_INT_EQ(0, ptr.count()); TEST_INT_EQ(0, ptr.use_count()); - TEST_PTR_EQ(NULL, ptr.get()); + TEST_PTR_NULL(ptr.get()); TEST_INT_EQ(1, ptr2.count()); TEST_INT_EQ(1, ptr2.use_count()); - TEST_PTR_NE(NULL, ptr2.get()); + TEST_PTR_NOT_NULL(ptr2.get()); TEST_INT_EQ(123, *ptr2); } @@ -435,7 +435,7 @@ static void test_swap() TEST_INT_EQ(1, ptr.count()); TEST_INT_EQ(1, ptr.use_count()); - TEST_PTR_NE(NULL, ptr.get()); + TEST_PTR_NOT_NULL(ptr.get()); TEST_MS_EQ("123", *ptr); @@ -445,11 +445,11 @@ static void test_swap() TEST_INT_EQ(0, ptr.count()); TEST_INT_EQ(0, ptr.use_count()); - TEST_PTR_EQ(NULL, ptr.get()); + TEST_PTR_NULL(ptr.get()); TEST_INT_EQ(1, ptr2.count()); TEST_INT_EQ(1, ptr2.use_count()); - TEST_PTR_NE(NULL, ptr2.get()); + TEST_PTR_NOT_NULL(ptr2.get()); TEST_MS_EQ("123", *ptr2); TEST_INT_EQ(3u, ptr2->size()); @@ -463,7 +463,7 @@ static void test_swap() TEST_INT_EQ(1, ptr.count()); TEST_INT_EQ(1, ptr.use_count()); - TEST_PTR_NE(NULL, ptr.get()); + TEST_PTR_NOT_NULL(ptr.get()); TEST_INT_EQ(124, ptr->i()); @@ -474,18 +474,18 @@ static void test_swap() TEST_INT_EQ(0, ptr.count()); TEST_INT_EQ(0, ptr.use_count()); - TEST_PTR_EQ(NULL, ptr.get()); + TEST_PTR_NULL(ptr.get()); TEST_INT_EQ(1, ptr2.count()); TEST_INT_EQ(1, ptr2.use_count()); - TEST_PTR_NE(NULL, ptr2.get()); + TEST_PTR_NOT_NULL(ptr2.get()); TEST_INT_EQ(124, ptr2->i()); } TEST_INT_EQ(0, ptr.count()); TEST_INT_EQ(0, ptr.use_count()); - TEST_PTR_EQ(NULL, ptr.get()); + TEST_PTR_NULL(ptr.get()); } TEST_INT_EQ(123, i); @@ -499,7 +499,7 @@ static void test_std_swap() TEST_INT_EQ(1, ptr.count()); TEST_INT_EQ(1, ptr.use_count()); - TEST_PTR_NE(NULL, ptr.get()); + TEST_PTR_NOT_NULL(ptr.get()); TEST_INT_EQ(123, *ptr); @@ -509,11 +509,11 @@ static void test_std_swap() TEST_INT_EQ(0, ptr.count()); TEST_INT_EQ(0, ptr.use_count()); - TEST_PTR_EQ(NULL, ptr.get()); + TEST_PTR_NULL(ptr.get()); TEST_INT_EQ(1, ptr2.count()); TEST_INT_EQ(1, ptr2.use_count()); - TEST_PTR_NE(NULL, ptr2.get()); + TEST_PTR_NOT_NULL(ptr2.get()); TEST_INT_EQ(123, *ptr2); } @@ -523,7 +523,7 @@ static void test_std_swap() TEST_INT_EQ(1, ptr.count()); TEST_INT_EQ(1, ptr.use_count()); - TEST_PTR_NE(NULL, ptr.get()); + TEST_PTR_NOT_NULL(ptr.get()); TEST_MS_EQ("123", *ptr); @@ -533,11 +533,11 @@ static void test_std_swap() TEST_INT_EQ(0, ptr.count()); TEST_INT_EQ(0, ptr.use_count()); - TEST_PTR_EQ(NULL, ptr.get()); + TEST_PTR_NULL(ptr.get()); TEST_INT_EQ(1, ptr2.count()); TEST_INT_EQ(1, ptr2.use_count()); - TEST_PTR_NE(NULL, ptr2.get()); + TEST_PTR_NOT_NULL(ptr2.get()); TEST_MS_EQ("123", *ptr2); TEST_INT_EQ(3u, ptr2->size()); diff --git a/test/unit/stlsoft/string/shim_string/entry.cpp b/test/unit/stlsoft/string/shim_string/entry.cpp index b294c610a..96164943d 100644 --- a/test/unit/stlsoft/string/shim_string/entry.cpp +++ b/test/unit/stlsoft/string/shim_string/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `stlsoft::basic_shim_string`. * * Created: 9th November 2008 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -191,7 +191,7 @@ static void test_construction() TEST_INT_EQ(0u, str0.size()); TEST_INT_EQ(0u, static_cast(str0)); TEST_INT_NE(0u, str0.internal_size()); - TEST_PTR_NE(NULL, str0); + TEST_PTR_NOT_NULL(str0); TEST_MS_EQ("", str0); TEST_MS_EQ("", str0.data()); @@ -201,7 +201,7 @@ static void test_construction() TEST_INT_EQ(0u, str1.size()); TEST_INT_EQ(0u, static_cast(str1)); TEST_INT_NE(0u, str1.internal_size()); - TEST_PTR_NE(NULL, str1); + TEST_PTR_NOT_NULL(str1); TEST_MS_EQ("", str1); TEST_MS_EQ("", str1.data()); @@ -211,7 +211,7 @@ static void test_construction() TEST_INT_EQ(0u, str2.size()); TEST_INT_EQ(0u, static_cast(str2)); TEST_INT_NE(0u, str2.internal_size()); - TEST_PTR_NE(NULL, str2); + TEST_PTR_NOT_NULL(str2); TEST_MS_EQ("", str2); TEST_MS_EQ("", str2.data()); @@ -221,7 +221,7 @@ static void test_construction() TEST_INT_EQ(0u, str3.size()); TEST_INT_EQ(0u, static_cast(str3)); TEST_INT_NE(0u, str3.internal_size()); - TEST_PTR_NE(NULL, str3); + TEST_PTR_NOT_NULL(str3); TEST_MS_EQ("", str3); TEST_MS_EQ("", str3.data()); @@ -231,7 +231,7 @@ static void test_construction() TEST_INT_EQ(0u, str4.size()); TEST_INT_EQ(0u, static_cast(str4)); TEST_INT_NE(0u, str4.internal_size()); - TEST_PTR_NE(NULL, str4); + TEST_PTR_NOT_NULL(str4); TEST_MS_EQ("", str4); TEST_MS_EQ("", str4.data()); @@ -241,7 +241,7 @@ static void test_construction() TEST_INT_EQ(0u, str5.size()); TEST_INT_EQ(0u, static_cast(str5)); TEST_INT_NE(0u, str5.internal_size()); - TEST_PTR_NE(NULL, str5); + TEST_PTR_NOT_NULL(str5); TEST_MS_EQ("", str5); TEST_MS_EQ("", str5.data()); } @@ -265,7 +265,7 @@ static void test_constructor_length() TEST_BOOLEAN_FALSE(str.empty()); TEST_INT_EQ(5u, str.size()); TEST_INT_EQ(5u, static_cast(str)); - TEST_PTR_NE(NULL, str); + TEST_PTR_NOT_NULL(str); TEST_MS_EQ("", str); TEST_MS_EQ("", str.data()); } @@ -277,7 +277,7 @@ static void test_constructor_c_string() TEST_BOOLEAN_FALSE(str.empty()); TEST_INT_EQ(1u, str.size()); TEST_INT_EQ(1u, static_cast(str)); - TEST_PTR_NE(NULL, str); + TEST_PTR_NOT_NULL(str); TEST_MS_EQ("a", str); TEST_MS_EQ("a", str.data()); } @@ -289,7 +289,7 @@ static void test_constructor_range_string() TEST_BOOLEAN_FALSE(str.empty()); TEST_INT_EQ(3u, str.size()); TEST_INT_EQ(3u, static_cast(str)); - TEST_PTR_NE(NULL, str); + TEST_PTR_NOT_NULL(str); TEST_MS_EQ("abc", str); TEST_MS_EQ("abc", str.data()); } @@ -303,7 +303,7 @@ static void test_write() TEST_BOOLEAN_FALSE(str.empty()); TEST_INT_EQ(3u, str.size()); TEST_INT_EQ(3u, static_cast(str)); - TEST_PTR_NE(NULL, str); + TEST_PTR_NOT_NULL(str); TEST_MS_EQ("abc", str); TEST_MS_EQ("abc", str.data()); } @@ -431,7 +431,7 @@ static void test_null_string() TEST_INT_EQ(0u, s.size()); TEST_INT_EQ(0u, static_cast(s)); TEST_INT_EQ(0u, s.size()); - TEST_PTR_EQ(NULL, s); + TEST_PTR_NULL(s); TEST_INT_EQ(0u, static_cast(s)); } } diff --git a/test/unit/stlsoft/string/simple_string/entry.cpp b/test/unit/stlsoft/string/simple_string/entry.cpp index bd1c22eb3..2e3901232 100644 --- a/test/unit/stlsoft/string/simple_string/entry.cpp +++ b/test/unit/stlsoft/string/simple_string/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `stlsoft::basic_simple_string`. * * Created: 4th November 2008 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -4151,21 +4151,21 @@ static void test_string_access_shims() TEST_INT_EQ(0u, stlsoft::c_str_len_a(s)); TEST_INT_EQ(0u, stlsoft::c_str_len(s)); - TEST_PTR_NE(NULL, stlsoft::c_str_data_a(s)); + TEST_PTR_NOT_NULL(stlsoft::c_str_data_a(s)); TEST_MS_EQ("", stlsoft::c_str_data_a(s)); - TEST_PTR_NE(NULL, stlsoft::c_str_data(s)); + TEST_PTR_NOT_NULL(stlsoft::c_str_data(s)); TEST_MS_EQ("", stlsoft::c_str_data(s)); - TEST_PTR_NE(NULL, stlsoft::c_str_ptr_a(s)); + TEST_PTR_NOT_NULL(stlsoft::c_str_ptr_a(s)); TEST_MS_EQ("", stlsoft::c_str_ptr_a(s)); - TEST_PTR_NE(NULL, stlsoft::c_str_ptr(s)); + TEST_PTR_NOT_NULL(stlsoft::c_str_ptr(s)); TEST_MS_EQ("", stlsoft::c_str_ptr(s)); - TEST_PTR_EQ(NULL, stlsoft::c_str_ptr_null_a(s)); + TEST_PTR_NULL(stlsoft::c_str_ptr_null_a(s)); - TEST_PTR_EQ(NULL, stlsoft::c_str_ptr_null(s)); + TEST_PTR_NULL(stlsoft::c_str_ptr_null(s)); } { @@ -4174,21 +4174,21 @@ static void test_string_access_shims() TEST_INT_EQ(0u, stlsoft::c_str_len_w(s)); // TEST_INT_EQ(0u, stlsoft::c_str_len(s)); - TEST_PTR_NE(NULL, stlsoft::c_str_data_w(s)); + TEST_PTR_NOT_NULL(stlsoft::c_str_data_w(s)); TEST_WS_EQ(L"", stlsoft::c_str_data_w(s)); -// TEST_PTR_NE(NULL, stlsoft::c_str_data(s)); +// TEST_PTR_NOT_NULL(stlsoft::c_str_data(s)); // TEST_WS_EQ(L"", stlsoft::c_str_data(s)); - TEST_PTR_NE(NULL, stlsoft::c_str_ptr_w(s)); + TEST_PTR_NOT_NULL(stlsoft::c_str_ptr_w(s)); TEST_WS_EQ(L"", stlsoft::c_str_ptr_w(s)); -// TEST_PTR_NE(NULL, stlsoft::c_str_ptr(s)); +// TEST_PTR_NOT_NULL(stlsoft::c_str_ptr(s)); // TEST_WS_EQ(L"", stlsoft::c_str_ptr(s)); - TEST_PTR_EQ(NULL, stlsoft::c_str_ptr_null_w(s)); + TEST_PTR_NULL(stlsoft::c_str_ptr_null_w(s)); -// TEST_PTR_EQ(NULL, stlsoft::c_str_ptr_null(s)); +// TEST_PTR_NULL(stlsoft::c_str_ptr_null(s)); } } diff --git a/test/unit/stlsoft/string/static_string/entry.cpp b/test/unit/stlsoft/string/static_string/entry.cpp index 45ab3632c..c1764c0ee 100644 --- a/test/unit/stlsoft/string/static_string/entry.cpp +++ b/test/unit/stlsoft/string/static_string/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `stlsoft::basic_static_string`. * * Created: 4th November 2008 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -2435,21 +2435,21 @@ static void test_string_access_shims() TEST_INT_EQ(0u, stlsoft::c_str_len_a(s)); TEST_INT_EQ(0u, stlsoft::c_str_len(s)); - TEST_PTR_NE(NULL, stlsoft::c_str_data_a(s)); + TEST_PTR_NOT_NULL(stlsoft::c_str_data_a(s)); TEST_MS_EQ("", stlsoft::c_str_data_a(s)); - TEST_PTR_NE(NULL, stlsoft::c_str_data(s)); + TEST_PTR_NOT_NULL(stlsoft::c_str_data(s)); TEST_MS_EQ("", stlsoft::c_str_data(s)); - TEST_PTR_NE(NULL, stlsoft::c_str_ptr_a(s)); + TEST_PTR_NOT_NULL(stlsoft::c_str_ptr_a(s)); TEST_MS_EQ("", stlsoft::c_str_ptr_a(s)); - TEST_PTR_NE(NULL, stlsoft::c_str_ptr(s)); + TEST_PTR_NOT_NULL(stlsoft::c_str_ptr(s)); TEST_MS_EQ("", stlsoft::c_str_ptr(s)); - TEST_PTR_EQ(NULL, stlsoft::c_str_ptr_null_a(s)); + TEST_PTR_NULL(stlsoft::c_str_ptr_null_a(s)); - TEST_PTR_EQ(NULL, stlsoft::c_str_ptr_null(s)); + TEST_PTR_NULL(stlsoft::c_str_ptr_null(s)); } { @@ -2458,21 +2458,21 @@ static void test_string_access_shims() TEST_INT_EQ(0u, stlsoft::c_str_len_w(s)); // TEST_INT_EQ(0u, stlsoft::c_str_len(s)); - TEST_PTR_NE(NULL, stlsoft::c_str_data_w(s)); + TEST_PTR_NOT_NULL(stlsoft::c_str_data_w(s)); TEST_WS_EQ(L"", stlsoft::c_str_data_w(s)); -// TEST_PTR_NE(NULL, stlsoft::c_str_data(s)); +// TEST_PTR_NOT_NULL(stlsoft::c_str_data(s)); // TEST_WS_EQ(L"", stlsoft::c_str_data(s)); - TEST_PTR_NE(NULL, stlsoft::c_str_ptr_w(s)); + TEST_PTR_NOT_NULL(stlsoft::c_str_ptr_w(s)); TEST_WS_EQ(L"", stlsoft::c_str_ptr_w(s)); -// TEST_PTR_NE(NULL, stlsoft::c_str_ptr(s)); +// TEST_PTR_NOT_NULL(stlsoft::c_str_ptr(s)); // TEST_WS_EQ(L"", stlsoft::c_str_ptr(s)); - TEST_PTR_EQ(NULL, stlsoft::c_str_ptr_null_w(s)); + TEST_PTR_NULL(stlsoft::c_str_ptr_null_w(s)); -// TEST_PTR_EQ(NULL, stlsoft::c_str_ptr_null(s)); +// TEST_PTR_NULL(stlsoft::c_str_ptr_null(s)); } } } // anonymous namespace diff --git a/test/unit/stlsoft/string/string_slice/entry.cpp b/test/unit/stlsoft/string/string_slice/entry.cpp index 2560d6978..66ec60a09 100644 --- a/test/unit/stlsoft/string/string_slice/entry.cpp +++ b/test/unit/stlsoft/string/string_slice/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `stlsoft::basic_string_slice`. * * Created: 19th February 2010 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -187,29 +187,29 @@ static void test_constructed_state() stlsoft::string_slice slice_w; TEST_INT_EQ(0u, slice.len); - TEST_PTR_EQ(NULL, slice.ptr); + TEST_PTR_NULL(slice.ptr); TEST_INT_EQ(0u, slice_w.len); - TEST_PTR_EQ(NULL, slice_w.ptr); + TEST_PTR_NULL(slice_w.ptr); TEST_INT_EQ(0u, ::stlsoft::c_str_len_a(slice)); - TEST_PTR_NE(NULL, ::stlsoft::c_str_data_a(slice)); + TEST_PTR_NOT_NULL(::stlsoft::c_str_data_a(slice)); TEST_INT_EQ(0u, ::stlsoft::c_str_len_w(slice_w)); - TEST_PTR_NE(NULL, ::stlsoft::c_str_data_w(slice_w)); + TEST_PTR_NOT_NULL(::stlsoft::c_str_data_w(slice_w)); TEST_INT_EQ(0u, ::stlsoft::c_str_len(slice)); - TEST_PTR_NE(NULL, ::stlsoft::c_str_data(slice)); + TEST_PTR_NOT_NULL(::stlsoft::c_str_data(slice)); TEST_INT_EQ(0u, ::stlsoft::c_str_len(slice_w)); - TEST_PTR_NE(NULL, ::stlsoft::c_str_data(slice_w)); + TEST_PTR_NOT_NULL(::stlsoft::c_str_data(slice_w)); TEST_INT_EQ(0u, ::stlsoft::c_str_len_a(&slice)); - TEST_PTR_NE(NULL, ::stlsoft::c_str_data_a(&slice)); + TEST_PTR_NOT_NULL(::stlsoft::c_str_data_a(&slice)); TEST_INT_EQ(0u, ::stlsoft::c_str_len_w(&slice_w)); - TEST_PTR_NE(NULL, ::stlsoft::c_str_data_w(&slice_w)); + TEST_PTR_NOT_NULL(::stlsoft::c_str_data_w(&slice_w)); TEST_INT_EQ(0u, ::stlsoft::c_str_len(&slice)); - TEST_PTR_NE(NULL, ::stlsoft::c_str_data(&slice)); + TEST_PTR_NOT_NULL(::stlsoft::c_str_data(&slice)); TEST_INT_EQ(0u, ::stlsoft::c_str_len(&slice_w)); - TEST_PTR_NE(NULL, ::stlsoft::c_str_data(&slice_w)); + TEST_PTR_NOT_NULL(::stlsoft::c_str_data(&slice_w)); } static void test_constructed_subslice_1() @@ -338,9 +338,9 @@ static void test_string_access_shims_multibyte_3() wchar_t const* ptr_w = stlsoft::c_str_data_w(slice_w); TEST_INT_EQ(0u, len); - TEST_PTR_NE(NULL, ptr); + TEST_PTR_NOT_NULL(ptr); TEST_INT_EQ(0u, len_w); - TEST_PTR_NE(NULL, ptr_w); + TEST_PTR_NOT_NULL(ptr_w); } static void test_equality_operator_1() diff --git a/test/unit/stlsoft/string/string_view/entry.cpp b/test/unit/stlsoft/string/string_view/entry.cpp index 0f731cb50..14b96aba2 100644 --- a/test/unit/stlsoft/string/string_view/entry.cpp +++ b/test/unit/stlsoft/string/string_view/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `stlsoft::basic_string_view`. * * Created: 4th November 2008 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -936,23 +936,23 @@ static void test_string_access_shims() TEST_INT_EQ(0u, stlsoft::c_str_len_a(s)); TEST_INT_EQ(0u, stlsoft::c_str_len(s)); - TEST_PTR_NE(NULL, stlsoft::c_str_data_a(s)); + TEST_PTR_NOT_NULL(stlsoft::c_str_data_a(s)); TEST_MS_EQ("", stlsoft::c_str_data_a(s)); - TEST_PTR_NE(NULL, stlsoft::c_str_data(s)); + TEST_PTR_NOT_NULL(stlsoft::c_str_data(s)); TEST_MS_EQ("", stlsoft::c_str_data(s)); #ifdef HAS_c_str_ - TEST_PTR_NE(NULL, stlsoft::c_str_ptr_a(s)); + TEST_PTR_NOT_NULL(stlsoft::c_str_ptr_a(s)); TEST_MS_EQ("", stlsoft::c_str_ptr_a(s)); - TEST_PTR_NE(NULL, stlsoft::c_str_ptr(s)); + TEST_PTR_NOT_NULL(stlsoft::c_str_ptr(s)); TEST_MS_EQ("", stlsoft::c_str_ptr(s)); - TEST_PTR_EQ(NULL, stlsoft::c_str_ptr_null_a(s)); + TEST_PTR_NULL(stlsoft::c_str_ptr_null_a(s)); - TEST_PTR_EQ(NULL, stlsoft::c_str_ptr_null(s)); + TEST_PTR_NULL(stlsoft::c_str_ptr_null(s)); #endif /* HAS_c_str_ */ } @@ -962,23 +962,23 @@ static void test_string_access_shims() TEST_INT_EQ(0u, stlsoft::c_str_len_w(s)); // TEST_INT_EQ(0u, stlsoft::c_str_len(s)); - TEST_PTR_NE(NULL, stlsoft::c_str_data_w(s)); + TEST_PTR_NOT_NULL(stlsoft::c_str_data_w(s)); TEST_WS_EQ(L"", stlsoft::c_str_data_w(s)); -// TEST_PTR_NE(NULL, stlsoft::c_str_data(s)); +// TEST_PTR_NOT_NULL(stlsoft::c_str_data(s)); // TEST_WS_EQ(L"", stlsoft::c_str_data(s)); #ifdef HAS_c_str_ - TEST_PTR_NE(NULL, stlsoft::c_str_ptr_w(s)); + TEST_PTR_NOT_NULL(stlsoft::c_str_ptr_w(s)); TEST_WS_EQ(L"", stlsoft::c_str_ptr_w(s)); -// TEST_PTR_NE(NULL, stlsoft::c_str_ptr(s)); +// TEST_PTR_NOT_NULL(stlsoft::c_str_ptr(s)); // TEST_WS_EQ(L"", stlsoft::c_str_ptr(s)); - TEST_PTR_EQ(NULL, stlsoft::c_str_ptr_null_w(s)); + TEST_PTR_NULL(stlsoft::c_str_ptr_null_w(s)); -// TEST_PTR_EQ(NULL, stlsoft::c_str_ptr_null(s)); +// TEST_PTR_NULL(stlsoft::c_str_ptr_null(s)); #endif /* HAS_c_str_ */ } diff --git a/test/unit/unixstl/filesystem/filesystem_traits/entry.cpp b/test/unit/unixstl/filesystem/filesystem_traits/entry.cpp index 9d1eca885..078c0517a 100644 --- a/test/unit/unixstl/filesystem/filesystem_traits/entry.cpp +++ b/test/unit/unixstl/filesystem/filesystem_traits/entry.cpp @@ -7,7 +7,7 @@ * and wide path classification / separator finders. * * Created: 15th October 2026 - * Updated: 19th October 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -349,8 +349,8 @@ static void TEST_find_path_name_separators_w() wchar_t const* const last = traits_w_t::find_last_path_name_separator(path); wchar_t const* const next = traits_w_t::find_next_path_name_separator(path); - TEST_PTR_NE(NULL, last); - TEST_PTR_NE(NULL, next); + TEST_PTR_NOT_NULL(last); + TEST_PTR_NOT_NULL(next); TEST_PTR_EQ(path + 0, next); TEST_PTR_EQ(path + 10, last); TEST_PTR_EQ(last, traits_w_t::find_last_path_name_separator(path, ::wcslen(path))); @@ -360,10 +360,10 @@ static void TEST_find_path_name_separators_w() { wchar_t const* const path = L"relative"; - TEST_PTR_EQ(NULL, traits_w_t::find_last_path_name_separator(path)); - TEST_PTR_EQ(NULL, traits_w_t::find_next_path_name_separator(path)); - TEST_PTR_EQ(NULL, traits_w_t::find_last_path_name_separator(path, 0)); - TEST_PTR_EQ(NULL, traits_w_t::find_next_path_name_separator(path, 0)); + TEST_PTR_NULL(traits_w_t::find_last_path_name_separator(path)); + TEST_PTR_NULL(traits_w_t::find_next_path_name_separator(path)); + TEST_PTR_NULL(traits_w_t::find_last_path_name_separator(path, 0)); + TEST_PTR_NULL(traits_w_t::find_next_path_name_separator(path, 0)); } } diff --git a/test/unit/unixstl/filesystem/path/entry.cpp b/test/unit/unixstl/filesystem/path/entry.cpp index 375386d7d..63b4fad80 100644 --- a/test/unit/unixstl/filesystem/path/entry.cpp +++ b/test/unit/unixstl/filesystem/path/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `unixstl::basic_path`. * * Created: 16th February 2024 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -219,10 +219,10 @@ static void test_construct_filename() TEST(p1.end() == p1.begin()); TEST(p1.rend() == p1.rbegin()); #endif - TEST_PTR_NE(ss_nullptr_k, p1.c_str()); + TEST_PTR_NOT_NULL(p1.c_str()); TEST('\0' != *p1.c_str()); TEST(0 == ::strcmp("file.ext", p1.c_str())); - TEST_PTR_NE(ss_nullptr_k, p1.data()); + TEST_PTR_NOT_NULL(p1.data()); TEST('\0' != *p1.data()); buffer[0] = '~'; @@ -232,8 +232,8 @@ static void test_construct_filename() TEST_MS_EQ("file.ext", stlsoft::sas_to_string(p1)); TEST_MS_EQ("file.ext", stlsoft::sas_to_string_m(p1)); - TEST_PTR_NE(ss_nullptr_k, stlsoft::c_str_ptr_null(buffer)); - TEST_PTR_NE(ss_nullptr_k, stlsoft::c_str_ptr_null_a(buffer)); + TEST_PTR_NOT_NULL(stlsoft::c_str_ptr_null(buffer)); + TEST_PTR_NOT_NULL(stlsoft::c_str_ptr_null_a(buffer)); TEST(0 == p1.get_location().len); TEST("file.ext" == p1.get_file()); @@ -332,10 +332,10 @@ static void test_construct_relative_directory_and_file() TEST(p1.end() == p1.begin()); TEST(p1.rend() == p1.rbegin()); #endif - TEST_PTR_NE(ss_nullptr_k, p1.c_str()); + TEST_PTR_NOT_NULL(p1.c_str()); TEST('\0' != *p1.c_str()); TEST(0 == ::strcmp("dir-1/file.ext", p1.c_str())); - TEST_PTR_NE(ss_nullptr_k, p1.data()); + TEST_PTR_NOT_NULL(p1.data()); TEST('\0' != *p1.data()); buffer[0] = '~'; @@ -347,8 +347,8 @@ static void test_construct_relative_directory_and_file() TEST(14 == stlsoft::c_str_len_a(p1)); TEST(0 == ::strcmp("dir-1/file.ext", stlsoft::c_str_ptr(buffer))); TEST(0 == ::strcmp("dir-1/file.ext", stlsoft::c_str_ptr_a(buffer))); - TEST_PTR_NE(ss_nullptr_k, stlsoft::c_str_ptr_null(buffer)); - TEST_PTR_NE(ss_nullptr_k, stlsoft::c_str_ptr_null_a(buffer)); + TEST_PTR_NOT_NULL(stlsoft::c_str_ptr_null(buffer)); + TEST_PTR_NOT_NULL(stlsoft::c_str_ptr_null_a(buffer)); TEST("dir-1/" == p1.get_location()); TEST("file.ext" == p1.get_file()); diff --git a/test/unit/versions/entry.cpp b/test/unit/versions/entry.cpp index e9d428540..3702a03d9 100644 --- a/test/unit/versions/entry.cpp +++ b/test/unit/versions/entry.cpp @@ -133,7 +133,7 @@ namespace { static void TEST__STLSOFT_VER() { - TEST_INT_EQ(_STLSOFT_VER_1_11_1, _STLSOFT_VER); + TEST_INT_EQ(_STLSOFT_VER_1_11_2_A1, _STLSOFT_VER); } #ifdef STLSOFT_HAS_ACE diff --git a/test/unit/winstl/filesystem/filesystem_traits/entry.cpp b/test/unit/winstl/filesystem/filesystem_traits/entry.cpp index 7441049ee..0d19426d1 100644 --- a/test/unit/winstl/filesystem/filesystem_traits/entry.cpp +++ b/test/unit/winstl/filesystem/filesystem_traits/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `winstl::filesystem_traits`. * * Created: 31st December 2008 - * Updated: 19th October 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -1259,9 +1259,9 @@ static void TEST_path_is_absolute_2() static void TEST_find_last_path_name_separator() { { - TEST_PTR_EQ(NULL, filesystem_traits_m_t::find_last_path_name_separator("")); - TEST_PTR_EQ(NULL, filesystem_traits_m_t::find_last_path_name_separator("abc")); - TEST_PTR_EQ(NULL, filesystem_traits_m_t::find_last_path_name_separator("abc_")); + TEST_PTR_NULL(filesystem_traits_m_t::find_last_path_name_separator("")); + TEST_PTR_NULL(filesystem_traits_m_t::find_last_path_name_separator("abc")); + TEST_PTR_NULL(filesystem_traits_m_t::find_last_path_name_separator("abc_")); { char const input[] = "\\"; @@ -1325,9 +1325,9 @@ static void TEST_find_last_path_name_separator() } { - TEST_PTR_EQ(NULL, filesystem_traits_w_t::find_last_path_name_separator(L"")); - TEST_PTR_EQ(NULL, filesystem_traits_w_t::find_last_path_name_separator(L"abc")); - TEST_PTR_EQ(NULL, filesystem_traits_w_t::find_last_path_name_separator(L"abc_")); + TEST_PTR_NULL(filesystem_traits_w_t::find_last_path_name_separator(L"")); + TEST_PTR_NULL(filesystem_traits_w_t::find_last_path_name_separator(L"abc")); + TEST_PTR_NULL(filesystem_traits_w_t::find_last_path_name_separator(L"abc_")); { wchar_t const input[] = L"\\"; @@ -1394,9 +1394,9 @@ static void TEST_find_last_path_name_separator() static void TEST_find_next_path_name_separator() { { - TEST_PTR_EQ(NULL, filesystem_traits_m_t::find_next_path_name_separator("")); - TEST_PTR_EQ(NULL, filesystem_traits_m_t::find_next_path_name_separator("abc")); - TEST_PTR_EQ(NULL, filesystem_traits_m_t::find_next_path_name_separator("abc_")); + TEST_PTR_NULL(filesystem_traits_m_t::find_next_path_name_separator("")); + TEST_PTR_NULL(filesystem_traits_m_t::find_next_path_name_separator("abc")); + TEST_PTR_NULL(filesystem_traits_m_t::find_next_path_name_separator("abc_")); { char const input[] = "\\"; @@ -1460,9 +1460,9 @@ static void TEST_find_next_path_name_separator() } { - TEST_PTR_EQ(NULL, filesystem_traits_w_t::find_next_path_name_separator(L"")); - TEST_PTR_EQ(NULL, filesystem_traits_w_t::find_next_path_name_separator(L"abc")); - TEST_PTR_EQ(NULL, filesystem_traits_w_t::find_next_path_name_separator(L"abc_")); + TEST_PTR_NULL(filesystem_traits_w_t::find_next_path_name_separator(L"")); + TEST_PTR_NULL(filesystem_traits_w_t::find_next_path_name_separator(L"abc")); + TEST_PTR_NULL(filesystem_traits_w_t::find_next_path_name_separator(L"abc_")); { wchar_t const input[] = L"\\"; @@ -1839,14 +1839,14 @@ static void TEST_patterns_all() auto const pa = filesystem_traits_m_t::patterns_all(); TEST_MS_EQ("*.*", pa[0]); - TEST_PTR_EQ(NULL, pa[1]); + TEST_PTR_NULL(pa[1]); } { auto const pa = filesystem_traits_w_t::patterns_all(); TEST_WS_EQ(L"*.*", pa[0]); - TEST_PTR_EQ(NULL, pa[1]); + TEST_PTR_NULL(pa[1]); } } @@ -1857,7 +1857,7 @@ static void TEST_patterns_all() TEST_INT_EQ(1, n); TEST_MS_EQ("*.*", pa[0]); - TEST_PTR_EQ(NULL, pa[1]); + TEST_PTR_NULL(pa[1]); } { @@ -1866,7 +1866,7 @@ static void TEST_patterns_all() TEST_INT_EQ(1, n); TEST_WS_EQ(L"*.*", pa[0]); - TEST_PTR_EQ(NULL, pa[1]); + TEST_PTR_NULL(pa[1]); } } } diff --git a/test/unit/winstl/memory/global_allocator/entry.cpp b/test/unit/winstl/memory/global_allocator/entry.cpp index 3a00b35bb..539139d04 100644 --- a/test/unit/winstl/memory/global_allocator/entry.cpp +++ b/test/unit/winstl/memory/global_allocator/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `winstl::global_allocator`. * * Created: 18th October 2024 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -102,7 +102,7 @@ static void exercise_allocate(allocator_t::size_type n) allocator_t ator; allocator_t::pointer p = ator.allocate(n); - TEST_PTR_NE(NULL, p); + TEST_PTR_NOT_NULL(p); for (allocator_t::size_type i = 0; i != n; ++i) { @@ -129,7 +129,7 @@ static void test_alloc_0() allocator_t::pointer p = a1.allocate(0); - TEST_PTR_NE(NULL, p); + TEST_PTR_NOT_NULL(p); a1.deallocate(p); } diff --git a/test/unit/winstl/memory/netapi_allocator/entry.cpp b/test/unit/winstl/memory/netapi_allocator/entry.cpp index 94fb1acec..ab2367ac2 100644 --- a/test/unit/winstl/memory/netapi_allocator/entry.cpp +++ b/test/unit/winstl/memory/netapi_allocator/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `winstl::netapi_allocator`. * * Created: 18th October 2024 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -102,7 +102,7 @@ static void exercise_allocate(allocator_t::size_type n) allocator_t ator; allocator_t::pointer p = ator.allocate(n); - TEST_PTR_NE(NULL, p); + TEST_PTR_NOT_NULL(p); for (allocator_t::size_type i = 0; i != n; ++i) { @@ -129,7 +129,7 @@ static void test_alloc_0() allocator_t::pointer p = a1.allocate(0); - TEST_PTR_NE(NULL, p); + TEST_PTR_NOT_NULL(p); a1.deallocate(p); } diff --git a/test/unit/winstl/memory/processheap_allocator/entry.cpp b/test/unit/winstl/memory/processheap_allocator/entry.cpp index ab3fdb47a..c8b8ccea9 100644 --- a/test/unit/winstl/memory/processheap_allocator/entry.cpp +++ b/test/unit/winstl/memory/processheap_allocator/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `winstl::processheap_allocator`. * * Created: 18th October 2024 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -102,7 +102,7 @@ static void exercise_allocate(allocator_t::size_type n) allocator_t ator; allocator_t::pointer p = ator.allocate(n); - TEST_PTR_NE(NULL, p); + TEST_PTR_NOT_NULL(p); for (allocator_t::size_type i = 0; i != n; ++i) { @@ -129,7 +129,7 @@ static void test_alloc_0() allocator_t::pointer p = a1.allocate(0); - TEST_PTR_NE(NULL, p); + TEST_PTR_NOT_NULL(p); a1.deallocate(p); } diff --git a/test/unit/winstl/memory/shell_allocator/entry.cpp b/test/unit/winstl/memory/shell_allocator/entry.cpp index 415d5fbcc..e541b42cd 100644 --- a/test/unit/winstl/memory/shell_allocator/entry.cpp +++ b/test/unit/winstl/memory/shell_allocator/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for `winstl::shell_allocator`. * * Created: 18th October 2024 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -102,7 +102,7 @@ static void exercise_allocate(allocator_t::size_type n) allocator_t ator; allocator_t::pointer p = ator.allocate(n); - TEST_PTR_NE(NULL, p); + TEST_PTR_NOT_NULL(p); for (allocator_t::size_type i = 0; i != n; ++i) { @@ -129,7 +129,7 @@ static void test_alloc_0() allocator_t::pointer p = a1.allocate(0); - TEST_PTR_NE(NULL, p); + TEST_PTR_NOT_NULL(p); a1.deallocate(p); } diff --git a/test/unit/winstl/util/struct_initialisers/entry.cpp b/test/unit/winstl/util/struct_initialisers/entry.cpp index cdd641d9d..00a247a93 100644 --- a/test/unit/winstl/util/struct_initialisers/entry.cpp +++ b/test/unit/winstl/util/struct_initialisers/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Component test for `winstl::struct_initialisers`. * * Created: 9th October 2024 - * Updated: 29th September 2026 + * Updated: 20th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -218,9 +218,9 @@ static void test_STARTUPINFOW() winstl::init_struct(si); TEST_INT_EQ(sizeof(si), si.cb); - TEST_PTR_EQ(NULL, si.lpReserved); - TEST_PTR_EQ(NULL, si.lpDesktop); - TEST_PTR_EQ(NULL, si.lpTitle); + TEST_PTR_NULL(si.lpReserved); + TEST_PTR_NULL(si.lpDesktop); + TEST_PTR_NULL(si.lpTitle); TEST_INT_EQ(0u, si.dwX); TEST_INT_EQ(0u, si.dwY); TEST_INT_EQ(0u, si.dwXSize); @@ -231,10 +231,10 @@ static void test_STARTUPINFOW() TEST_INT_EQ(0u, si.dwFlags); TEST_INT_EQ(0u, si.wShowWindow); TEST_INT_EQ(0u, si.cbReserved2); - TEST_PTR_EQ(NULL, si.lpReserved2); - TEST_PTR_EQ(NULL, si.hStdInput); - TEST_PTR_EQ(NULL, si.hStdOutput); - TEST_PTR_EQ(NULL, si.hStdError); + TEST_PTR_NULL(si.lpReserved2); + TEST_PTR_NULL(si.hStdInput); + TEST_PTR_NULL(si.hStdOutput); + TEST_PTR_NULL(si.hStdError); } @@ -351,7 +351,7 @@ static void test_SECURITY_ATTRIBUTES() winstl::init_struct(sa); TEST_INT_EQ(sizeof(sa), sa.nLength); - TEST_PTR_EQ(NULL, sa.lpSecurityDescriptor); + TEST_PTR_NULL(sa.lpSecurityDescriptor); TEST_BOOLEAN_FALSE(sa.bInheritHandle); } @@ -369,7 +369,7 @@ static void test_DRAGINFOA() POINT pt; #endif TEST_BOOLEAN_FALSE(da.fNC); - TEST_PTR_EQ(NULL, da.lpFileList); + TEST_PTR_NULL(da.lpFileList); TEST_INT_EQ(0u, da.grfKeyState); } From 9694b1664125882b8fb68f609fde6082612f669f Mon Sep 17 00:00:00 2001 From: synesissoftware Date: Sun, 25 Oct 2026 13:59:32 +1100 Subject: [PATCH 19/22] chore(nomenclature): standardise use of alpha/beta/rc nomenclature throughout the repo (#75) * `auto_buffer` extraneous warning (#74) * 1.11.2 version elements * fix(stlsoft): silence GCC 12+ free-nonheap warning in auto_buffer Mark `deallocate_()` `STLSOFT_NOINLINE` on GCC 12+ so `operator delete` stays out of the inlined destructor, and suppress `-Wfree-nonheap-object` around the external-buffer `delete`, which GCC misattributes to the internal buffer. * test(stlsoft): compare a full sun_path with a counted string A 108-character path fills Linux sun_path and is not NUL-terminated. TEST_MS_EQ then read past the array. Use TEST_MS_EQ_N when the path length is the capacity, as the 104-character case already does. --------- Co-authored-by: Matt Wilson * chore(nomenclature): standardise use of alpha/beta/rc nomenclature throughout the repo --------- Co-authored-by: Matt Wilson --- CHANGES.md | 188 ++++++++-------- include/acestl/acestl.hpp | 12 +- include/atlstl/atlstl.hpp | 16 +- include/comstl/comstl.h | 18 +- include/inetstl/inetstl.h | 22 +- include/mfcstl/mfcstl.hpp | 12 +- include/platformstl/platformstl.h | 26 +-- include/rangelib/rangelib.hpp | 8 +- include/stlsoft/stlsoft.h | 200 +++++++++--------- .../unixstl/filesystem/filesystem_traits.hpp | 2 +- include/unixstl/unixstl.h | 36 ++-- include/winstl/winstl.h | 42 ++-- include/wtlstl/wtlstl.hpp | 12 +- strategy/COMPONENTS-INVENTORY.md | 24 +-- test/unit/versions/entry.cpp | 2 +- 15 files changed, 311 insertions(+), 309 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b58bcd34a..61abfadf5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,8 @@ * **stlsoft/memory/auto_buffer.hpp** — on GCC 12+, marked `deallocate_()` `STLSOFT_NOINLINE` and suppressed `-Wfree-nonheap-object` around the external-buffer `delete`, which GCC misattributes to the internal buffer; * testing: * applies xTests' null-ptr macros; +* documentation and boilerplate: + * standardised use of alpha/beta/rc nomenclature throughout the repo; ## 1.11.1 - 21st October 2026 @@ -143,10 +145,10 @@ * version: * **test.unit.versions** — aligned with **1.11.1-rc9** (**_STLSOFT_VER_1_11_1_RC9**); * **comstl** — **1.10.4** (**_COMSTL_VER_1_10_4**), with **STLSoft 1.11.1-rc9**; - * **inetstl** — **1.5.0 alpha 4** (**_INETSTL_VER_1_5_0_A04**), with **STLSoft 1.11.1-rc9**; - * **platformstl** — **1.10.0 beta 3** (**_PLATFORMSTL_VER_1_10_0_B03**), with **STLSoft 1.11.1-rc9**; - * **unixstl** — **1.8.6 beta 8** (**_UNIXSTL_VER_1_8_6_B08**), with **STLSoft 1.11.1-rc9**; - * **winstl** — **1.13.0 beta 5** (**_WINSTL_VER_1_13_0_B05**), with **STLSoft 1.11.1-rc9**; + * **inetstl** — **1.5.0-alpha4** (**_INETSTL_VER_1_5_0_A04**), with **STLSoft 1.11.1-rc9**; + * **platformstl** — **1.10.0-beta3** (**_PLATFORMSTL_VER_1_10_0_B03**), with **STLSoft 1.11.1-rc9**; + * **unixstl** — **1.8.6-beta8** (**_UNIXSTL_VER_1_8_6_B08**), with **STLSoft 1.11.1-rc9**; + * **winstl** — **1.13.0-beta5** (**_WINSTL_VER_1_13_0_B05**), with **STLSoft 1.11.1-rc9**; ## 1.11.1-rc8 - 10th October 2026 @@ -165,9 +167,9 @@ * Example **examples/by_project/unixstl/filesystem/rewind_dir** — enumerates a directory in two passes (count, then collect), using `rewind_dir()` between them; * **test.unit.versions** — aligned with **1.11.1-rc8** (**_STLSOFT_VER_1_11_1_RC8**); * version: - * **unixstl** — **1.8.6 beta 7** (**_UNIXSTL_VER_1_8_6_B07**), with **STLSoft 1.11.1-rc8**; - * **winstl** — **1.13.0 beta 4** (**_WINSTL_VER_1_13_0_B04**), with **STLSoft 1.11.1-rc8**; - * **inetstl** — **1.5.0 alpha 3** (**_INETSTL_VER_1_5_0_A03**), with **STLSoft 1.11.1-rc8**; + * **unixstl** — **1.8.6-beta7** (**_UNIXSTL_VER_1_8_6_B07**), with **STLSoft 1.11.1-rc8**; + * **winstl** — **1.13.0-beta4** (**_WINSTL_VER_1_13_0_B04**), with **STLSoft 1.11.1-rc8**; + * **inetstl** — **1.5.0-alpha3** (**_INETSTL_VER_1_5_0_A03**), with **STLSoft 1.11.1-rc8**; * boilerplate: * Added **run_all_component_tests.sh** / **.cmd**, **run_all_performance_tests.sh** / **.cmd** (with `--gap-groups`), and **run_all_automated_tests.sh** / **.cmd** (unit then component; `--unit-only` / `--component-only`); * Added **generate_doxygen.sh**, **Doxyfile**, and **doc/mainpage.md** — HTML API documentation generated from the public headers into **_build/doxygen/html**; @@ -198,7 +200,7 @@ * Strategy note **strategy/BIT_FUNCTIONS.md** — measurements and default choice (table for `count_bits()`; keep intrinsics unselected pending cross-toolchain evidence); * **winstl::netapi_allocator** — pass a `DWORD` byte count to `NetApiBufferAllocate`; the unit test links **netapi32**; * **stlsoft/std/cstring.hpp** — suppress CRT deprecation around the `strcpy`, `strcat`, and `strdup` wrappers; -* **winstl** — **1.13.0 beta 3** (**_WINSTL_VER_1_13_0_B03**), with **STLSoft 1.11.1-rc7**; +* **winstl** — **1.13.0-beta3** (**_WINSTL_VER_1_13_0_B03**), with **STLSoft 1.11.1-rc7**; * CMake — Windows GNU (**MinGW**) test/example programs static-link **libgcc** / **libstdc++** so PE images load when runner **PATH** does not match the build toolchain; * CI — performance job exports **SIS_PERFTESTS_GROUPGAPS=1**; * **execute_performance_tests.sh** — capture the child exit code after optional `expand` piping (was overwriting a failed status with `$?` from the success branch); @@ -211,7 +213,7 @@ * Performance suite **test/performance/stlsoft/util/bit_functions** (density patterns, intrinsic rows, median / ns-per-call reporting); * Performance suite **test/performance/platformstl/filesystem/file_lines** — comparative harness vs `fgetc` / `std::getline` (LF / CRLF / CR; mid-size and small-file shapes; C++11+); * Unit tests — removed empty placeholder cases; filled the nine allocator suites (**comstl::task_allocator**, **mfcstl::afx_allocator**, **malloc_allocator**, **new_allocator**, **null_allocator**, and WinSTL **global_allocator**, **netapi_allocator**, **processheap_allocator**, and **shell_allocator**) with round-trip sizes, `max_size()`, and `std::list` / `std::vector` use (`null_allocator` throws `out_of_memory_exception`); -* **test.unit.versions** — aligned with **1.11.1-rc7** (**_STLSOFT_VER_1_11_1_RC7**) and **WinSTL 1.13.0 beta 3** (**_WINSTL_VER_1_13_0_B03**); +* **test.unit.versions** — aligned with **1.11.1-rc7** (**_STLSOFT_VER_1_11_1_RC7**) and **WinSTL 1.13.0-beta3** (**_WINSTL_VER_1_13_0_B03**); ## 1.11.1-rc6 - 21st September 2026 @@ -711,48 +713,48 @@ * CMake support; -## 1.10.1 beta 33 - 26th April 2021 +## 1.10.1-beta33 - 26th April 2021 * Clang compatibility; -## 1.10.1 beta 32 - 26th April 2021 +## 1.10.1-beta32 - 26th April 2021 * GCC/Clang compatibility; -## 1.10.1 beta 31 - 2nd April 2021 +## 1.10.1-beta31 - 2nd April 2021 * Clang compatibility; * provision for customising inline (in C compilation); * warnings; -## 1.10.1 beta 30 - 29th March 2021 +## 1.10.1-beta30 - 29th March 2021 * Clang compatibility; * warnings; -## 1.10.1 beta 29 - 16th February 2021 +## 1.10.1-beta29 - 16th February 2021 * a whole lot of Clang- and GCC-compatibility; -## 1.10.1 beta 28 - 18th January 2021 +## 1.10.1-beta28 - 18th January 2021 * added character-array overloads of fast_strftime(); * WinSTL hard link information functions now work for directories as well as files; * various defect fixes; -## 1.10.1 beta 27 - 10th January 2021 +## 1.10.1-beta27 - 10th January 2021 * added string access shims for std::chrono type(s); * some GCC compatibility tweaks; -## 1.10.1 beta 26 - 4th January 2021 +## 1.10.1-beta26 - 4th January 2021 * added (UNIXSTL and WinSTL) Path Classification API (from 1.12 work), which work with Windows UNC and long-path root designators and all slash conventions; * added (UNIXSTL and WinSTL) path parsing function - include/???stl/filesystem/path_parse_functions.h, presenting a consistent set of functions centralised from disparate parts of the libraries; @@ -770,17 +772,17 @@ * BREAKING CHANGES: ~ abstracted out string-handling from *stl::system_traits<> into stlsoft::c_string_traits<>, and removed several unused (and sketchy) functions; -## 1.10.1 beta 25 - 14th December 2020 +## 1.10.1-beta25 - 14th December 2020 -* added two more files missing from beta 23 - D'oh!; +* added two more files missing from-beta23 - D'oh!; -## 1.10.1 beta 24 - 13th December 2020 +## 1.10.1-beta24 - 13th December 2020 -* added file unixstl/filesystem/path_buffer.hpp missing from beta 23; +* added file unixstl/filesystem/path_buffer.hpp missing from-beta23; -## 1.10.1 beta 23 - 13th December 2020 +## 1.10.1-beta23 - 13th December 2020 * basic_file_path_buffer<> is now deprecated in all projects, and all dependent components are modified to use other facilities; * added platformstl::environment_variable<> class template; @@ -793,7 +795,7 @@ * large number of new methods and defect fixes in (platformstl|unixstl|winstl)::system_traits; -## 1.10.1 beta 22 - 29th November 2020 +## 1.10.1-beta22 - 29th November 2020 * added stlsoft::string_to_integer_range(); * added stlsoft::strnchr(), stlsoft::strnistrn(), stlsoft::strnstrn() C-style string search functions; @@ -809,7 +811,7 @@ * fixed case of a bunch of headers; -## 1.10.1 beta 21 - 27th July 2020 +## 1.10.1-beta21 - 27th July 2020 * VC++ 15/16 compatibility; * fixed unixstl::readdir_sequence::empty(); @@ -821,12 +823,12 @@ * fixed unixstl::readdir_sequence::empty(); -## 1.10.1 beta 20 - 4th July 2020 +## 1.10.1-beta20 - 4th July 2020 * fixed detecton of shared_ptr and unique_ptr; -## 1.10.1 beta 19 - 4th July 2020 +## 1.10.1-beta19 - 4th July 2020 * added stlsoft::t2w, stlsoft::w2t, stlsoft::t2a, stlsoft::a2t for upcoming Pantheios release; * added stream insertion operator (generic) for string slice types; @@ -845,14 +847,14 @@ * Add support for the ARM architecture when doing Android NDK GCC compilation; -## 1.10.1 beta 18 - 31st October 2019 +## 1.10.1-beta18 - 31st October 2019 * added stlsoft/system/environment/functions.hpp to enhances stlsoft::environment_variable_exists() with string access shims to support arbitrary string type; * remove vestigial (and erroneous) winstl/string/spin_policies.hpp; * various documentation fixes; -## 1.10.1 beta 17 - 24th October 2019 +## 1.10.1-beta17 - 24th October 2019 * GCC 8 compatibility; * GCC 9 compatibility; @@ -860,7 +862,7 @@ * improved documentation; -## 1.10.1 beta 16 - 13th October 2019 +## 1.10.1-beta16 - 13th October 2019 * added stlsoft_C_environment_variable_exists_a() / environment_variable_exists() (from STLSoft 1.10-alpha); * added stlsoft::count_bits(int) overload; @@ -879,7 +881,7 @@ * fixed up project files (README, NEWS, etc.); -## 1.10.1 beta 15 - 13th September 2019 +## 1.10.1-beta15 - 13th September 2019 * added stlsoft::fast_strftime() and stlsoft::fast_wcsftime() as drop-in replacements for std::strftime() and std::wcsftime(); * added get_ptr() shim overload for std::shared_ptr and std::unique_ptr; @@ -890,20 +892,20 @@ * various portability improvements to newer compilers; -## 1.10.1 beta 14 - 4th August 2019 +## 1.10.1-beta14 - 4th August 2019 * added SECURITY_DESCRIPTOR helpers(); * stlsoft::w2m and stlsoft::m2w now more general; -## 1.10.1 beta 13 - 16th April 2019 +## 1.10.1-beta13 - 16th April 2019 * fixed STLSOFT_ALWAYS_FALSE() / STLSOFT_ALWAYS_TRUE(); * platformstl::FILE_stream : ~ fixing character-encoding function selection defect; * canonicalising source file structure; -## 1.10.1 beta 12 - 26th December 2018 +## 1.10.1-beta12 - 26th December 2018 * added sas_to_string() (and related) functions; * added stlsoft::errno_exception (from 1.12 branch); @@ -912,30 +914,30 @@ * UNIXSTL's timeval String Access Shims now work for arbitrary locale; -## 1.10.1 beta 11 - 22nd December 2018 +## 1.10.1-beta11 - 22nd December 2018 * stlsoft::ref_ptr : + borrow(); + own(); * winstl::environment_variable : + data(); + equal(); + equal_ignore_case(); + exists(); + operators ==() and !=(); -## 1.10.1 beta 10 - 20th December 2018 +## 1.10.1-beta10 - 20th December 2018 * winstl::process_mutex() now takes an optional EVENT handle which will be signalled if the mutex experiences an abandoned acquire; * special_string_instance now provides generic (SAS) (in)equality operators automatically; * try_parse_to_bool() semantics firmed up; -## 1.10.1 beta 9 - 12th June 2018 +## 1.10.1-beta9 - 12th June 2018 * Borland compatibility; -## 1.10.1 beta 8 - 11th June 2018 +## 1.10.1-beta8 - 11th June 2018 * fixing break to UNIX-compatibility introduced in beta-6/7; -## 1.10.1 beta 7 - 9th June 2018 +## 1.10.1-beta7 - 9th June 2018 * auto_buffer<> now supports limited form of pointer arithmethic via operator -(); * added subscript operator for auto_array_destructor<>; @@ -943,7 +945,7 @@ * refactoring of copy-proscriptions; -## 1.10.1 beta 6 - 9th June 2018 +## 1.10.1-beta6 - 9th June 2018 * refactored in terms of external API; * removed empty/meaningless "compatibility" sections; @@ -951,19 +953,19 @@ * simplifying, and prospective changes (for getting to 1.12); -## 1.10.1 beta 5 - 15th May 2017 +## 1.10.1-beta5 - 15th May 2017 * enhanced STLSOFT_SUPPRESS_UNUSED() to work with rvalues; -## 1.10.1 beta 3 - 19th February 2017 +## 1.10.1-beta3 - 19th February 2017 * a whole bunch of non-functional changes to make the codebase more consistent and amenable to further automatic instrumentation by script auto-validation script compatibility, and ensure all files have full inclusion control; * fixing get_FILE_ptr() shim namespace issues; * winstl::token_information has additional compatibility up to W8/Svr12, and now defaults to throwing instances of winstl::security_exception; -## 1.10.1 beta 2 - 28th January 2017 +## 1.10.1-beta2 - 28th January 2017 * work on STLSoft integer_to_string functions to loosen non-array forms' preconditions, reduce dependencies in rest of codebase to integer_to_decimal_string()-only; * filesystem_traits - refactored is_dots() and starts_with_dots() to accomodate GCC 4.9 pedanticism; @@ -972,7 +974,7 @@ * hiding/suppressing unused typedefs; -## 1.10.1 beta 1 - 14th January 2017 +## 1.10.1-beta1 - 14th January 2017 * too many changes to list here - it's a new world! (Bit of a shame it took 10 years to get here :$); * in summary:; @@ -2220,7 +2222,7 @@ * stlsoft/smartptr/shared_ptr.hpp:; * now correctly handles failure to allocate the shared counter, even when compiling absent exceptions; * atlstl/automation/enumerators.hpp:; -* fixed defect in Reset() - which did nothing! - that was introduced in STLSoft 1.9.1 beta 5 (!) upon transcription from the original, correct, Synesis Software proprietary source; +* fixed defect in Reset() - which did nothing! - that was introduced in STLSoft 1.9.1-beta5 (!) upon transcription from the original, correct, Synesis Software proprietary source; * minor documentation fixes; * unixstl/filesystem/filesystem_traits.hpp:; * removal of dependency of str(n)cpy()/wcs(n)cpy(), which causes VC++ 8+ to carp about "safety"; @@ -2977,7 +2979,7 @@ ## 1.9.18 - 27th January 2008 -* enhancement of STLSoft's integral_printf_trait component to support Pantheios 1.0.1 beta 91; +* enhancement of STLSoft's integral_printf_trait component to support Pantheios 1.0.1-beta91; * release of SAPI utility header for COMSTL; * added hex_format_a/w() methods to integral_printf_traits; * comstl/speech/sapi_util.hpp, which abstracts away the definitions of the SAPI interfaces and constants, for those compilers that do not have the headers supplied; @@ -3136,14 +3138,14 @@ * rangelib/algorithms.hpp: bug fix in r_equal(), r_exists_if(), r_find_if(); -## 1.9.1 beta 48 - 12th April 2007 +## 1.9.1-beta48 - 12th April 2007 * resource_type (and const_resource_type, for some) member type for: stlsoft::ptr_proxy stlsoft::ref_ptr stlsoft::shared_ptr comstl::bstr comstl::guid inetstl::connection inetstl::session unixstl::process_mutex unixstl::semaphore unixstl::thread_mutex winstl::module winstl::reg_key winstl::reg_key_sequence winstl::reg_value_sequence winstl::event winstl::process_mutex winstl::semaphore; * added operator () to fixed arrays (stlsoft/container/fixed_array.hpp) (as requested/persuaded by Neal Becker); * fixed bug in rangelib::r_exists() (Thanks to Yakov Markovitch); -## 1.9.1 beta 47 - 6th April 2007 +## 1.9.1-beta47 - 6th April 2007 * stlsoft::any_of() and stlsoft::all_of() composite predicate creator functions; * binary forms of stlsoft::ptr_fun and stlsoft::ptr_fun_void; @@ -3164,12 +3166,12 @@ * winstl::basic_findvolume_sequence bug with VC++ 8 now fixed; -## 1.9.1 beta 46 - 13th March 2007 +## 1.9.1-beta46 - 13th March 2007 * wholesale lexical changes (e.g. "char const *x" => "char const* x"); -## 1.9.1 beta 45 - 12th March 2007 +## 1.9.1-beta45 - 12th March 2007 * comstl::collection_sequence:; * const_iterator and const_pointer member types; @@ -3190,12 +3192,12 @@ * winstl::reg_value:; -## 1.9.1 beta 44 - 22nd February 2007 +## 1.9.1-beta44 - 22nd February 2007 * distribution is now rooted under stlsoft-X.Y, e.g. stlsoft-1.9.1-beta44; -## 1.9.1 beta 43 - 22nd January 2007 +## 1.9.1-beta43 - 22nd January 2007 * comstl::co_create_instance() overloads now have a third, defaulted, member, for creation context. This is required for the new VOLE project, which will be released tomorrow; * mfcstl::CArray_cadaptor and mfcstl::CArray_iadaptor now support <, <=, >, and >= comparison, in addition to ==, !=; @@ -3206,14 +3208,14 @@ * winstl/shims/access/string.hpp now includes winstl/shims/access/string/time.hpp; -## 1.9.1 beta 42 - 15th January 2007 +## 1.9.1-beta42 - 15th January 2007 * refactored atomic integer support on UNIX:; * Now only supports if for Mac OS-X, Win32 (when emulated, of course), and if UNIXSTL_FORCE_ATOMIC_INTEGER_OPERATIONS is defined, allowing the user to decide for themselves whether or not to use (non-portable) facilities such as asm/atomic.h; * unixstl/synch/util/features.h; -## 1.9.1 beta 41 - 14th January 2007 +## 1.9.1-beta41 - 14th January 2007 * refactored sized-integer detection:; * The symbols STLSOFT_CF_8BIT_INT_EXTENDED_TYPE_IS_DISTINCT STLSOFT_CF_16BIT_INT_EXTENDED_TYPE_IS_DISTINCT STLSOFT_CF_32BIT_INT_EXTENDED_TYPE_IS_DISTINCT are removed. Instead use STLSOFT_CF_CHAR_DISTINCT_INT_TYPE STLSOFT_CF_SHORT_DISTINCT_INT_TYPE STLSOFT_CF_INT_DISTINCT_INT_TYPE; @@ -3230,7 +3232,7 @@ * removed (almost) all of the previously deprecated __STLSOFT* symbols, __STLSOFT_COMPILER_IS_BORLAND __STLSOFT_COMPILER_IS_COMO __STLSOFT_COMPILER_IS_DMC __STLSOFT_COMPILER_IS_INTEL __STLSOFT_COMPILER_IS_GCC __STLSOFT_COMPILER_IS_MSVC __STLSOFT_COMPILER_IS_MWERKS __STLSOFT_COMPILER_IS_VECTORC __STLSOFT_COMPILER_IS_WATCOM __STLSOFT_COMPILER_IS_UNKNOWN __STLSOFT_COMPILER_LABEL_STRING __STLSOFT_COMPILER_VERSION_STRING __STLSOFT_DOCUMENTATION_SKIP_SECTION __STLSOFT_CF_STATIC_ASSERT_SUPPORT __STLSOFT_CF_EXCEPTION_SUPPORT __STLSOFT_CF_FUNCTION_SIGNATURE_FULL_ARG_QUALIFICATION_REQUIRED __STLSOFT_CF_NAMESPACE_SUPPORT __STLSOFT_CF_TEMPLATE_SUPPORT __STLSOFT_CF_EXCEPTION_SIGNATURE_SUPPORT __STLSOFT_CF_THROW_BAD_ALLOC __STLSOFT_CF_NOTHROW_BAD_ALLOC __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_FUNDAMENTAL_ARGUMENT_SUPPORT __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT __STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT __STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT __STLSOFT_CF_MEMBER_TEMPLATE_RANGE_METHOD_SUPPORT __STLSOFT_CF_MEMBER_TEMPLATE_CLASS_SUPPORT __STLSOFT_CF_TEMPLATE_SPECIALISATION_SYNTAX __STLSOFT_CF_TEMPLATE_PARTIAL_SPECIALISATION_SUPPORT __STLSOFT_CF_TEMPLATE_OUTOFCLASSFN_QUALIFIED_TYPE_SUPPORT __STLSOFT_CF_std_NAMESPACE __STLSOFT_CF_std_char_traits_AVAILABLE __STLSOFT_CF_ALLOCATOR_ALLOCATE_HAS_HINT __STLSOFT_CF_ALLOCATOR_DEALLOCATE_HAS_OBJECTCOUNT __STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT __STLSOFT_CF_EXPLICIT_KEYWORD_SUPPORT __STLSOFT_CF_MUTABLE_KEYWORD_SUPPORT __STLSOFT_CF_TYPENAME_PARAM_KEYWORD_SUPPORT __STLSOFT_CF_TYPENAME_TYPE_KEYWORD_SUPPORT __STLSOFT_CF_TYPENAME_TYPE_DEF_KEYWORD_SUPPORT __STLSOFT_CF_TYPENAME_TYPE_MIL_KEYWORD_SUPPORT __STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT __STLSOFT_CF_KOENIG_LOOKUP_SUPPORT __STLSOFT_CF_TEMPLATE_TEMPLATE_SUPPORT __STLSOFT_CF_STATIC_ARRAY_SIZE_DETERMINATION_SUPPORT __STLSOFT_CF_VENEER_SUPPORT __STLSOFT_CF_TEMPLATE_SHIMS_NOT_SUPPORTED __STLSOFT_CF_NEGATIVE_MODULUS_POSITIVE_GIVES_NEGATIVE_RESULT; -## 1.9.1 beta 40 - 6th January 2007 +## 1.9.1-beta40 - 6th January 2007 * stlsoft::format_thousands() grouping function template, e.g. char result[101]; stlsoft::format_thousands(result, STLSOFT_NUM_ELEMENTS(result), "2;3", 987654321); assert(0 == ::strcmp(result, "9876,54,321")); * stlsoft::truncation_test() function suite; this is necessary to support the new VOLE library (see http://vole.sourceforge.net/); @@ -3240,7 +3242,7 @@ * all remaining in-header unit-test blocks are removed into separate headers; -## 1.9.1 beta 39 - 5th January 2007 +## 1.9.1-beta39 - 5th January 2007 * oaidl interfaces to comstl/internal/interface_traits_std.hpp; * stream inserter for comstl::bstr; @@ -3248,7 +3250,7 @@ * fix to winstl/time/format_functions.h to fix bug with 24-hr time picture elements (HH); -## 1.9.1 beta 38 - 3rd January 2007 +## 1.9.1-beta38 - 3rd January 2007 * stlsoft/filesystem/io_functions.hpp, which defines the function template read_line, used to read a line of text from a FILE* stream, e.g. FILE *stm = . . .; std::string str; while (stlsoft::read_line(stm, str)) { ::fprintf(stdout, "line: %.*s\n", int(str.size()), str.data()); }; * stlsoft::ptr_ifun() indirection function pointer adaptor creator functions - used with std::for_each if you are storing a sequence of X but your function acts on X*, e.g. class X; void modX(X *); std::vector vecx; std::for_each(vecx.begin(), vecx.end(), stlsoft::ptr_ifun(modX)); @@ -3263,7 +3265,7 @@ * fixed compilation problem with unixstl/dl/dl_call.hpp with GCC 4.x; -## 1.9.1 beta 37 - 30th December 2006 +## 1.9.1-beta37 - 30th December 2006 * stlsoft::equal_handle function class - this is dead and gone; * stlsoft/container_veneers.hpp - this is obsolete; it points to correct #include; @@ -3289,14 +3291,14 @@ * winstl/registry/shared_handles.hpp => winstl/registry/util/shared_handles.hpp; -## 1.9.1 beta 36 - 28th December 2006 +## 1.9.1-beta36 - 28th December 2006 * unittest cases for unixstl::memory_mapped_file WinSTL; * winstl::memory_mapped_file can now be constructed from a wide string, in addition to a multibyte string. It can also be constructed from any type for which the stlsoft::c_str_ptr string access shim returns a wide string, in addition to any type for which the stlsoft::c_str_ptr string access shim returns a multibyte string; * unittest cases for winstl::memory_mapped_file; -## 1.9.1 beta 35 - 27th December 2006 +## 1.9.1-beta35 - 27th December 2006 * stlsoft::do_initialisation_never array initialisation policy, which stipulates that no initialisation whatsoever be performed on array elements; * stlsoft::scoped_handle now supports indirect cleanup functions. In other words, if you have a handle type handle_t, you can pass either a cleanup function taking handle_t - e.g. handle_close(handle_t ); - or a cleanup function taking a pointer to handle_t - e.g. handle_close_set_null(handle_t *); @@ -3306,7 +3308,7 @@ * refactoring of #includes in unixstl/synch/thread_mutex.hpp; -## 1.9.1 beta 34 - 24th December 2006 +## 1.9.1-beta34 - 24th December 2006 * replacement of all per-component exception throwing mechanisms with stlsoft::throw_x() utility function STLSoft; * deprecation of stlsoft::cwd_stack::is_empty() method; @@ -3335,20 +3337,20 @@ * winstl::to_SYSTEMTIME conversion shim; -## 1.9.1 beta 33 - 13th December 2006 +## 1.9.1-beta33 - 13th December 2006 * all comstl__??? functions are no longer in the comstl namespace (when in C++ compilation); their non comstl__-prefixed equivalents remain in the comstl namespace. For example, the full name of the comstl::comstl__set_error_info_description_w() function is now comstl__set_error_info_description_w() whether in C or C++; the name of comstl::set_error_info_description_w() remains as it was; * comstl::IDispatchImpl4; * comstl::try_interface_cast; -## 1.9.1 beta 32 - 6th December 2006 +## 1.9.1-beta32 - 6th December 2006 * fixed unixstl/unixstl.h (in)compatibility with C compilation; * fixed platformstl/platformstl.h (in)compatibility with C compilation; -## 1.9.1 beta 31 - 6th December 2006 +## 1.9.1-beta31 - 6th December 2006 * comstl/interface/bad_interface_cast.hpp -> comstl/error/bad_interface_cast.hpp; * comstl/interface/interface_cast.hpp -> comstl/conversion/interface_cast.hpp; @@ -3367,12 +3369,12 @@ * winstl::WaitForMultipleObjects() function suite renamed winstl::wait_for_multiple_objects(), and now implemented in terms of new winstl::get_synch_handle shim; -## 1.9.1 beta 30 - 2nd December 2006 +## 1.9.1-beta30 - 2nd December 2006 * UNIXSTL components spin_mutex and the atomic_???() function suite are now compatible with both architectures (PPC + Intel) on MAC OSX; -## 1.9.1 beta 29 - 27th November 2006 +## 1.9.1-beta29 - 27th November 2006 * atlstl::Window class - a string access shim-aware enhancement to ATLs' Window class; * COMSTL value policies throw exceptions if fail to copy; @@ -3380,13 +3382,13 @@ * WinSTL's pid_sequence and process_module_sequence classes have been rendered slightly more efficient; -## 1.9.1 beta 28 - 29th October 2006 +## 1.9.1-beta28 - 29th October 2006 * stlsoft::a2w() and stlsoft::w2a() char conversion functions (functionally the same as the WinSTL ones); * fixed bug in winstl/shims/access/string/time.hpp that breaks Pantheios in UNICODE builds; -## 1.9.1 beta 27 - 22nd October 2006 +## 1.9.1-beta27 - 22nd October 2006 * stlsoft::trip_bool class template; * stlsoft/functional/function_adaptors.hpp does not include stlsoft/functional/method_adaptors.hpp for GCC < 3.3; @@ -3394,7 +3396,7 @@ * fixed for UNIX makefiles; -## 1.9.1 beta 26 - 21st October 2006 +## 1.9.1-beta26 - 21st October 2006 * stlsoft::scoped_handle specialisation for scoping APIs with 0 params; * string access shims (in InetSTL) for struct in_addr; @@ -3402,7 +3404,7 @@ * fix to stlsoft::integer_to_string() overloads to handle (unsigned) long in addition to all the others; -## 1.9.1 beta 25 - 5th October 2006 +## 1.9.1-beta25 - 5th October 2006 * fixed #include omission stlsoft/conversion/byte_format_functions.hpp; * fixed method omissions in stlsoft::special_string_instance_1; @@ -3410,7 +3412,7 @@ * winstl/util/struct_initialisers.hpp now handles case where WIN32_LEAN_AND_MEAN may have been defined; -## 1.9.1 beta 24 - 24th September 2006 +## 1.9.1-beta24 - 24th September 2006 * stlsoft::basic_shim_string::internal_size(); * unixstl::process_mutex now allows for wrapping of an externally created pthread_mutex_t*; @@ -3424,25 +3426,25 @@ * platformstl/synch/atomic_functions.h now contains various feature detection symbols, e.g. PLATFORMSTL_HAS_ATOMIC_PREINCREMENT, PLATFORMSTL_HAS_ATOMIC_PREADD; -## 1.9.1 beta 23 - 17th September 2006 +## 1.9.1-beta23 - 17th September 2006 * mfcstl/collections/clist_adaptors.hpp: mfcstl::CList_iadaptor replaces the old mfcstl::list_adaptor class template; * a whole load more directory changes. Very few now remain, and 1.9.1 proper is very close; -## 1.9.1 beta 22 - 13th September 2006 +## 1.9.1-beta22 - 13th September 2006 * the following files were "moved" into stlsoft/util: options_verifier.hpp printf_traits.hpp true_typedef.hpp argument_proxies.hpp compiler_optimisation_traits.hpp constraints.hpp limit_traits.h sign_traits.hpp size_traits.hpp static_initialisers.hpp; * the following files were "moved" into stlsoft/obsolete: first_class_promoter.hpp explicit_inheritance_veneer.hpp; * fix of version numbers in stlsoft/stlsoft.h; -## 1.9.1 beta 21 - 7th September 2006 +## 1.9.1-beta21 - 7th September 2006 * fix bug in stlsoft::member_selector_iterator (which crops up when compiling Pantheios with Visual C++ 8); -## 1.9.1 beta 20 - 2nd September 2006 +## 1.9.1-beta20 - 2nd September 2006 * comstl::bstr (comstl/string/bstr.hpp) - facade for BSTR; * comstl::variant (comstl/util/variant.hpp) - facade for VARIANT; @@ -3451,18 +3453,18 @@ * winstl::reg_get_dword_value() - retrieves a DWORD value from a reg key; -## 1.9.1 beta 19 - 9th August 2006 +## 1.9.1-beta19 - 9th August 2006 * dotnetstl::check_cast custom cast function template (dotnetstl/conversion/check_cast.hpp); -## 1.9.1 beta 18 - 7th August 2006 +## 1.9.1-beta18 - 7th August 2006 * stlsoft/string/special_string_instance.hpp: string access shims for stlsoft::special_string_instance_1 class template are now defined; * atlstl/automation/automation_collections.hpp: atlstl::generic_automation_collection (and atlstl::generic_collection_base) now both can accept a template param for the (dual) interface from which they inherit - they used to inherit from IDispatch; -## 1.9.1 beta 17 - 5th August 2006 +## 1.9.1-beta17 - 5th August 2006 * winstl/controls/dialog_functions.hpp: winstl::dialog_button_id_check unary function class; * The method form of atlstl::get_MemberValue() now is a bit more flexible, in that the returned type and the method return value may be different (but must still be compatible); @@ -3471,34 +3473,34 @@ * winstl::load_text_file() now throws an exception if the file cannot be opened; -## 1.9.1 beta 16 - 25th July 2006 +## 1.9.1-beta16 - 25th July 2006 * stlsoft::byte_format() - powerful binary=>text formatting function; * winstl::console_colour_scope - scoping class for Win32 console soon to be released; http://pantheios.org/); * acestl::message_queue_sequence uses optimised scatter/slice IO technique described in "Extended STL, volume 1" (to be published at the end of the year, or early 2007), for faster processing of block copy operations; -## 1.9.1 beta 15 - 18th July 2006 +## 1.9.1-beta15 - 18th July 2006 * More directory changes, particularly for the Template Meta-programming library; * New container class: platformstl::cwd_stack - which is used to store current working directory checkpoints (via push(), and restore them via pop() - future enhancements to internals are planned, but interface likely to remain unchanged; * A whole host of algorithms that've been hiding in the research branch for over a year are now brought into the main trunk, under include/stlsoft/algorithms/..; -## 1.9.1 beta 14 - 15th July 2006 +## 1.9.1-beta14 - 15th July 2006 * More directory refactoring, particularly for the string access shims, /shims/access/string.hpp; * Function/method pointer adaptors now cope with void/non-void return, const/non-const methods, and cdecl/fastcall/stdcall calling conventions Note: Please make sure that you delete directory include/stlsoft/typefixer; -## 1.9.1 beta 13 - 12th July 2006 +## 1.9.1-beta13 - 12th July 2006 * A massive amount of refactoring of the string access shims and their documentation; * unixstl::module / winstl::module get_handle() method removed, replaced with get_module_handle(); * unixstl::process_mutex now throws exceptions (when compiled with exception-handling on) if any of the PThreads methods fail; -## 1.9.1 beta 12 - 8th July 2006 +## 1.9.1-beta12 - 8th July 2006 * stlsoft::special_string_instance, which supports the "Special String Instance" pattern (see online docs for expl); * unixstl::current_directory, winstl::current_directory, winstl::absolute_path, winstl::module_directory, winstl::module_filename, winstl::system_directory, winstl::windows_directory, are no longer separate classes, but rather specialisations (with different policies, as appropriate) of stlsoft::special_string_instance; @@ -3510,12 +3512,12 @@ * lots and lots more directory re-arrangements, and addition of "better" documentation (to be seen currently at http://stlsoft.org/doc-1.9); -## 1.9.1 beta 11 - 25th June 2006 +## 1.9.1-beta11 - 25th June 2006 * no changes; -## 1.9.1 beta 10 - 18th June 2006 +## 1.9.1-beta10 - 18th June 2006 * stlsoft/string/copy_functions.hpp; * atlstl::SupportErrorInfoImpl5 class template; @@ -3535,22 +3537,22 @@ * stlsoft/system/commandline_parser.hpp - minor bug fix; -## 1.9.1 beta 9 - 11th June 2006 +## 1.9.1-beta9 - 11th June 2006 * no changes; -## 1.9.1 beta 8 - 7th June 2006 +## 1.9.1-beta8 - 7th June 2006 * no changes; -## 1.9.1 beta 7 - 1st June 2006 +## 1.9.1-beta7 - 1st June 2006 * no changes; -## 1.9.1 beta 6 - 28th May 2006 +## 1.9.1-beta6 - 28th May 2006 * atlstl::IDispatch2 and atlstl::IDispatch3 class templates (atlstl/multiple_dispatch.hpp); * atlstl::get_ConstantValue() (atlstl/property_method_helpers.hpp); @@ -3577,7 +3579,7 @@ * stlsoft::string_concatenator_iterator now works with Borland; -## 1.9.1 beta 5 - 28th March 2006 +## 1.9.1-beta5 - 28th March 2006 * a heap of memory-related components now reside in /memory/ sub-directory, e.g. comstl/task_allocator.hpp => comstl/memory/task_allocator.hpp; * same goes for many exceptions, e.g. stlsoft/contract_violation.hpp => stlsoft/exceptions/contract_violation.hpp; @@ -3600,7 +3602,7 @@ * WinSTL Registry library has had a major reworking; -## 1.9.1 beta 4 - 31st January 2006 +## 1.9.1-beta4 - 31st January 2006 * stlsoft::charset_tokeniser (stlsoft/charset_tokeniser.hpp) - a "refinement" of stlsoft::string_tokeniser, making it easy to tokenise using charsets (a la strtok()) without the mess of using custom comparators with string_tokeniser (which can be something of a drag); * comstl::cloneable_cloning_policy (comstl/enumeration_policies.hpp) - a policy that enables comstl::enumerator_sequence to be used with enumerators that may, or may not, be cloneable; @@ -3620,7 +3622,7 @@ * comstl::degenerate_cloning_policy; -## 1.9.1 beta 3 - 20th January 2006 +## 1.9.1-beta3 - 20th January 2006 * stlsoft/collections.hpp: contains new collection concept tags; * stlsoft::external_iterator_invalidation (stlsoft/exceptions/external_iterator_invalidation.hpp): new exception class for representing iterator interruption by external agents; @@ -3647,14 +3649,14 @@ * stlsoft_proxy_ptr.h => stlsoft/ptr_proxy.hpp; -## 1.9.1 beta 2 - 27th December 2005 +## 1.9.1-beta2 - 27th December 2005 * stlsoft::exception_string class. (Replaces simple_string in exception classes); * stlsoft::string_concatenator_iterator; * stlsoft::tref_reverse_iterator; -## 1.9.1 beta 1 - 20th December 2005 +## 1.9.1-beta1 - 20th December 2005 * includes alpha version of new XMLSTL sub-project; * (nearly) completes the change of directory structure, e.g. from winstl_shell_allocator.h => winstl/shell_allocator.hpp; diff --git a/include/acestl/acestl.hpp b/include/acestl/acestl.hpp index 37cba2cbd..d1b133dda 100644 --- a/include/acestl/acestl.hpp +++ b/include/acestl/acestl.hpp @@ -5,7 +5,7 @@ * platform discriminations, and definitions of types. * * Created: 15th September 2004 - * Updated: 20th October 2026 + * Updated: 25th October 2026 * * Home: http://stlsoft.org/ * @@ -50,7 +50,7 @@ # define ACESTL_VER_ACESTL_HPP_ACESTL_MAJOR 1 # define ACESTL_VER_ACESTL_HPP_ACESTL_MINOR 8 # define ACESTL_VER_ACESTL_HPP_ACESTL_REVISION 2 -# define ACESTL_VER_ACESTL_HPP_ACESTL_EDIT 58 +# define ACESTL_VER_ACESTL_HPP_ACESTL_EDIT 59 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ /** \file acestl/acestl.hpp @@ -142,9 +142,9 @@ # define _ACESTL_VER_1_0_4 0x00010004 /*!< Version 1.0.4 */ # define _ACESTL_VER_1_1_1 0x00010101 /*!< Version 1.1.1 (STLSoft 1.9.1) */ # define _ACESTL_VER_1_1_2 0x00010102 /*!< Version 1.1.2 (STLSoft 1.9.25) */ -# define _ACESTL_VER_1_2_1_B01 0x01020181 /*!< Version 1.2.1 beta 1 (STLSoft 1.10.1 b1) */ -# define _ACESTL_VER_1_2_1_B02 0x01020182 /*!< Version 1.2.1 beta 2 (STLSoft 1.10.1 beta 26) */ -# define _ACESTL_VER_1_2_1 0x010201ff /*!< Version 1.2.1 (with STLSoft 1.11.1 alpha 8) */ +# define _ACESTL_VER_1_2_1_B01 0x01020181 /*!< Version 1.2.1-beta1 (STLSoft 1.10.1 b1) */ +# define _ACESTL_VER_1_2_1_B02 0x01020182 /*!< Version 1.2.1-beta2 (STLSoft 1.10.1-beta26) */ +# define _ACESTL_VER_1_2_1 0x010201ff /*!< Version 1.2.1 (with STLSoft 1.11.1-alpha8) */ #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ #define _ACESTL_VER_MAJOR 1 @@ -199,7 +199,7 @@ */ #if _STLSOFT_VER < 0x010a019a -# error This version of the ACESTL libraries requires STLSoft version 1.10.1 beta 26, or later +# error This version of the ACESTL libraries requires STLSoft version 1.10.1-beta26, or later #endif /* _STLSOFT_VER */ diff --git a/include/atlstl/atlstl.hpp b/include/atlstl/atlstl.hpp index 227b21507..c1be159ea 100644 --- a/include/atlstl/atlstl.hpp +++ b/include/atlstl/atlstl.hpp @@ -5,7 +5,7 @@ * platform discriminations, and definitions of types. * * Created: 15th January 2002 - * Updated: 20th October 2026 + * Updated: 25th October 2026 * * Home: http://stlsoft.org/ * @@ -51,7 +51,7 @@ # define ATLSTL_VER_ATLSTL_HPP_ATLSTL_MAJOR 3 # define ATLSTL_VER_ATLSTL_HPP_ATLSTL_MINOR 7 # define ATLSTL_VER_ATLSTL_HPP_ATLSTL_REVISION 2 -# define ATLSTL_VER_ATLSTL_HPP_ATLSTL_EDIT 127 +# define ATLSTL_VER_ATLSTL_HPP_ATLSTL_EDIT 128 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ /** \file atlstl/atlstl.hpp @@ -141,11 +141,11 @@ # define _ATLSTL_VER_1_6_1 0x00010601 /*!< Version 1.6.1 (with STLSoft 1.9.1) */ # define _ATLSTL_VER_1_6_2 0x00010602 /*!< Version 1.6.2 (with STLSoft 1.9.25) */ # define _ATLSTL_VER_1_6_3 0x010603ff /*!< Version 1.6.3 (with STLSoft 1.9.113) */ -# define _ATLSTL_VER_1_7_1_B01 0x01070181 /*!< Version 1.7.1 beta 1 (with STLSoft 1.10.1 beta 1) */ -# define _ATLSTL_VER_1_7_1_B02 0x01070182 /*!< Version 1.7.1 beta 2 (with STLSoft 1.10.1 beta 4) */ -# define _ATLSTL_VER_1_7_1_B03 0x01070183 /*!< Version 1.7.1 beta 3 (with STLSoft 1.10.1 beta 10) */ -# define _ATLSTL_VER_1_7_1_B04 0x01070184 /*!< Version 1.7.1 beta 4 (with STLSoft 1.10.1 beta 26) */ -# define _ATLSTL_VER_1_7_1 0x010701ff /*!< Version 1.7.1 (with STLSoft 1.11.1 alpha 8) */ +# define _ATLSTL_VER_1_7_1_B01 0x01070181 /*!< Version 1.7.1-beta1 (with STLSoft 1.10.1-beta1) */ +# define _ATLSTL_VER_1_7_1_B02 0x01070182 /*!< Version 1.7.1-beta2 (with STLSoft 1.10.1-beta4) */ +# define _ATLSTL_VER_1_7_1_B03 0x01070183 /*!< Version 1.7.1-beta3 (with STLSoft 1.10.1-beta10) */ +# define _ATLSTL_VER_1_7_1_B04 0x01070184 /*!< Version 1.7.1-beta4 (with STLSoft 1.10.1-beta26) */ +# define _ATLSTL_VER_1_7_1 0x010701ff /*!< Version 1.7.1 (with STLSoft 1.11.1-alpha8) */ #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ #define _ATLSTL_VER_MAJOR 1 @@ -212,7 +212,7 @@ */ #if _STLSOFT_VER < 0x010a019a -# error This version of the ATLSTL libraries requires STLSoft version 1.10.1 beta 26, or later +# error This version of the ATLSTL libraries requires STLSoft version 1.10.1-beta26, or later #endif /* _STLSOFT_VER */ /* ///////////////////////////////////////////////////////////////////////// diff --git a/include/comstl/comstl.h b/include/comstl/comstl.h index 5768500af..6be0958da 100644 --- a/include/comstl/comstl.h +++ b/include/comstl/comstl.h @@ -5,7 +5,7 @@ * platform discriminations, and definitions of types. * * Created: 15th January 2002 - * Updated: 20th October 2026 + * Updated: 25th October 2026 * * Home: http://stlsoft.org/ * @@ -56,7 +56,7 @@ # define COMSTL_VER_COMSTL_H_COMSTL_MAJOR 3 # define COMSTL_VER_COMSTL_H_COMSTL_MINOR 9 # define COMSTL_VER_COMSTL_H_COMSTL_REVISION 10 -# define COMSTL_VER_COMSTL_H_COMSTL_EDIT 136 +# define COMSTL_VER_COMSTL_H_COMSTL_EDIT 137 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ /** \file comstl/comstl.h @@ -164,13 +164,13 @@ # define _COMSTL_VER_1_8_6 0x010806ff /*!< Version 1.8.6 (with STLSoft 1.9.97) */ # define _COMSTL_VER_1_9_1 0x010901ff /*!< Version 1.9.1 (with STLSoft 1.9.98) */ # define _COMSTL_VER_1_9_2 0x010902ff /*!< Version 1.9.2 (with STLSoft 1.9.113) */ -# define _COMSTL_VER_1_10_1_B01 0x010a0181 /*!< Version 1.10.1 beta 1 (with STLSoft 1.10.1 beta 1) */ -# define _COMSTL_VER_1_10_1_B02 0x010a0182 /*!< Version 1.10.1 beta 2 (with STLSoft 1.10.1 beta 17) */ -# define _COMSTL_VER_1_10_1_B03 0x010a0183 /*!< Version 1.10.1 beta 3 (with STLSoft 1.10.1 beta 26) */ +# define _COMSTL_VER_1_10_1_B01 0x010a0181 /*!< Version 1.10.1-beta1 (with STLSoft 1.10.1-beta1) */ +# define _COMSTL_VER_1_10_1_B02 0x010a0182 /*!< Version 1.10.1-beta2 (with STLSoft 1.10.1-beta17) */ +# define _COMSTL_VER_1_10_1_B03 0x010a0183 /*!< Version 1.10.1-beta3 (with STLSoft 1.10.1-beta26) */ # define _COMSTL_VER_1_10_1 0x010a01ff /*!< Version 1.10.1 (with STLSoft 1.10.3) */ -# define _COMSTL_VER_1_10_2 0x010a02ff /*!< Version 1.10.2 (with STLSoft 1.11.1 alpha 8) */ -# define _COMSTL_VER_1_10_3 0x010a03ff /*!< Version 1.10.3 (with STLSoft 1.11.1 alpha 17) */ -# define _COMSTL_VER_1_10_4 0x010a04ff /*!< Version 1.10.4 (with STLSoft 1.11.1 rc 9) */ +# define _COMSTL_VER_1_10_2 0x010a02ff /*!< Version 1.10.2 (with STLSoft 1.11.1-alpha8) */ +# define _COMSTL_VER_1_10_3 0x010a03ff /*!< Version 1.10.3 (with STLSoft 1.11.1-alpha17) */ +# define _COMSTL_VER_1_10_4 0x010a04ff /*!< Version 1.10.4 (with STLSoft 1.11.1-rc9) */ #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ #define _COMSTL_VER_MAJOR 1 @@ -228,7 +228,7 @@ */ #if _STLSOFT_VER < 0x010b0151 -# error This version of the COMSTL libraries requires STLSoft version 1.11.1 alpha 17, or later +# error This version of the COMSTL libraries requires STLSoft version 1.11.1-alpha17, or later #endif /* _STLSOFT_VER */ diff --git a/include/inetstl/inetstl.h b/include/inetstl/inetstl.h index c9c732a1c..ab4ea14b6 100644 --- a/include/inetstl/inetstl.h +++ b/include/inetstl/inetstl.h @@ -5,7 +5,7 @@ * platform discriminations, and definitions of types. * * Created: 24th April 2004 - * Updated: 21st October 2026 + * Updated: 25th October 2026 * * Home: http://stlsoft.org/ * @@ -51,7 +51,7 @@ # define INETSTL_VER_INETSTL_H_INETSTL_MAJOR 3 # define INETSTL_VER_INETSTL_H_INETSTL_MINOR 11 # define INETSTL_VER_INETSTL_H_INETSTL_REVISION 5 -# define INETSTL_VER_INETSTL_H_INETSTL_EDIT 582 +# define INETSTL_VER_INETSTL_H_INETSTL_EDIT 584 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ /** \file inetstl/inetstl.h @@ -138,15 +138,15 @@ # define _INETSTL_VER_1_3_6 0x010306ff /*!< Version 1.3.6 (with STLSoft 1.9.113) */ # define _INETSTL_VER_1_3_7 0x010307ff /*!< Version 1.3.7 (with STLSoft 1.9.119) */ # define _INETSTL_VER_1_3_8 0x010308ff /*!< Version 1.3.8 (with STLSoft 1.9.121) */ -# define _INETSTL_VER_1_4_1_B01 0x01040181 /*!< Version 1.4.1 beta 1 (with STLSoft 1.10.1 beta 1) */ -# define _INETSTL_VER_1_4_1_B02 0x01040182 /*!< Version 1.4.1 beta 2 (with STLSoft 1.10.1 beta 10) */ -# define _INETSTL_VER_1_4_1_B03 0x01040183 /*!< Version 1.4.1 beta 3 (with STLSoft 1.10.1 beta 26) */ +# define _INETSTL_VER_1_4_1_B01 0x01040181 /*!< Version 1.4.1-beta1 (with STLSoft 1.10.1-beta1) */ +# define _INETSTL_VER_1_4_1_B02 0x01040182 /*!< Version 1.4.1-beta2 (with STLSoft 1.10.1-beta10) */ +# define _INETSTL_VER_1_4_1_B03 0x01040183 /*!< Version 1.4.1-beta3 (with STLSoft 1.10.1-beta26) */ # define _INETSTL_VER_1_4_1 0x010401ff /*!< Version 1.4.1 (with STLSoft 1.10.3) */ -# define _INETSTL_VER_1_4_2 0x010402ff /*!< Version 1.4.2 (with STLSoft 1.11.1 alpha 8) */ -# define _INETSTL_VER_1_5_0_A01 0x01050041 /*!< Version 1.5.0 alpha 1 (with STLSoft 1.11.1 beta 2) */ -# define _INETSTL_VER_1_5_0_A02 0x01050042 /*!< Version 1.5.0 alpha 2 (with STLSoft 1.11.1 rc 2) */ -# define _INETSTL_VER_1_5_0_A03 0x01050043 /*!< Version 1.5.0 alpha 3 (with STLSoft 1.11.1 rc 8) */ -# define _INETSTL_VER_1_5_0_A04 0x01050044 /*!< Version 1.5.0 alpha 4 (with STLSoft 1.11.1 rc 9) */ +# define _INETSTL_VER_1_4_2 0x010402ff /*!< Version 1.4.2 (with STLSoft 1.11.1-alpha8) */ +# define _INETSTL_VER_1_5_0_A01 0x01050041 /*!< Version 1.5.0-alpha1 (with STLSoft 1.11.1-beta2) */ +# define _INETSTL_VER_1_5_0_A02 0x01050042 /*!< Version 1.5.0-alpha2 (with STLSoft 1.11.1-rc2) */ +# define _INETSTL_VER_1_5_0_A03 0x01050043 /*!< Version 1.5.0-alpha3 (with STLSoft 1.11.1-rc8) */ +# define _INETSTL_VER_1_5_0_A04 0x01050044 /*!< Version 1.5.0-alpha4 (with STLSoft 1.11.1-rc9) */ # define _INETSTL_VER_1_5_0 0x010500FF /*!< Version 1.5.0 (with STLSoft 1.11.1) */ #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -199,7 +199,7 @@ */ #if _STLSOFT_VER < 0x010B01C9 -# error This version of the InetSTL libraries requires STLSoft version 1.11.1 rc 9, or later +# error This version of the InetSTL libraries requires STLSoft version 1.11.1-rc9, or later #endif /* _STLSOFT_VER */ diff --git a/include/mfcstl/mfcstl.hpp b/include/mfcstl/mfcstl.hpp index 0525521a2..7878eaa7a 100644 --- a/include/mfcstl/mfcstl.hpp +++ b/include/mfcstl/mfcstl.hpp @@ -5,7 +5,7 @@ * and platform discriminations, and definitions of types. * * Created: 15th January 2002 - * Updated: 20th October 2026 + * Updated: 25th October 2026 * * Thanks: To Cláudio Albuquerque for suggesting the inclusion of atlstr.h. * @@ -53,7 +53,7 @@ # define MFCSTL_VER_MFCSTL_HPP_MFCSTL_MAJOR 3 # define MFCSTL_VER_MFCSTL_HPP_MFCSTL_MINOR 5 # define MFCSTL_VER_MFCSTL_HPP_MFCSTL_REVISION 6 -# define MFCSTL_VER_MFCSTL_HPP_MFCSTL_EDIT 112 +# define MFCSTL_VER_MFCSTL_HPP_MFCSTL_EDIT 113 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ /** \file mfcstl/mfcstl.hpp @@ -140,9 +140,9 @@ # define _MFCSTL_VER_1_5_2 0x00010502 /*!< Version 1.5.2 (with STLSoft 1.9.10) */ # define _MFCSTL_VER_1_5_3 0x00010503 /*!< Version 1.5.3 (with STLSoft 1.9.25) */ # define _MFCSTL_VER_1_5_4 0x010504ff /*!< Version 1.5.4 (with STLSoft 1.9.113) */ -# define _MFCSTL_VER_1_6_1_B01 0x01060181 /*!< Version 1.6.1 beta 1 (with STLSoft 1.10.1 beta 1) */ -# define _MFCSTL_VER_1_6_1_B02 0x01060182 /*!< Version 1.6.1 beta 2 (with STLSoft 1.10.1 beta 26) */ -# define _MFCSTL_VER_1_6_1 0x010601ff /*!< Version 1.6.1 (with STLSoft 1.11.1 alpha 8) */ +# define _MFCSTL_VER_1_6_1_B01 0x01060181 /*!< Version 1.6.1-beta1 (with STLSoft 1.10.1-beta1) */ +# define _MFCSTL_VER_1_6_1_B02 0x01060182 /*!< Version 1.6.1-beta2 (with STLSoft 1.10.1-beta26) */ +# define _MFCSTL_VER_1_6_1 0x010601ff /*!< Version 1.6.1 (with STLSoft 1.11.1-alpha8) */ #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ #define _MFCSTL_VER_MAJOR 1 @@ -200,7 +200,7 @@ */ #if _STLSOFT_VER < 0x010a019a -# error This version of the MFCSTL libraries requires STLSoft version 1.10.1 beta 26, or later +# error This version of the MFCSTL libraries requires STLSoft version 1.10.1-beta26, or later #endif /* _STLSOFT_VER */ /* ///////////////////////////////////////////////////////////////////////// diff --git a/include/platformstl/platformstl.h b/include/platformstl/platformstl.h index 663c40c1f..7a8af12a2 100644 --- a/include/platformstl/platformstl.h +++ b/include/platformstl/platformstl.h @@ -5,7 +5,7 @@ * platform discriminations, and definitions of types. * * Created: 20th March 2005 - * Updated: 21st October 2026 + * Updated: 25th October 2026 * * Home: http://stlsoft.org/ * @@ -50,7 +50,7 @@ # define PLATFORMSTL_VER_PLATFORMSTL_H_PLATFORMSTL_MAJOR 1 # define PLATFORMSTL_VER_PLATFORMSTL_H_PLATFORMSTL_MINOR 15 # define PLATFORMSTL_VER_PLATFORMSTL_H_PLATFORMSTL_REVISION 10 -# define PLATFORMSTL_VER_PLATFORMSTL_H_PLATFORMSTL_EDIT 67 +# define PLATFORMSTL_VER_PLATFORMSTL_H_PLATFORMSTL_EDIT 68 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ /** \file platformstl/platformstl.h @@ -138,17 +138,17 @@ # define _PLATFORMSTL_VER_1_8_2 0x010802ff /*!< Version 1.8.2 (with STLSoft 1.9.90) */ # define _PLATFORMSTL_VER_1_8_3 0x010803ff /*!< Version 1.8.3 (with STLSoft 1.9.110) */ # define _PLATFORMSTL_VER_1_8_4 0x010804ff /*!< Version 1.8.4 (with STLSoft 1.9.119) */ -# define _PLATFORMSTL_VER_1_9_1_B01 0x01090181 /*!< Version 1.9.1 beta 1 (with STLSoft 1.10.1 beta 1) */ -# define _PLATFORMSTL_VER_1_9_1_B02 0x01090182 /*!< Version 1.9.1 beta 2 (with STLSoft 1.10.1 beta 16) */ -# define _PLATFORMSTL_VER_1_9_1_B03 0x01090183 /*!< Version 1.9.1 beta 3 (with STLSoft 1.10.1 beta 23) */ -# define _PLATFORMSTL_VER_1_9_1_B04 0x01090184 /*!< Version 1.9.1 beta 4 (with STLSoft 1.10.1 beta 26) */ +# define _PLATFORMSTL_VER_1_9_1_B01 0x01090181 /*!< Version 1.9.1-beta1 (with STLSoft 1.10.1-beta1) */ +# define _PLATFORMSTL_VER_1_9_1_B02 0x01090182 /*!< Version 1.9.1-beta2 (with STLSoft 1.10.1-beta16) */ +# define _PLATFORMSTL_VER_1_9_1_B03 0x01090183 /*!< Version 1.9.1-beta3 (with STLSoft 1.10.1-beta23) */ +# define _PLATFORMSTL_VER_1_9_1_B04 0x01090184 /*!< Version 1.9.1-beta4 (with STLSoft 1.10.1-beta26) */ # define _PLATFORMSTL_VER_1_9_2 0x010902ff /*!< Version 1.9.2 (with STLSoft 1.10.5) */ -# define _PLATFORMSTL_VER_1_9_3 0x010903ff /*!< Version 1.9.3 (with STLSoft 1.11.1 alpha 8) */ -# define _PLATFORMSTL_VER_1_10_0_A01 0x010a0041 /*!< Version 1.10.0 alpha 1 (with STLSoft 1.11.1 alpha 15) */ -# define _PLATFORMSTL_VER_1_10_0_B01 0x010A0081 /*!< Version 1.10.0 beta 1 (with STLSoft 1.11.1 rc 3) */ -# define _PLATFORMSTL_VER_1_10_0_B02 0x010A0082 /*!< Version 1.10.0 beta 2 (with STLSoft 1.11.1 rc 8) */ -# define _PLATFORMSTL_VER_1_10_0_B03 0x010A0083 /*!< Version 1.10.0 beta 3 (with STLSoft 1.11.1 rc 9) */ -# define _PLATFORMSTL_VER_1_10_0 0x010A00FF /*!< Version 1.10.0 beta 3 (with STLSoft 1.11.1) */ +# define _PLATFORMSTL_VER_1_9_3 0x010903ff /*!< Version 1.9.3 (with STLSoft 1.11.1-alpha8) */ +# define _PLATFORMSTL_VER_1_10_0_A01 0x010a0041 /*!< Version 1.10.0-alpha1 (with STLSoft 1.11.1-alpha15) */ +# define _PLATFORMSTL_VER_1_10_0_B01 0x010A0081 /*!< Version 1.10.0-beta1 (with STLSoft 1.11.1-rc3) */ +# define _PLATFORMSTL_VER_1_10_0_B02 0x010A0082 /*!< Version 1.10.0-beta2 (with STLSoft 1.11.1-rc8) */ +# define _PLATFORMSTL_VER_1_10_0_B03 0x010A0083 /*!< Version 1.10.0-beta3 (with STLSoft 1.11.1-rc9) */ +# define _PLATFORMSTL_VER_1_10_0 0x010A00FF /*!< Version 1.10.0-beta3 (with STLSoft 1.11.1) */ #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ #define _PLATFORMSTL_VER_MAJOR 1 @@ -187,7 +187,7 @@ */ #if _STLSOFT_VER < 0x010a019a -# error This version of the PlatformSTL libraries requires STLSoft version 1.10.1 beta 26, or later +# error This version of the PlatformSTL libraries requires STLSoft version 1.10.1-beta26, or later #endif /* _STLSOFT_VER */ diff --git a/include/rangelib/rangelib.hpp b/include/rangelib/rangelib.hpp index de90526ac..1fd2a66bb 100644 --- a/include/rangelib/rangelib.hpp +++ b/include/rangelib/rangelib.hpp @@ -4,7 +4,7 @@ * Purpose: Root header for the STLSoft implementation of RangeLib. * * Created: 12th October 2004 - * Updated: 20th October 2026 + * Updated: 25th October 2026 * * Home: http://stlsoft.org/ * @@ -48,7 +48,7 @@ # define RANGELIB_VER_RANGELIB_HPP_RANGELIB_MAJOR 1 # define RANGELIB_VER_RANGELIB_HPP_RANGELIB_MINOR 4 # define RANGELIB_VER_RANGELIB_HPP_RANGELIB_REVISION 4 -# define RANGELIB_VER_RANGELIB_HPP_RANGELIB_EDIT 43 +# define RANGELIB_VER_RANGELIB_HPP_RANGELIB_EDIT 44 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ /** \file rangelib/rangelib.hpp @@ -135,7 +135,7 @@ # define _RANGELIB_VER_1_1_1 0x00010101 /*!< Version 1.1.1 (with STLSoft 1.9.1) */ # define _RANGELIB_VER_1_1_2 0x00010102 /*!< Version 1.1.2 (with STLSoft 1.9.25) */ # define _RANGELIB_VER_1_1_3 0x010103ff /*!< Version 1.1.3 (with STLSoft 1.9.113) */ -# define _RANGELIB_VER_1_1_4 0x010103ff /*!< Version 1.1.4 (with STLSoft 1.11.1 alpha 8) */ +# define _RANGELIB_VER_1_1_4 0x010103ff /*!< Version 1.1.4 (with STLSoft 1.11.1-alpha8) */ #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ #define _RANGELIB_VER_MAJOR 1 @@ -185,7 +185,7 @@ STLSOFT_COMPILER_IS_MSVC: _MSC_VER < 1200 */ #if _STLSOFT_VER < 0x010a0181 -# error This version of the RangeLib libraries requires STLSoft version 1.10.1 beta 1, or later +# error This version of the RangeLib libraries requires STLSoft version 1.10.1-beta1, or later #endif /* _STLSOFT_VER */ /* ///////////////////////////////////////////////////////////////////////// diff --git a/include/stlsoft/stlsoft.h b/include/stlsoft/stlsoft.h index 4489c2e76..dc2a2d78c 100644 --- a/include/stlsoft/stlsoft.h +++ b/include/stlsoft/stlsoft.h @@ -55,8 +55,8 @@ #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION # define STLSOFT_VER_STLSOFT_H_STLSOFT_MAJOR 3 # define STLSOFT_VER_STLSOFT_H_STLSOFT_MINOR 57 -# define STLSOFT_VER_STLSOFT_H_STLSOFT_REVISION 23 -# define STLSOFT_VER_STLSOFT_H_STLSOFT_EDIT 613 +# define STLSOFT_VER_STLSOFT_H_STLSOFT_REVISION 24 +# define STLSOFT_VER_STLSOFT_H_STLSOFT_EDIT 614 #else /* ? STLSOFT_DOCUMENTATION_SKIP_SECTION */ /* # include "./internal/doxygen_defs.h" */ #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -188,20 +188,20 @@ # define _STLSOFT_VER_1_8_7 0x00010807 /*!< Version 1.8.7 */ # define _STLSOFT_VER_1_8_8 0x00010808 /*!< Version 1.8.8 */ # define _STLSOFT_VER_1_8_9 0x00010809 /*!< Version 1.8.9 */ -# define _STLSOFT_VER_1_9_1_B13 0x0109010d /*!< Version 1.9.1 beta 13 (10th Jul 2006) */ -# define _STLSOFT_VER_1_9_1_B20 0x01090114 /*!< Version 1.9.1 beta 20 (28th Aug 2006) */ -# define _STLSOFT_VER_1_9_1_B22 0x01090116 /*!< Version 1.9.1 beta 22 (13th Sep 2006) */ -# define _STLSOFT_VER_1_9_1_B28 0x0109011c /*!< Version 1.9.1 beta 28 (29th Oct 2006) */ -# define _STLSOFT_VER_1_9_1_B29 0x0109011d /*!< Version 1.9.1 beta 29 (27th Nov 2006) */ -# define _STLSOFT_VER_1_9_1_B33 0x01090121 /*!< Version 1.9.1 beta 33 (13th Dec 2006) */ -# define _STLSOFT_VER_1_9_1_B34 0x01090122 /*!< Version 1.9.1 beta 34 (24th Dec 2006) */ -# define _STLSOFT_VER_1_9_1_B37 0x01090125 /*!< Version 1.9.1 beta 37 (30th Dec 2006) */ -# define _STLSOFT_VER_1_9_1_B40 0x01090128 /*!< Version 1.9.1 beta 40 (6th Jan 2007) */ -# define _STLSOFT_VER_1_9_1_B41 0x01090129 /*!< Version 1.9.1 beta 41 (14th Jan 2007) */ -# define _STLSOFT_VER_1_9_1_B42 0x0109012a /*!< Version 1.9.1 beta 42 (15th Jan 2007) */ -# define _STLSOFT_VER_1_9_1_B45 0x0109012d /*!< Version 1.9.1 beta 45 (1st Mar 2007) */ -# define _STLSOFT_VER_1_9_1_B47 0x0109012f /*!< Version 1.9.1 beta 47 (6th Apr 2007) */ -# define _STLSOFT_VER_1_9_1_B48 0x01090130 /*!< Version 1.9.1 beta 48 (12th Apr 2007) */ +# define _STLSOFT_VER_1_9_1_B13 0x0109010d /*!< Version 1.9.1-beta13 (10th Jul 2006) */ +# define _STLSOFT_VER_1_9_1_B20 0x01090114 /*!< Version 1.9.1-beta20 (28th Aug 2006) */ +# define _STLSOFT_VER_1_9_1_B22 0x01090116 /*!< Version 1.9.1-beta22 (13th Sep 2006) */ +# define _STLSOFT_VER_1_9_1_B28 0x0109011c /*!< Version 1.9.1-beta28 (29th Oct 2006) */ +# define _STLSOFT_VER_1_9_1_B29 0x0109011d /*!< Version 1.9.1-beta29 (27th Nov 2006) */ +# define _STLSOFT_VER_1_9_1_B33 0x01090121 /*!< Version 1.9.1-beta33 (13th Dec 2006) */ +# define _STLSOFT_VER_1_9_1_B34 0x01090122 /*!< Version 1.9.1-beta34 (24th Dec 2006) */ +# define _STLSOFT_VER_1_9_1_B37 0x01090125 /*!< Version 1.9.1-beta37 (30th Dec 2006) */ +# define _STLSOFT_VER_1_9_1_B40 0x01090128 /*!< Version 1.9.1-beta40 (6th Jan 2007) */ +# define _STLSOFT_VER_1_9_1_B41 0x01090129 /*!< Version 1.9.1-beta41 (14th Jan 2007) */ +# define _STLSOFT_VER_1_9_1_B42 0x0109012a /*!< Version 1.9.1-beta42 (15th Jan 2007) */ +# define _STLSOFT_VER_1_9_1_B45 0x0109012d /*!< Version 1.9.1-beta45 (1st Mar 2007) */ +# define _STLSOFT_VER_1_9_1_B47 0x0109012f /*!< Version 1.9.1-beta47 (6th Apr 2007) */ +# define _STLSOFT_VER_1_9_1_B48 0x01090130 /*!< Version 1.9.1-beta48 (12th Apr 2007) */ # define _STLSOFT_VER_1_9_1 0x010901ff /*!< Version 1.9.1 (30th Apr 2007) */ # define _STLSOFT_VER_1_9_2 0x010902ff /*!< Version 1.9.2 (2nd Jun 2007) */ # define _STLSOFT_VER_1_9_3 0x010903ff /*!< Version 1.9.3 (29th Jul 2007) */ @@ -331,41 +331,41 @@ # define _STLSOFT_VER_1_9_130 0x010982ff /*!< Version 1.9.130 (1st October 2016) */ # define _STLSOFT_VER_1_9_131 0x010983ff /*!< Version 1.9.131 (1st October 2016) */ -# define _STLSOFT_VER_1_10_1_B01 0x010a0181 /*!< Version 1.10.1 beta 1 (13th January 2017) */ -# define _STLSOFT_VER_1_10_1_B02 0x010a0182 /*!< Version 1.10.1 beta 2 (28th January 2017) */ -# define _STLSOFT_VER_1_10_1_B03 0x010a0183 /*!< Version 1.10.1 beta 3 (15th February 2017) */ -# define _STLSOFT_VER_1_10_1_B04 0x010a0184 /*!< Version 1.10.1 beta 4 (23rd March 2017) */ -# define _STLSOFT_VER_1_10_1_B05 0x010a0185 /*!< Version 1.10.1 beta 5 (15th May 2017) */ -# define _STLSOFT_VER_1_10_1_B06 0x010a0186 /*!< Version 1.10.1 beta 6 (8th June 2018) */ -# define _STLSOFT_VER_1_10_1_B07 0x010a0187 /*!< Version 1.10.1 beta 7 (9th June 2018) */ -# define _STLSOFT_VER_1_10_1_B08 0x010a0188 /*!< Version 1.10.1 beta 8 (11th June 2018) */ -# define _STLSOFT_VER_1_10_1_B09 0x010a0189 /*!< Version 1.10.1 beta 9 (11th June 2018) */ -# define _STLSOFT_VER_1_10_1_B10 0x010a018a /*!< Version 1.10.1 beta 10 (20th December 2018) */ -# define _STLSOFT_VER_1_10_1_B11 0x010a018b /*!< Version 1.10.1 beta 11 (22nd December 2018) */ -# define _STLSOFT_VER_1_10_1_B12 0x010a018c /*!< Version 1.10.1 beta 12 (26th December 2018) */ -# define _STLSOFT_VER_1_10_1_B13 0x010a018d /*!< Version 1.10.1 beta 13 (3rd February 2019) */ -# define _STLSOFT_VER_1_10_1_B14 0x010a018e /*!< Version 1.10.1 beta 14 (4th August 2019) */ -# define _STLSOFT_VER_1_10_1_B15 0x010a018f /*!< Version 1.10.1 beta 15 (13th September 2019) */ -# define _STLSOFT_VER_1_10_1_B16 0x010a0190 /*!< Version 1.10.1 beta 16 (13th October 2019) */ -# define _STLSOFT_VER_1_10_1_B17 0x010a0191 /*!< Version 1.10.1 beta 17 (24th October 2019) */ -# define _STLSOFT_VER_1_10_1_B18 0x010a0192 /*!< Version 1.10.1 beta 18 (31st October 2019) */ -# define _STLSOFT_VER_1_10_1_B19 0x010a0193 /*!< Version 1.10.1 beta 19 (4th July 2020) */ -# define _STLSOFT_VER_1_10_1_B20 0x010a0194 /*!< Version 1.10.1 beta 20 (5th July 2020) */ -# define _STLSOFT_VER_1_10_1_B21 0x010a0195 /*!< Version 1.10.1 beta 21 (27th July 2020) */ -# define _STLSOFT_VER_1_10_1_B22 0x010a0196 /*!< Version 1.10.1 beta 22 (29th November 2020) */ -# define _STLSOFT_VER_1_10_1_B23 0x010a0197 /*!< Version 1.10.1 beta 23 (13th December 2020) */ -# define _STLSOFT_VER_1_10_1_B24 0x010a0198 /*!< Version 1.10.1 beta 24 (13th December 2020) */ -# define _STLSOFT_VER_1_10_1_B25 0x010a0199 /*!< Version 1.10.1 beta 25 (14th December 2020) */ -# define _STLSOFT_VER_1_10_1_B26 0x010a019a /*!< Version 1.10.1 beta 26 (18th December 2020) */ -# define _STLSOFT_VER_1_10_1_B27 0x010a019b /*!< Version 1.10.1 beta 27 (11th January 2021) */ -# define _STLSOFT_VER_1_10_1_B28 0x010a019c /*!< Version 1.10.1 beta 28 (18th January 2021) */ -# define _STLSOFT_VER_1_10_1_B29 0x010a019d /*!< Version 1.10.1 beta 29 (26th January 2021) */ -# define _STLSOFT_VER_1_10_1_B30 0x010a019e /*!< Version 1.10.1 beta 30 (29th March 2021) */ -# define _STLSOFT_VER_1_10_1_B31 0x010a019f /*!< Version 1.10.1 beta 31 (2nd April 2021) */ -# define _STLSOFT_VER_1_10_1_B32 0x010a01a0 /*!< Version 1.10.1 beta 32 (26th April 2021) */ -# define _STLSOFT_VER_1_10_1_B33 0x010a01a1 /*!< Version 1.10.1 beta 33 (26th April 2021) */ -# define _STLSOFT_VER_1_10_1_B34 0x010a01a2 /*!< Version 1.10.1 beta 34 (26th April 2021) */ -# define _STLSOFT_VER_1_10_1_B35 0x010a01a3 /*!< Version 1.10.1 beta 35 (1st December 2023) */ +# define _STLSOFT_VER_1_10_1_B01 0x010a0181 /*!< Version 1.10.1-beta1 (13th January 2017) */ +# define _STLSOFT_VER_1_10_1_B02 0x010a0182 /*!< Version 1.10.1-beta2 (28th January 2017) */ +# define _STLSOFT_VER_1_10_1_B03 0x010a0183 /*!< Version 1.10.1-beta3 (15th February 2017) */ +# define _STLSOFT_VER_1_10_1_B04 0x010a0184 /*!< Version 1.10.1-beta4 (23rd March 2017) */ +# define _STLSOFT_VER_1_10_1_B05 0x010a0185 /*!< Version 1.10.1-beta5 (15th May 2017) */ +# define _STLSOFT_VER_1_10_1_B06 0x010a0186 /*!< Version 1.10.1-beta6 (8th June 2018) */ +# define _STLSOFT_VER_1_10_1_B07 0x010a0187 /*!< Version 1.10.1-beta7 (9th June 2018) */ +# define _STLSOFT_VER_1_10_1_B08 0x010a0188 /*!< Version 1.10.1-beta8 (11th June 2018) */ +# define _STLSOFT_VER_1_10_1_B09 0x010a0189 /*!< Version 1.10.1-beta9 (11th June 2018) */ +# define _STLSOFT_VER_1_10_1_B10 0x010a018a /*!< Version 1.10.1-beta10 (20th December 2018) */ +# define _STLSOFT_VER_1_10_1_B11 0x010a018b /*!< Version 1.10.1-beta11 (22nd December 2018) */ +# define _STLSOFT_VER_1_10_1_B12 0x010a018c /*!< Version 1.10.1-beta12 (26th December 2018) */ +# define _STLSOFT_VER_1_10_1_B13 0x010a018d /*!< Version 1.10.1-beta13 (3rd February 2019) */ +# define _STLSOFT_VER_1_10_1_B14 0x010a018e /*!< Version 1.10.1-beta14 (4th August 2019) */ +# define _STLSOFT_VER_1_10_1_B15 0x010a018f /*!< Version 1.10.1-beta15 (13th September 2019) */ +# define _STLSOFT_VER_1_10_1_B16 0x010a0190 /*!< Version 1.10.1-beta16 (13th October 2019) */ +# define _STLSOFT_VER_1_10_1_B17 0x010a0191 /*!< Version 1.10.1-beta17 (24th October 2019) */ +# define _STLSOFT_VER_1_10_1_B18 0x010a0192 /*!< Version 1.10.1-beta18 (31st October 2019) */ +# define _STLSOFT_VER_1_10_1_B19 0x010a0193 /*!< Version 1.10.1-beta19 (4th July 2020) */ +# define _STLSOFT_VER_1_10_1_B20 0x010a0194 /*!< Version 1.10.1-beta20 (5th July 2020) */ +# define _STLSOFT_VER_1_10_1_B21 0x010a0195 /*!< Version 1.10.1-beta21 (27th July 2020) */ +# define _STLSOFT_VER_1_10_1_B22 0x010a0196 /*!< Version 1.10.1-beta22 (29th November 2020) */ +# define _STLSOFT_VER_1_10_1_B23 0x010a0197 /*!< Version 1.10.1-beta23 (13th December 2020) */ +# define _STLSOFT_VER_1_10_1_B24 0x010a0198 /*!< Version 1.10.1-beta24 (13th December 2020) */ +# define _STLSOFT_VER_1_10_1_B25 0x010a0199 /*!< Version 1.10.1-beta25 (14th December 2020) */ +# define _STLSOFT_VER_1_10_1_B26 0x010a019a /*!< Version 1.10.1-beta26 (18th December 2020) */ +# define _STLSOFT_VER_1_10_1_B27 0x010a019b /*!< Version 1.10.1-beta27 (11th January 2021) */ +# define _STLSOFT_VER_1_10_1_B28 0x010a019c /*!< Version 1.10.1-beta28 (18th January 2021) */ +# define _STLSOFT_VER_1_10_1_B29 0x010a019d /*!< Version 1.10.1-beta29 (26th January 2021) */ +# define _STLSOFT_VER_1_10_1_B30 0x010a019e /*!< Version 1.10.1-beta30 (29th March 2021) */ +# define _STLSOFT_VER_1_10_1_B31 0x010a019f /*!< Version 1.10.1-beta31 (2nd April 2021) */ +# define _STLSOFT_VER_1_10_1_B32 0x010a01a0 /*!< Version 1.10.1-beta32 (26th April 2021) */ +# define _STLSOFT_VER_1_10_1_B33 0x010a01a1 /*!< Version 1.10.1-beta33 (26th April 2021) */ +# define _STLSOFT_VER_1_10_1_B34 0x010a01a2 /*!< Version 1.10.1-beta34 (26th April 2021) */ +# define _STLSOFT_VER_1_10_1_B35 0x010a01a3 /*!< Version 1.10.1-beta35 (1st December 2023) */ # define _STLSOFT_VER_1_10_1 0x010a01ff /*!< Version 1.10.1 (13th December 2023) */ # define _STLSOFT_VER_1_10_2 0x010a02ff /*!< Version 1.10.2 (3rd January 2024) */ # define _STLSOFT_VER_1_10_3 0x010a03ff /*!< Version 1.10.3 (12th January 2024) */ @@ -378,61 +378,61 @@ # define _STLSOFT_VER_1_10_10 0x010a0aff /*!< Version 1.10.10 (16th February 2024) */ # define _STLSOFT_VER_1_10_11 0x010a0bff /*!< Version 1.10.11 (16th February 2024) */ -# define _STLSOFT_VER_1_11_1_A01 0x010b0141 /*!< Version 1.11.1 alpha 1 (20th February 2024) */ -# define _STLSOFT_VER_1_11_1_A02 0x010b0142 /*!< Version 1.11.1 alpha 2 (1st March 2024) */ -# define _STLSOFT_VER_1_11_1_A03 0x010b0143 /*!< Version 1.11.1 alpha 3 (16th March 2024) */ -# define _STLSOFT_VER_1_11_1_A04 0x010b0144 /*!< Version 1.11.1 alpha 4 (18th March 2024) */ -# define _STLSOFT_VER_1_11_1_A05 0x010b0145 /*!< Version 1.11.1 alpha 5 (29th March 2024) */ -# define _STLSOFT_VER_1_11_1_A06 0x010b0146 /*!< Version 1.11.1 alpha 6 (29th March 2024) */ -# define _STLSOFT_VER_1_11_1_A07 0x010b0147 /*!< Version 1.11.1 alpha 7 (5th May 2024) */ -# define _STLSOFT_VER_1_11_1_A08 0x010b0148 /*!< Version 1.11.1 alpha 8 (9th July 2024) */ -# define _STLSOFT_VER_1_11_1_A09 0x010b0149 /*!< Version 1.11.1 alpha 9 (9th July 2024) */ -# define _STLSOFT_VER_1_11_1_A10 0x010b014a /*!< Version 1.11.1 alpha 10 (14th July 2024) */ -# define _STLSOFT_VER_1_11_1_A11 0x010b014b /*!< Version 1.11.1 alpha 11 (16th July 2024) */ -# define _STLSOFT_VER_1_11_1_A12 0x010b014c /*!< Version 1.11.1 alpha 12 (3rd August 2024) */ -# define _STLSOFT_VER_1_11_1_A13 0x010b014d /*!< Version 1.11.1 alpha 13 (4th August 2024) */ -# define _STLSOFT_VER_1_11_1_A14 0x010b014e /*!< Version 1.11.1 alpha 14 (21st August 2024) */ -# define _STLSOFT_VER_1_11_1_A15 0x010b014e /*!< Version 1.11.1 alpha 15 (2nd September 2024) */ -# define _STLSOFT_VER_1_11_1_A16 0x010b0150 /*!< Version 1.11.1 alpha 16 (1st October 2024) */ -# define _STLSOFT_VER_1_11_1_A17 0x010b0151 /*!< Version 1.11.1 alpha 17 (10th October 2024) */ -# define _STLSOFT_VER_1_11_1_A18 0x010b0152 /*!< Version 1.11.1 alpha 18 (15th October 2024) */ -# define _STLSOFT_VER_1_11_1_A19 0x010b0153 /*!< Version 1.11.1 alpha 19 (23rd October 2024) */ -# define _STLSOFT_VER_1_11_1_A20 0x010b0154 /*!< Version 1.11.1 alpha 20 (23rd October 2024) */ -# define _STLSOFT_VER_1_11_1_A21 0x010b0155 /*!< Version 1.11.1 alpha 21 (25th October 2024) */ -# define _STLSOFT_VER_1_11_1_A22 0x010b0156 /*!< Version 1.11.1 alpha 22 (26th October 2024) */ -# define _STLSOFT_VER_1_11_1_A23 0x010b0157 /*!< Version 1.11.1 alpha 23 (26th October 2024) */ -# define _STLSOFT_VER_1_11_1_A24 0x010b0158 /*!< Version 1.11.1 alpha 24 (4th November 2024) */ -# define _STLSOFT_VER_1_11_1_A25 0x010b0159 /*!< Version 1.11.1 alpha 25 (18th November 2024) */ -# define _STLSOFT_VER_1_11_1_A26 0x010b015a /*!< Version 1.11.1 alpha 26 (23rd November 2024) */ -# define _STLSOFT_VER_1_11_1_A27 0x010b015b /*!< Version 1.11.1 alpha 27 (19th December 2024) */ -# define _STLSOFT_VER_1_11_1_A28 0x010b015c /*!< Version 1.11.1 alpha 28 (28th December 2024) */ -# define _STLSOFT_VER_1_11_1_B1 0x010b0181 /*!< Version 1.11.1 beta 1 (31st December 2024) */ -# define _STLSOFT_VER_1_11_1_B2 0x010b0182 /*!< Version 1.11.1 beta 2 (21st February 2025) */ -# define _STLSOFT_VER_1_11_1_B3 0x010b0183 /*!< Version 1.11.1 beta 3 (15th April 2025) */ -# define _STLSOFT_VER_1_11_1_B4 0x010b0184 /*!< Version 1.11.1 beta 4 (22nd April 2025) */ -# define _STLSOFT_VER_1_11_1_B5 0x010b0185 /*!< Version 1.11.1 beta 5 (26th April 2025) */ -# define _STLSOFT_VER_1_11_1_B6 0x010b0186 /*!< Version 1.11.1 beta 6 (28th April 2025) */ -# define _STLSOFT_VER_1_11_1_B7 0x010b0187 /*!< Version 1.11.1 beta 7 (30th April 2025) */ -# define _STLSOFT_VER_1_11_1_B8 0x010b0188 /*!< Version 1.11.1 beta 8 (3rd May 2025) */ -# define _STLSOFT_VER_1_11_1_B9 0x010b0189 /*!< Version 1.11.1 beta 9 (5th May 2025) */ -# define _STLSOFT_VER_1_11_1_RC1 0x010b01c1 /*!< Version 1.11.1 rc 1 (6th May 2025) */ -# define _STLSOFT_VER_1_11_1_RC2 0x010b01c2 /*!< Version 1.11.1 rc 2 (31st May 2025) */ -# define _STLSOFT_VER_1_11_1_RC3 0x010b01c3 /*!< Version 1.11.1 rc 3 (23rd August 2025) */ -# define _STLSOFT_VER_1_11_1_RC4 0x010b01c4 /*!< Version 1.11.1 rc 4 (1st July 2026) */ -# define _STLSOFT_VER_1_11_1_RC5 0x010b01c5 /*!< Version 1.11.1 rc 5 (4th August 2026) */ -# define _STLSOFT_VER_1_11_1_RC6 0x010b01c6 /*!< Version 1.11.1 rc 6 (21st September 2026) */ -# define _STLSOFT_VER_1_11_1_RC7 0x010B01C7 /*!< Version 1.11.1 rc 7 (30th September 2026) */ -# define _STLSOFT_VER_1_11_1_RC8 0x010B01C8 /*!< Version 1.11.1 rc 8 (10th October 2026) */ -# define _STLSOFT_VER_1_11_1_RC9 0x010B01C9 /*!< Version 1.11.1 rc 9 (18th October 2026) */ -# define _STLSOFT_VER_1_11_1_RC10 0x010B01CA /*!< Version 1.11.1 rc 10 (20th October 2026) */ +# define _STLSOFT_VER_1_11_1_A01 0x010b0141 /*!< Version 1.11.1-alpha1 (20th February 2024) */ +# define _STLSOFT_VER_1_11_1_A02 0x010b0142 /*!< Version 1.11.1-alpha2 (1st March 2024) */ +# define _STLSOFT_VER_1_11_1_A03 0x010b0143 /*!< Version 1.11.1-alpha3 (16th March 2024) */ +# define _STLSOFT_VER_1_11_1_A04 0x010b0144 /*!< Version 1.11.1-alpha4 (18th March 2024) */ +# define _STLSOFT_VER_1_11_1_A05 0x010b0145 /*!< Version 1.11.1-alpha5 (29th March 2024) */ +# define _STLSOFT_VER_1_11_1_A06 0x010b0146 /*!< Version 1.11.1-alpha6 (29th March 2024) */ +# define _STLSOFT_VER_1_11_1_A07 0x010b0147 /*!< Version 1.11.1-alpha7 (5th May 2024) */ +# define _STLSOFT_VER_1_11_1_A08 0x010b0148 /*!< Version 1.11.1-alpha8 (9th July 2024) */ +# define _STLSOFT_VER_1_11_1_A09 0x010b0149 /*!< Version 1.11.1-alpha9 (9th July 2024) */ +# define _STLSOFT_VER_1_11_1_A10 0x010b014a /*!< Version 1.11.1-alpha10 (14th July 2024) */ +# define _STLSOFT_VER_1_11_1_A11 0x010b014b /*!< Version 1.11.1-alpha11 (16th July 2024) */ +# define _STLSOFT_VER_1_11_1_A12 0x010b014c /*!< Version 1.11.1-alpha12 (3rd August 2024) */ +# define _STLSOFT_VER_1_11_1_A13 0x010b014d /*!< Version 1.11.1-alpha13 (4th August 2024) */ +# define _STLSOFT_VER_1_11_1_A14 0x010b014e /*!< Version 1.11.1-alpha14 (21st August 2024) */ +# define _STLSOFT_VER_1_11_1_A15 0x010b014e /*!< Version 1.11.1-alpha15 (2nd September 2024) */ +# define _STLSOFT_VER_1_11_1_A16 0x010b0150 /*!< Version 1.11.1-alpha16 (1st October 2024) */ +# define _STLSOFT_VER_1_11_1_A17 0x010b0151 /*!< Version 1.11.1-alpha17 (10th October 2024) */ +# define _STLSOFT_VER_1_11_1_A18 0x010b0152 /*!< Version 1.11.1-alpha18 (15th October 2024) */ +# define _STLSOFT_VER_1_11_1_A19 0x010b0153 /*!< Version 1.11.1-alpha19 (23rd October 2024) */ +# define _STLSOFT_VER_1_11_1_A20 0x010b0154 /*!< Version 1.11.1-alpha20 (23rd October 2024) */ +# define _STLSOFT_VER_1_11_1_A21 0x010b0155 /*!< Version 1.11.1-alpha21 (25th October 2024) */ +# define _STLSOFT_VER_1_11_1_A22 0x010b0156 /*!< Version 1.11.1-alpha22 (26th October 2024) */ +# define _STLSOFT_VER_1_11_1_A23 0x010b0157 /*!< Version 1.11.1-alpha23 (26th October 2024) */ +# define _STLSOFT_VER_1_11_1_A24 0x010b0158 /*!< Version 1.11.1-alpha24 (4th November 2024) */ +# define _STLSOFT_VER_1_11_1_A25 0x010b0159 /*!< Version 1.11.1-alpha25 (18th November 2024) */ +# define _STLSOFT_VER_1_11_1_A26 0x010b015a /*!< Version 1.11.1-alpha26 (23rd November 2024) */ +# define _STLSOFT_VER_1_11_1_A27 0x010b015b /*!< Version 1.11.1-alpha27 (19th December 2024) */ +# define _STLSOFT_VER_1_11_1_A28 0x010b015c /*!< Version 1.11.1-alpha28 (28th December 2024) */ +# define _STLSOFT_VER_1_11_1_B1 0x010b0181 /*!< Version 1.11.1-beta1 (31st December 2024) */ +# define _STLSOFT_VER_1_11_1_B2 0x010b0182 /*!< Version 1.11.1-beta2 (21st February 2025) */ +# define _STLSOFT_VER_1_11_1_B3 0x010b0183 /*!< Version 1.11.1-beta3 (15th April 2025) */ +# define _STLSOFT_VER_1_11_1_B4 0x010b0184 /*!< Version 1.11.1-beta4 (22nd April 2025) */ +# define _STLSOFT_VER_1_11_1_B5 0x010b0185 /*!< Version 1.11.1-beta5 (26th April 2025) */ +# define _STLSOFT_VER_1_11_1_B6 0x010b0186 /*!< Version 1.11.1-beta6 (28th April 2025) */ +# define _STLSOFT_VER_1_11_1_B7 0x010b0187 /*!< Version 1.11.1-beta7 (30th April 2025) */ +# define _STLSOFT_VER_1_11_1_B8 0x010b0188 /*!< Version 1.11.1-beta8 (3rd May 2025) */ +# define _STLSOFT_VER_1_11_1_B9 0x010b0189 /*!< Version 1.11.1-beta9 (5th May 2025) */ +# define _STLSOFT_VER_1_11_1_RC1 0x010b01c1 /*!< Version 1.11.1-rc1 (6th May 2025) */ +# define _STLSOFT_VER_1_11_1_RC2 0x010b01c2 /*!< Version 1.11.1-rc2 (31st May 2025) */ +# define _STLSOFT_VER_1_11_1_RC3 0x010b01c3 /*!< Version 1.11.1-rc3 (23rd August 2025) */ +# define _STLSOFT_VER_1_11_1_RC4 0x010b01c4 /*!< Version 1.11.1-rc4 (1st July 2026) */ +# define _STLSOFT_VER_1_11_1_RC5 0x010b01c5 /*!< Version 1.11.1-rc5 (4th August 2026) */ +# define _STLSOFT_VER_1_11_1_RC6 0x010b01c6 /*!< Version 1.11.1-rc6 (21st September 2026) */ +# define _STLSOFT_VER_1_11_1_RC7 0x010B01C7 /*!< Version 1.11.1-rc7 (30th September 2026) */ +# define _STLSOFT_VER_1_11_1_RC8 0x010B01C8 /*!< Version 1.11.1-rc8 (10th October 2026) */ +# define _STLSOFT_VER_1_11_1_RC9 0x010B01C9 /*!< Version 1.11.1-rc9 (18th October 2026) */ +# define _STLSOFT_VER_1_11_1_RC10 0x010B01CA /*!< Version 1.11.1-rc10 (20th October 2026) */ # define _STLSOFT_VER_1_11_1 0x010B01FF /*!< Version 1.11.1 (21st October 2026) */ -# define _STLSOFT_VER_1_11_2_A1 0x010B0241 /*!< Version 1.11.2 alpha 1 (25th October 2026) */ +# define _STLSOFT_VER_1_11_2 0x010B02FF /*!< Version 1.11.2 (25th October 2026) */ #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ #define _STLSOFT_VER_MAJOR 1 #define _STLSOFT_VER_MINOR 11 #define _STLSOFT_VER_PATCH 2 -#define _STLSOFT_VER_RELSTATUS 0x41 +#define _STLSOFT_VER_RELSTATUS 0xFF #define _STLSOFT_VER \ (0\ diff --git a/include/unixstl/filesystem/filesystem_traits.hpp b/include/unixstl/filesystem/filesystem_traits.hpp index ff4b3de32..b17bedde2 100644 --- a/include/unixstl/filesystem/filesystem_traits.hpp +++ b/include/unixstl/filesystem/filesystem_traits.hpp @@ -1757,7 +1757,7 @@ struct filesystem_traits } private: -#if _STLSOFT_VER >= 0x010b0280 +#if _STLSOFT_VER >= 0x010c0000 # error Sort get_root_len_() properly #endif diff --git a/include/unixstl/unixstl.h b/include/unixstl/unixstl.h index 32a22b177..80640bb14 100644 --- a/include/unixstl/unixstl.h +++ b/include/unixstl/unixstl.h @@ -5,7 +5,7 @@ * platform discriminations, and definitions of types. * * Created: 15th January 2002 - * Updated: 21st October 2026 + * Updated: 25th October 2026 * * Home: http://stlsoft.org/ * @@ -51,7 +51,7 @@ # define UNIXSTL_VER_UNIXSTL_H_UNIXSTL_MAJOR 3 # define UNIXSTL_VER_UNIXSTL_H_UNIXSTL_MINOR 11 # define UNIXSTL_VER_UNIXSTL_H_UNIXSTL_REVISION 6 -# define UNIXSTL_VER_UNIXSTL_H_UNIXSTL_EDIT 135 +# define UNIXSTL_VER_UNIXSTL_H_UNIXSTL_EDIT 136 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ /** \file unixstl/unixstl.h @@ -146,25 +146,25 @@ # define _UNIXSTL_VER_1_7_4 0x010704ff /*!< Version 1.7.4 (with STLSoft 1.9.108) */ # define _UNIXSTL_VER_1_7_5 0x010705ff /*!< Version 1.7.5 (with STLSoft 1.9.113) */ # define _UNIXSTL_VER_1_7_6 0x010706ff /*!< Version 1.7.6 (with STLSoft 1.9.119) */ -# define _UNIXSTL_VER_1_8_1_B01 0x01080181 /*!< Version 1.8.1 beta 1 (with STLSoft 1.10.1 beta 1) */ -# define _UNIXSTL_VER_1_8_1_B02 0x01080182 /*!< Version 1.8.1 beta 2 (with STLSoft 1.10.1 beta 23) */ -# define _UNIXSTL_VER_1_8_1_B03 0x01080183 /*!< Version 1.8.1 beta 3 (with STLSoft 1.10.1 beta 25) */ -# define _UNIXSTL_VER_1_8_1_B04 0x01080184 /*!< Version 1.8.1 beta 4 (with STLSoft 1.10.1 beta 26) */ +# define _UNIXSTL_VER_1_8_1_B01 0x01080181 /*!< Version 1.8.1-beta1 (with STLSoft 1.10.1-beta1) */ +# define _UNIXSTL_VER_1_8_1_B02 0x01080182 /*!< Version 1.8.1-beta2 (with STLSoft 1.10.1-beta23) */ +# define _UNIXSTL_VER_1_8_1_B03 0x01080183 /*!< Version 1.8.1-beta3 (with STLSoft 1.10.1-beta25) */ +# define _UNIXSTL_VER_1_8_1_B04 0x01080184 /*!< Version 1.8.1-beta4 (with STLSoft 1.10.1-beta26) */ # define _UNIXSTL_VER_1_8_1 0x010801ff /*!< Version 1.8.1 (with STLSoft 1.10.3) */ # define _UNIXSTL_VER_1_8_2 0x010802ff /*!< Version 1.8.2 (with STLSoft 1.10.4) */ # define _UNIXSTL_VER_1_8_3 0x010803ff /*!< Version 1.8.3 (with STLSoft 1.10.5) */ # define _UNIXSTL_VER_1_8_3 0x010803ff /*!< Version 1.8.3 (with STLSoft 1.10.5) */ -# define _UNIXSTL_VER_1_8_4 0x010804ff /*!< Version 1.8.4 (with STLSoft 1.11.1 alpha 8) */ -# define _UNIXSTL_VER_1_8_5 0x010805ff /*!< Version 1.8.5 (with STLSoft 1.11.1 alpha 12) */ -# define _UNIXSTL_VER_1_8_6_A01 0x01080641 /*!< Version 1.8.8 alpha 1 (with STLSoft 1.11.1 alpha 17) */ -# define _UNIXSTL_VER_1_8_6_B01 0x01080681 /*!< Version 1.8.8 beta 1 (with STLSoft 1.11.1 beta 2) */ -# define _UNIXSTL_VER_1_8_6_B02 0x01080682 /*!< Version 1.8.8 beta 2 (with STLSoft 1.11.1 beta 3) */ -# define _UNIXSTL_VER_1_8_6_B03 0x01080683 /*!< Version 1.8.8 beta 3 (with STLSoft 1.11.1 beta 7) */ -# define _UNIXSTL_VER_1_8_6_B04 0x01080684 /*!< Version 1.8.8 beta 4 (with STLSoft 1.11.1 beta 8) */ -# define _UNIXSTL_VER_1_8_6_B05 0x01080685 /*!< Version 1.8.8 beta 5 (with STLSoft 1.11.1 rc 2) */ -# define _UNIXSTL_VER_1_8_6_B06 0x01080686 /*!< Version 1.8.8 beta 6 (with STLSoft 1.11.1 rc 3) */ -# define _UNIXSTL_VER_1_8_6_B07 0x01080687 /*!< Version 1.8.8 beta 7 (with STLSoft 1.11.1 rc 8) */ -# define _UNIXSTL_VER_1_8_6_B08 0x01080688 /*!< Version 1.8.8 beta 8 (with STLSoft 1.11.1 rc 9) */ +# define _UNIXSTL_VER_1_8_4 0x010804ff /*!< Version 1.8.4 (with STLSoft 1.11.1-alpha8) */ +# define _UNIXSTL_VER_1_8_5 0x010805ff /*!< Version 1.8.5 (with STLSoft 1.11.1-alpha12) */ +# define _UNIXSTL_VER_1_8_6_A01 0x01080641 /*!< Version 1.8.8-alpha1 (with STLSoft 1.11.1-alpha17) */ +# define _UNIXSTL_VER_1_8_6_B01 0x01080681 /*!< Version 1.8.8-beta1 (with STLSoft 1.11.1-beta2) */ +# define _UNIXSTL_VER_1_8_6_B02 0x01080682 /*!< Version 1.8.8-beta2 (with STLSoft 1.11.1-beta3) */ +# define _UNIXSTL_VER_1_8_6_B03 0x01080683 /*!< Version 1.8.8-beta3 (with STLSoft 1.11.1-beta7) */ +# define _UNIXSTL_VER_1_8_6_B04 0x01080684 /*!< Version 1.8.8-beta4 (with STLSoft 1.11.1-beta8) */ +# define _UNIXSTL_VER_1_8_6_B05 0x01080685 /*!< Version 1.8.8-beta5 (with STLSoft 1.11.1-rc2) */ +# define _UNIXSTL_VER_1_8_6_B06 0x01080686 /*!< Version 1.8.8-beta6 (with STLSoft 1.11.1-rc3) */ +# define _UNIXSTL_VER_1_8_6_B07 0x01080687 /*!< Version 1.8.8-beta7 (with STLSoft 1.11.1-rc8) */ +# define _UNIXSTL_VER_1_8_6_B08 0x01080688 /*!< Version 1.8.8-beta8 (with STLSoft 1.11.1-rc9) */ # define _UNIXSTL_VER_1_8_6 0x010806FF /*!< Version 1.8.8 (with STLSoft 1.11.1) */ #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -204,7 +204,7 @@ */ #if _STLSOFT_VER < 0x010B01C9 -# error This version of the UNIXSTL libraries requires STLSoft version 1.11.1 rc 9, or later +# error This version of the UNIXSTL libraries requires STLSoft version 1.11.1-rc9, or later #endif /* _STLSOFT_VER */ diff --git a/include/winstl/winstl.h b/include/winstl/winstl.h index 165ff56a5..d3411b3a4 100644 --- a/include/winstl/winstl.h +++ b/include/winstl/winstl.h @@ -5,7 +5,7 @@ * platform discriminations, and definitions of types. * * Created: 15th January 2002 - * Updated: 21st October 2026 + * Updated: 25th October 2026 * * Home: http://stlsoft.org/ * @@ -51,7 +51,7 @@ # define WINSTL_VER_WINSTL_H_WINSTL_MAJOR 3 # define WINSTL_VER_WINSTL_H_WINSTL_MINOR 18 # define WINSTL_VER_WINSTL_H_WINSTL_REVISION 17 -# define WINSTL_VER_WINSTL_H_WINSTL_EDIT 249 +# define WINSTL_VER_WINSTL_H_WINSTL_EDIT 250 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ /** \file winstl/winstl.h @@ -167,25 +167,25 @@ # define _WINSTL_VER_1_11_10 0x010b0aff /*!< Version 1.11.10 (with STLSoft 1.9.120) */ # define _WINSTL_VER_1_11_11 0x010b0bff /*!< Version 1.11.11 (with STLSoft 1.9.121) */ # define _WINSTL_VER_1_11_12 0x010b0cff /*!< Version 1.11.11 (with STLSoft 1.9.126) */ -# define _WINSTL_VER_1_12_1_B01 0x010c0181 /*!< Version 1.12.1 beta 1 (with STLSoft 1.10.1 beta 1) */ -# define _WINSTL_VER_1_12_1_B02 0x010c0182 /*!< Version 1.12.1 beta 2 (with STLSoft 1.10.1 beta 10) */ -# define _WINSTL_VER_1_12_1_B03 0x010c0183 /*!< Version 1.12.1 beta 3 (with STLSoft 1.10.1 beta 14) */ -# define _WINSTL_VER_1_12_1_B04 0x010c0184 /*!< Version 1.12.1 beta 4 (with STLSoft 1.10.1 beta 14) */ -# define _WINSTL_VER_1_12_1_B05 0x010c0185 /*!< Version 1.12.1 beta 5 (with STLSoft 1.10.1 beta 26) */ +# define _WINSTL_VER_1_12_1_B01 0x010c0181 /*!< Version 1.12.1-beta1 (with STLSoft 1.10.1-beta1) */ +# define _WINSTL_VER_1_12_1_B02 0x010c0182 /*!< Version 1.12.1-beta2 (with STLSoft 1.10.1-beta10) */ +# define _WINSTL_VER_1_12_1_B03 0x010c0183 /*!< Version 1.12.1-beta3 (with STLSoft 1.10.1-beta14) */ +# define _WINSTL_VER_1_12_1_B04 0x010c0184 /*!< Version 1.12.1-beta4 (with STLSoft 1.10.1-beta14) */ +# define _WINSTL_VER_1_12_1_B05 0x010c0185 /*!< Version 1.12.1-beta5 (with STLSoft 1.10.1-beta26) */ # define _WINSTL_VER_1_12_1 0x010c01ff /*!< Version 1.12.1 (with STLSoft 1.10.3) */ -# define _WINSTL_VER_1_12_2 0x010c02ff /*!< Version 1.12.2 (with STLSoft 1.11.1 alpha 7) */ -# define _WINSTL_VER_1_12_3 0x010c03ff /*!< Version 1.12.3 (with STLSoft 1.11.1 alpha 8) */ -# define _WINSTL_VER_1_13_0_A01 0x010d0041 /*!< Version 1.13.0 alpha 1 (with STLSoft 1.11.1 alpha 15) */ -# define _WINSTL_VER_1_13_0_A02 0x010d0042 /*!< Version 1.13.0 alpha 2 (with STLSoft 1.11.1 alpha 17) */ -# define _WINSTL_VER_1_13_0_A03 0x010d0043 /*!< Version 1.13.0 alpha 3 (with STLSoft 1.11.1 alpha 18) */ -# define _WINSTL_VER_1_13_0_A04 0x010d0044 /*!< Version 1.13.0 alpha 4 (with STLSoft 1.11.1 alpha 28) */ -# define _WINSTL_VER_1_13_0_A05 0x010d0045 /*!< Version 1.13.0 alpha 5 (with STLSoft 1.11.1 beta 3) */ -# define _WINSTL_VER_1_13_0_A06 0x010d0046 /*!< Version 1.13.0 alpha 6 (with STLSoft 1.11.1 rc 2) */ -# define _WINSTL_VER_1_13_0_B01 0x010d0081 /*!< Version 1.13.0 beta 1 (with STLSoft 1.11.1 rc 3) */ -# define _WINSTL_VER_1_13_0_B02 0x010d0082 /*!< Version 1.13.0 beta 2 (with STLSoft 1.11.1 rc 4) */ -# define _WINSTL_VER_1_13_0_B03 0x010d0083 /*!< Version 1.13.0 beta 3 (with STLSoft 1.11.1 rc 7) */ -# define _WINSTL_VER_1_13_0_B04 0x010d0084 /*!< Version 1.13.0 beta 4 (with STLSoft 1.11.1 rc 8) */ -# define _WINSTL_VER_1_13_0_B05 0x010d0085 /*!< Version 1.13.0 beta 5 (with STLSoft 1.11.1 rc 9) */ +# define _WINSTL_VER_1_12_2 0x010c02ff /*!< Version 1.12.2 (with STLSoft 1.11.1-alpha7) */ +# define _WINSTL_VER_1_12_3 0x010c03ff /*!< Version 1.12.3 (with STLSoft 1.11.1-alpha8) */ +# define _WINSTL_VER_1_13_0_A01 0x010d0041 /*!< Version 1.13.0-alpha1 (with STLSoft 1.11.1-alpha15) */ +# define _WINSTL_VER_1_13_0_A02 0x010d0042 /*!< Version 1.13.0-alpha2 (with STLSoft 1.11.1-alpha17) */ +# define _WINSTL_VER_1_13_0_A03 0x010d0043 /*!< Version 1.13.0-alpha3 (with STLSoft 1.11.1-alpha18) */ +# define _WINSTL_VER_1_13_0_A04 0x010d0044 /*!< Version 1.13.0-alpha4 (with STLSoft 1.11.1-alpha28) */ +# define _WINSTL_VER_1_13_0_A05 0x010d0045 /*!< Version 1.13.0-alpha5 (with STLSoft 1.11.1-beta3) */ +# define _WINSTL_VER_1_13_0_A06 0x010d0046 /*!< Version 1.13.0-alpha6 (with STLSoft 1.11.1-rc2) */ +# define _WINSTL_VER_1_13_0_B01 0x010d0081 /*!< Version 1.13.0-beta1 (with STLSoft 1.11.1-rc3) */ +# define _WINSTL_VER_1_13_0_B02 0x010d0082 /*!< Version 1.13.0-beta2 (with STLSoft 1.11.1-rc4) */ +# define _WINSTL_VER_1_13_0_B03 0x010d0083 /*!< Version 1.13.0-beta3 (with STLSoft 1.11.1-rc7) */ +# define _WINSTL_VER_1_13_0_B04 0x010d0084 /*!< Version 1.13.0-beta4 (with STLSoft 1.11.1-rc8) */ +# define _WINSTL_VER_1_13_0_B05 0x010d0085 /*!< Version 1.13.0-beta5 (with STLSoft 1.11.1-rc9) */ # define _WINSTL_VER_1_13_0 0x010d00FF /*!< Version 1.13.0 (with STLSoft 1.11.1) */ #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -295,7 +295,7 @@ */ #if _STLSOFT_VER < 0x010B01C9 -# error This version of the WinSTL libraries requires STLSoft version 1.11.1 rc 9, or later +# error This version of the WinSTL libraries requires STLSoft version 1.11.1-rc9, or later #endif /* _STLSOFT_VER */ diff --git a/include/wtlstl/wtlstl.hpp b/include/wtlstl/wtlstl.hpp index e0d1629f4..b4f661d38 100644 --- a/include/wtlstl/wtlstl.hpp +++ b/include/wtlstl/wtlstl.hpp @@ -5,7 +5,7 @@ * platform discriminations, and definitions of types. * * Created: 12th May 2003 - * Updated: 20th October 2026 + * Updated: 25th October 2026 * * Home: http://stlsoft.org/ * @@ -51,7 +51,7 @@ # define _WTLSTL_VER_WTLSTL_HPP_WTLSTL_MAJOR 2 # define _WTLSTL_VER_WTLSTL_HPP_WTLSTL_MINOR 4 # define _WTLSTL_VER_WTLSTL_HPP_WTLSTL_REVISION 3 -# define _WTLSTL_VER_WTLSTL_HPP_WTLSTL_EDIT 64 +# define _WTLSTL_VER_WTLSTL_HPP_WTLSTL_EDIT 65 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ /** \file wtlstl/wtlstl.hpp @@ -125,9 +125,9 @@ #define _WTLSTL_VER_1_1_2 0x00010102 /*!< Version 1.1.2 */ #define _WTLSTL_VER_1_2_1 0x00010201 /*!< Version 1.2.1 */ #define _WTLSTL_VER_1_2_2 0x00010202 /*!< Version 1.2.2 (with STLSoft 1.9.25) */ -#define _WTLSTL_VER_1_2_3 0x00010203 /*!< Version 1.2.3 (with STLSoft 1.10.1 b1) */ -#define _WTLSTL_VER_1_2_4 0x00010204 /*!< Version 1.2.4 (with STLSoft 1.10.1 b 26) */ -#define _WTLSTL_VER_1_2_5 0x00010205 /*!< Version 1.2.5 (with STLSoft 1.11.1 alpha 8) */ +#define _WTLSTL_VER_1_2_3 0x00010203 /*!< Version 1.2.3 (with STLSoft 1.10.1-beta1) */ +#define _WTLSTL_VER_1_2_4 0x00010204 /*!< Version 1.2.4 (with STLSoft 1.10.1-beta26) */ +#define _WTLSTL_VER_1_2_5 0x00010205 /*!< Version 1.2.5 (with STLSoft 1.11.1-alphaß8) */ #define _WTLSTL_VER_MAJOR 1 #define _WTLSTL_VER_MINOR 2 @@ -220,7 +220,7 @@ */ #if _STLSOFT_VER < 0x010a019a -# error This version of the WTLSTL libraries requires STLSoft version 1.10.1 beta 26, or later +# error This version of the WTLSTL libraries requires STLSoft version 1.10.1-beta26, or later #endif /* _STLSOFT_VER */ /* ///////////////////////////////////////////////////////////////////////// diff --git a/strategy/COMPONENTS-INVENTORY.md b/strategy/COMPONENTS-INVENTORY.md index b440753e4..7d0734b3e 100644 --- a/strategy/COMPONENTS-INVENTORY.md +++ b/strategy/COMPONENTS-INVENTORY.md @@ -674,18 +674,18 @@ Bullets matching performance / optimisation / enhancement keywords, for the oper * **1.10.7 - 30th January 2024**: enhanced stream insertion operators, when used with types descended from `std::basic_ios<>`, to observe width and alignment for `stlsoft::basic_shim_string<>`, `stlsoft::basic_simple_string<>`, `stlsoft::basic_static_string`, `stlsoft::basic_string_view`, `stlsoft::stlsoft_C_string_slice_m_t`/`stlsoft::stlsoft_C_string_slice_w_t`; * **1.10.6 - 28th January 2024**: simplification and improvement of CMake handling; * **1.10.2 - 3rd January 2024**: MinGW 64-bit compatibility improvements; -* **1.10.1 beta 26 - 4th January 2021**: (UNIXSTL and WinSTL) basic_path<> added move semantics and get_location() method and made swap() method public, as well as numerous defect fixes and consistency improvements implemented in terms of new Path Classification API; -* **1.10.1 beta 26 - 4th January 2021**: many improvements to GCC compatibility; -* **1.10.1 beta 22 - 29th November 2020**: stlsoft::split() functions enhanced to: return vector of arbitrary length; allow heterogeneous types for the split elements; -* **1.10.1 beta 18 - 31st October 2019**: added stlsoft/system/environment/functions.hpp to enhances stlsoft::environment_variable_exists() with string access shims to support arbitrary string type; -* **1.10.1 beta 17 - 24th October 2019**: improved documentation; -* **1.10.1 beta 15 - 13th September 2019**: various portability improvements to newer compilers; -* **1.10.1 beta 5 - 15th May 2017**: enhanced STLSOFT_SUPPRESS_UNUSED() to work with rvalues; -* **1.10.1 beta 2 - 28th January 2017**: a large number of changes to improve compatibility with UNIX, Clang, GCC, and MinGW; -* **1.10.1 beta 1 - 14th January 2017**: new high-performance conversion functions (based around the extant technology in stlsoft::integer_to_string()): integer_to_decimal_string(), integer_to_hexadecimal_string(), integer_to_octal_string(), integer_to_lc_string(), integer_to_zero_padded_decimal_string(); -* **1.10.1 beta 1 - 14th January 2017**: substantially improved atomic function support; -* **1.10.1 beta 1 - 14th January 2017**: substantially improved spin_mutex class templates and policies; -* **1.10.1 beta 1 - 14th January 2017**: ... and many many other improvements and additions ..; +* **1.10.1-beta26 - 4th January 2021**: (UNIXSTL and WinSTL) basic_path<> added move semantics and get_location() method and made swap() method public, as well as numerous defect fixes and consistency improvements implemented in terms of new Path Classification API; +* **1.10.1-beta26 - 4th January 2021**: many improvements to GCC compatibility; +* **1.10.1-beta22 - 29th November 2020**: stlsoft::split() functions enhanced to: return vector of arbitrary length; allow heterogeneous types for the split elements; +* **1.10.1-beta18 - 31st October 2019**: added stlsoft/system/environment/functions.hpp to enhances stlsoft::environment_variable_exists() with string access shims to support arbitrary string type; +* **1.10.1-beta17 - 24th October 2019**: improved documentation; +* **1.10.1-beta15 - 13th September 2019**: various portability improvements to newer compilers; +* **1.10.1-beta5 - 15th May 2017**: enhanced STLSOFT_SUPPRESS_UNUSED() to work with rvalues; +* **1.10.1-beta2 - 28th January 2017**: a large number of changes to improve compatibility with UNIX, Clang, GCC, and MinGW; +* **1.10.1-beta1 - 14th January 2017**: new high-performance conversion functions (based around the extant technology in stlsoft::integer_to_string()): integer_to_decimal_string(), integer_to_hexadecimal_string(), integer_to_octal_string(), integer_to_lc_string(), integer_to_zero_padded_decimal_string(); +* **1.10.1-beta1 - 14th January 2017**: substantially improved atomic function support; +* **1.10.1-beta1 - 14th January 2017**: substantially improved spin_mutex class templates and policies; +* **1.10.1-beta1 - 14th January 2017**: ... and many many other improvements and additions ..; ## Full inventory diff --git a/test/unit/versions/entry.cpp b/test/unit/versions/entry.cpp index 3702a03d9..0517f2874 100644 --- a/test/unit/versions/entry.cpp +++ b/test/unit/versions/entry.cpp @@ -133,7 +133,7 @@ namespace { static void TEST__STLSOFT_VER() { - TEST_INT_EQ(_STLSOFT_VER_1_11_2_A1, _STLSOFT_VER); + TEST_INT_EQ(_STLSOFT_VER_1_11_2, _STLSOFT_VER); } #ifdef STLSOFT_HAS_ACE From 5fffa1db5e72fd8ec20a1dc792f220e52ca129bf Mon Sep 17 00:00:00 2001 From: synesissoftware Date: Sun, 25 Oct 2026 17:08:59 +1100 Subject: [PATCH 20/22] C-string function fixes (#77) * test(stlsoft): add exhaustive c_string unit tests Cover strnchr, strnicmp, strnistrn, strnpbrkn, strnrchr, and strnstrn, plus each wchar analogue, with C and C++ programs. strnistrn stays on the current inner loop, so the first-character false-match cases fail; * fix(stlsoft): compare each strnistrn character, not only the first The inner loops of stlsoft_C_strnistrn() and stlsoft_C_wcsnistrn() compared *s1 with *s2 on every index, so a first-character hit was treated as a full match. Index the pair, and fold the wide form with towupper. * chore(automated tests): namespace commenting * fix(stlsoft): quiet MSVC C4310 Store high-bit c_string test bytes in unsigned char so MSVC does not warn C4310. --------- Co-authored-by: Matt Wilson --- include/stlsoft/string/c_string/strnistrn.h | 12 +- test/unit/stlsoft/string/CMakeLists.txt | 3 +- .../stlsoft/string/c_string/CMakeLists.txt | 13 + .../string/c_string/strnchr.C/CMakeLists.txt | 2 + .../stlsoft/string/c_string/strnchr.C/entry.c | 254 ++++++++++++ .../string/c_string/strnchr/CMakeLists.txt | 2 + .../stlsoft/string/c_string/strnchr/entry.cpp | 274 +++++++++++++ .../strnicmp.C}/CMakeLists.txt | 0 .../strnicmp.C}/entry.c | 98 ++++- .../strnicmp}/CMakeLists.txt | 0 .../strnicmp}/entry.cpp | 104 ++++- .../c_string/strnistrn.C/CMakeLists.txt | 2 + .../string/c_string/strnistrn.C/entry.c | 354 +++++++++++++++++ .../string/c_string/strnistrn/CMakeLists.txt | 2 + .../string/c_string/strnistrn/entry.cpp | 374 ++++++++++++++++++ .../c_string/strnpbrkn.C/CMakeLists.txt | 2 + .../string/c_string/strnpbrkn.C/entry.c | 325 +++++++++++++++ .../string/c_string/strnpbrkn/CMakeLists.txt | 2 + .../string/c_string/strnpbrkn/entry.cpp | 345 ++++++++++++++++ .../string/c_string/strnrchr.C/CMakeLists.txt | 2 + .../string/c_string/strnrchr.C/entry.c | 254 ++++++++++++ .../string/c_string/strnrchr/CMakeLists.txt | 2 + .../string/c_string/strnrchr/entry.cpp | 274 +++++++++++++ .../string/c_string/strnstrn.C/CMakeLists.txt | 2 + .../string/c_string/strnstrn.C/entry.c | 337 ++++++++++++++++ .../string/c_string/strnstrn/CMakeLists.txt | 2 + .../string/c_string/strnstrn/entry.cpp | 357 +++++++++++++++++ 27 files changed, 3384 insertions(+), 14 deletions(-) create mode 100644 test/unit/stlsoft/string/c_string/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnchr.C/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnchr.C/entry.c create mode 100644 test/unit/stlsoft/string/c_string/strnchr/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnchr/entry.cpp rename test/unit/stlsoft/string/{c_string.strnicmp.C => c_string/strnicmp.C}/CMakeLists.txt (100%) rename test/unit/stlsoft/string/{c_string.strnicmp.C => c_string/strnicmp.C}/entry.c (66%) rename test/unit/stlsoft/string/{c_string.strnicmp => c_string/strnicmp}/CMakeLists.txt (100%) rename test/unit/stlsoft/string/{c_string.strnicmp => c_string/strnicmp}/entry.cpp (67%) create mode 100644 test/unit/stlsoft/string/c_string/strnistrn.C/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnistrn.C/entry.c create mode 100644 test/unit/stlsoft/string/c_string/strnistrn/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnistrn/entry.cpp create mode 100644 test/unit/stlsoft/string/c_string/strnpbrkn.C/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnpbrkn.C/entry.c create mode 100644 test/unit/stlsoft/string/c_string/strnpbrkn/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnpbrkn/entry.cpp create mode 100644 test/unit/stlsoft/string/c_string/strnrchr.C/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnrchr.C/entry.c create mode 100644 test/unit/stlsoft/string/c_string/strnrchr/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnrchr/entry.cpp create mode 100644 test/unit/stlsoft/string/c_string/strnstrn.C/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnstrn.C/entry.c create mode 100644 test/unit/stlsoft/string/c_string/strnstrn/CMakeLists.txt create mode 100644 test/unit/stlsoft/string/c_string/strnstrn/entry.cpp diff --git a/include/stlsoft/string/c_string/strnistrn.h b/include/stlsoft/string/c_string/strnistrn.h index 4eb48d7e7..eebd4b16b 100644 --- a/include/stlsoft/string/c_string/strnistrn.h +++ b/include/stlsoft/string/c_string/strnistrn.h @@ -4,11 +4,11 @@ * Purpose: Definition of stlsoft_C_strnistrn() and stlsoft_C_wcsnistrn() * * Created: 1st October 2020 - * Updated: 11th March 2024 + * Updated: 23rd October 2026 * * Home: http://stlsoft.org/ * - * Copyright (c) 2020-2024, Matthew Wilson and Synesis Information Systems + * Copyright (c) 2020-2026, Matthew Wilson and Synesis Information Systems * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -53,8 +53,8 @@ #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_MAJOR 1 # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_MINOR 0 -# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_REVISION 2 -# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_EDIT 3 +# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_REVISION 3 +# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_EDIT 4 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -116,7 +116,7 @@ stlsoft_C_strnistrn( for (i = 1; i != n2; ++i) { - if (STLSOFT_NS_GLOBAL(toupper)(*s1) != STLSOFT_NS_GLOBAL(toupper)(*s2)) + if (STLSOFT_NS_GLOBAL(toupper)(s1[i]) != STLSOFT_NS_GLOBAL(toupper)(s2[i])) { break; } @@ -165,7 +165,7 @@ stlsoft_C_wcsnistrn( for (i = 1; i != n2; ++i) { - if (STLSOFT_NS_GLOBAL(toupper)(*s1) != STLSOFT_NS_GLOBAL(toupper)(*s2)) + if (STLSOFT_NS_GLOBAL(towupper)(s1[i]) != STLSOFT_NS_GLOBAL(towupper)(s2[i])) { break; } diff --git a/test/unit/stlsoft/string/CMakeLists.txt b/test/unit/stlsoft/string/CMakeLists.txt index cff73bc90..6c2d6a80d 100644 --- a/test/unit/stlsoft/string/CMakeLists.txt +++ b/test/unit/stlsoft/string/CMakeLists.txt @@ -1,6 +1,5 @@ # SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten -add_subdirectory(c_string.strnicmp) -add_subdirectory(c_string.strnicmp.C) +add_subdirectory(c_string) add_subdirectory(c_string_traits) add_subdirectory(char_traits) add_subdirectory(copy_functions) diff --git a/test/unit/stlsoft/string/c_string/CMakeLists.txt b/test/unit/stlsoft/string/c_string/CMakeLists.txt new file mode 100644 index 000000000..acee4746e --- /dev/null +++ b/test/unit/stlsoft/string/c_string/CMakeLists.txt @@ -0,0 +1,13 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +add_subdirectory(strnchr) +add_subdirectory(strnchr.C) +add_subdirectory(strnicmp) +add_subdirectory(strnicmp.C) +add_subdirectory(strnistrn) +add_subdirectory(strnistrn.C) +add_subdirectory(strnpbrkn) +add_subdirectory(strnpbrkn.C) +add_subdirectory(strnrchr) +add_subdirectory(strnrchr.C) +add_subdirectory(strnstrn) +add_subdirectory(strnstrn.C) diff --git a/test/unit/stlsoft/string/c_string/strnchr.C/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnchr.C/CMakeLists.txt new file mode 100644 index 000000000..43cebfc42 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnchr.C/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnchr.C entry.c) diff --git a/test/unit/stlsoft/string/c_string/strnchr.C/entry.c b/test/unit/stlsoft/string/c_string/strnchr.C/entry.c new file mode 100644 index 000000000..73c2ffcaa --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnchr.C/entry.c @@ -0,0 +1,254 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnchr.C/entry.c + * + * Purpose: Unit-tests for stlsoft_C_strnchr() and stlsoft_C_wcsnchr(). + * + * Created: 23rd October 2026 + * Updated: 23rd October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +static void TEST_stlsoft_C_strnchr_n_0(void); +static void TEST_stlsoft_C_strnchr_MATCH_AT_START(void); +static void TEST_stlsoft_C_strnchr_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_strnchr_MATCH_AT_END(void); +static void TEST_stlsoft_C_strnchr_FIRST_OF_SEVERAL(void); +static void TEST_stlsoft_C_strnchr_MISS(void); +static void TEST_stlsoft_C_strnchr_DOES_NOT_READ_PAST_n(void); +static void TEST_stlsoft_C_strnchr_FINDS_EMBEDDED_NUL(void); +static void TEST_stlsoft_C_strnchr_CONTINUES_PAST_NUL(void); +static void TEST_stlsoft_C_strnchr_HIGH_BIT(void); +static void TEST_stlsoft_C_wcsnchr_n_0(void); +static void TEST_stlsoft_C_wcsnchr_MATCH_AT_START(void); +static void TEST_stlsoft_C_wcsnchr_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_wcsnchr_MATCH_AT_END(void); +static void TEST_stlsoft_C_wcsnchr_FIRST_OF_SEVERAL(void); +static void TEST_stlsoft_C_wcsnchr_MISS(void); +static void TEST_stlsoft_C_wcsnchr_DOES_NOT_READ_PAST_n(void); +static void TEST_stlsoft_C_wcsnchr_FINDS_EMBEDDED_NUL(void); +static void TEST_stlsoft_C_wcsnchr_CONTINUES_PAST_NUL(void); +static void TEST_stlsoft_C_wcsnchr_HIGH_BIT(void); + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnchr.C", verbosity)) + { + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_n_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_FIRST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_DOES_NOT_READ_PAST_n); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_FINDS_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_CONTINUES_PAST_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnchr_HIGH_BIT); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_n_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_FIRST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_DOES_NOT_READ_PAST_n); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_FINDS_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_CONTINUES_PAST_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnchr_HIGH_BIT); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +static void TEST_stlsoft_C_strnchr_n_0(void) +{ + TEST_PTR_NULL(stlsoft_C_strnchr("abc", 0, 'a')); + TEST_PTR_NULL(stlsoft_C_strnchr("", 0, '\0')); +} + +static void TEST_stlsoft_C_strnchr_MATCH_AT_START(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft_C_strnchr(s, 3, 'a')); + TEST_PTR_EQ(s, stlsoft_C_strnchr(s, 1, 'a')); +} + +static void TEST_stlsoft_C_strnchr_MATCH_IN_MIDDLE(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnchr(s, 3, 'b')); +} + +static void TEST_stlsoft_C_strnchr_MATCH_AT_END(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnchr(s, 3, 'c')); +} + +static void TEST_stlsoft_C_strnchr_FIRST_OF_SEVERAL(void) +{ + char const s[] = "abaca"; + + TEST_PTR_EQ(s, stlsoft_C_strnchr(s, 5, 'a')); + TEST_PTR_EQ(s + 1, stlsoft_C_strnchr(s, 5, 'b')); +} + +static void TEST_stlsoft_C_strnchr_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_strnchr("abc", 3, 'z')); + TEST_PTR_NULL(stlsoft_C_strnchr("abc", 3, 'A')); +} + +static void TEST_stlsoft_C_strnchr_DOES_NOT_READ_PAST_n(void) +{ + char const s[] = "abc"; + + TEST_PTR_NULL(stlsoft_C_strnchr(s, 2, 'c')); + TEST_PTR_EQ(s + 2, stlsoft_C_strnchr(s, 3, 'c')); +} + +static void TEST_stlsoft_C_strnchr_FINDS_EMBEDDED_NUL(void) +{ + char const s[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnchr(s, 3, '\0')); + TEST_PTR_EQ("", stlsoft_C_strnchr("", 1, '\0')); +} + +static void TEST_stlsoft_C_strnchr_CONTINUES_PAST_NUL(void) +{ + char const s[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnchr(s, 3, 'b')); + TEST_PTR_NULL(stlsoft_C_strnchr(s, 2, 'b')); +} + +static void TEST_stlsoft_C_strnchr_HIGH_BIT(void) +{ + unsigned char const s_u[] = { 0xE9, 'b', 'c' }; + char const* const s = (char const*)s_u; + + TEST_PTR_EQ(s, stlsoft_C_strnchr(s, 3, s[0])); + TEST_PTR_EQ(s + 1, stlsoft_C_strnchr(s, 3, 'b')); + TEST_PTR_NULL(stlsoft_C_strnchr(s, 3, 'x')); +} + +static void TEST_stlsoft_C_wcsnchr_n_0(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnchr(L"abc", 0, L'a')); + TEST_PTR_NULL(stlsoft_C_wcsnchr(L"", 0, L'\0')); +} + +static void TEST_stlsoft_C_wcsnchr_MATCH_AT_START(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnchr(s, 3, L'a')); + TEST_PTR_EQ(s, stlsoft_C_wcsnchr(s, 1, L'a')); +} + +static void TEST_stlsoft_C_wcsnchr_MATCH_IN_MIDDLE(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnchr(s, 3, L'b')); +} + +static void TEST_stlsoft_C_wcsnchr_MATCH_AT_END(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnchr(s, 3, L'c')); +} + +static void TEST_stlsoft_C_wcsnchr_FIRST_OF_SEVERAL(void) +{ + wchar_t const s[] = L"abaca"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnchr(s, 5, L'a')); + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnchr(s, 5, L'b')); +} + +static void TEST_stlsoft_C_wcsnchr_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnchr(L"abc", 3, L'z')); + TEST_PTR_NULL(stlsoft_C_wcsnchr(L"abc", 3, L'A')); +} + +static void TEST_stlsoft_C_wcsnchr_DOES_NOT_READ_PAST_n(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_NULL(stlsoft_C_wcsnchr(s, 2, L'c')); + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnchr(s, 3, L'c')); +} + +static void TEST_stlsoft_C_wcsnchr_FINDS_EMBEDDED_NUL(void) +{ + wchar_t const s[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnchr(s, 3, L'\0')); + TEST_PTR_EQ(L"", stlsoft_C_wcsnchr(L"", 1, L'\0')); +} + +static void TEST_stlsoft_C_wcsnchr_CONTINUES_PAST_NUL(void) +{ + wchar_t const s[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnchr(s, 3, L'b')); + TEST_PTR_NULL(stlsoft_C_wcsnchr(s, 2, L'b')); +} + +static void TEST_stlsoft_C_wcsnchr_HIGH_BIT(void) +{ + wchar_t const s[] = { L'\x00E9', L'b', L'c' }; + + TEST_PTR_EQ(s, stlsoft_C_wcsnchr(s, 3, s[0])); + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnchr(s, 3, L'b')); + TEST_PTR_NULL(stlsoft_C_wcsnchr(s, 3, L'x')); +} + + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/test/unit/stlsoft/string/c_string/strnchr/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnchr/CMakeLists.txt new file mode 100644 index 000000000..acf10c047 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnchr/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnchr entry.cpp) diff --git a/test/unit/stlsoft/string/c_string/strnchr/entry.cpp b/test/unit/stlsoft/string/c_string/strnchr/entry.cpp new file mode 100644 index 000000000..d1badf5df --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnchr/entry.cpp @@ -0,0 +1,274 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnchr/entry.cpp + * + * Purpose: Unit-tests for stlsoft::c_string::strnchr() and wcsnchr(). + * + * Created: 23rd October 2026 + * Updated: 25th October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +namespace +{ + + static void TEST_c_string_strnchr_n_0(); + static void TEST_c_string_strnchr_MATCH_AT_START(); + static void TEST_c_string_strnchr_MATCH_IN_MIDDLE(); + static void TEST_c_string_strnchr_MATCH_AT_END(); + static void TEST_c_string_strnchr_FIRST_OF_SEVERAL(); + static void TEST_c_string_strnchr_MISS(); + static void TEST_c_string_strnchr_DOES_NOT_READ_PAST_n(); + static void TEST_c_string_strnchr_FINDS_EMBEDDED_NUL(); + static void TEST_c_string_strnchr_CONTINUES_PAST_NUL(); + static void TEST_c_string_strnchr_HIGH_BIT(); + static void TEST_c_string_wcsnchr_n_0(); + static void TEST_c_string_wcsnchr_MATCH_AT_START(); + static void TEST_c_string_wcsnchr_MATCH_IN_MIDDLE(); + static void TEST_c_string_wcsnchr_MATCH_AT_END(); + static void TEST_c_string_wcsnchr_FIRST_OF_SEVERAL(); + static void TEST_c_string_wcsnchr_MISS(); + static void TEST_c_string_wcsnchr_DOES_NOT_READ_PAST_n(); + static void TEST_c_string_wcsnchr_FINDS_EMBEDDED_NUL(); + static void TEST_c_string_wcsnchr_CONTINUES_PAST_NUL(); + static void TEST_c_string_wcsnchr_HIGH_BIT(); + + static wchar_t const* wcsnchr_both_(wchar_t const* s, size_t n, int ch); +} // anonymous namespace + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnchr", verbosity)) + { + XTESTS_RUN_CASE(TEST_c_string_strnchr_n_0); + XTESTS_RUN_CASE(TEST_c_string_strnchr_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_c_string_strnchr_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_strnchr_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_strnchr_FIRST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_c_string_strnchr_MISS); + XTESTS_RUN_CASE(TEST_c_string_strnchr_DOES_NOT_READ_PAST_n); + XTESTS_RUN_CASE(TEST_c_string_strnchr_FINDS_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_c_string_strnchr_CONTINUES_PAST_NUL); + XTESTS_RUN_CASE(TEST_c_string_strnchr_HIGH_BIT); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_n_0); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_FIRST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_MISS); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_DOES_NOT_READ_PAST_n); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_FINDS_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_CONTINUES_PAST_NUL); + XTESTS_RUN_CASE(TEST_c_string_wcsnchr_HIGH_BIT); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +namespace +{ + +static wchar_t const* wcsnchr_both_(wchar_t const* s, size_t n, int ch) +{ + wchar_t const* const via_str = stlsoft::c_string::strnchr(s, n, ch); + wchar_t const* const via_wcs = stlsoft::c_string::wcsnchr(s, n, ch); + + TEST_PTR_EQ(via_wcs, via_str); + + return via_wcs; +} + +static void TEST_c_string_strnchr_n_0() +{ + TEST_PTR_NULL(stlsoft::c_string::strnchr("abc", 0, 'a')); + TEST_PTR_NULL(stlsoft::c_string::strnchr("", 0, '\0')); +} + +static void TEST_c_string_strnchr_MATCH_AT_START() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnchr(s, 3, 'a')); + TEST_PTR_EQ(s, stlsoft::c_string::strnchr(s, 1, 'a')); +} + +static void TEST_c_string_strnchr_MATCH_IN_MIDDLE() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnchr(s, 3, 'b')); +} + +static void TEST_c_string_strnchr_MATCH_AT_END() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnchr(s, 3, 'c')); +} + +static void TEST_c_string_strnchr_FIRST_OF_SEVERAL() +{ + char const s[] = "abaca"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnchr(s, 5, 'a')); + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnchr(s, 5, 'b')); +} + +static void TEST_c_string_strnchr_MISS() +{ + TEST_PTR_NULL(stlsoft::c_string::strnchr("abc", 3, 'z')); + TEST_PTR_NULL(stlsoft::c_string::strnchr("abc", 3, 'A')); +} + +static void TEST_c_string_strnchr_DOES_NOT_READ_PAST_n() +{ + char const s[] = "abc"; + + TEST_PTR_NULL(stlsoft::c_string::strnchr(s, 2, 'c')); + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnchr(s, 3, 'c')); +} + +static void TEST_c_string_strnchr_FINDS_EMBEDDED_NUL() +{ + char const s[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnchr(s, 3, '\0')); + TEST_PTR_EQ("", stlsoft::c_string::strnchr("", 1, '\0')); +} + +static void TEST_c_string_strnchr_CONTINUES_PAST_NUL() +{ + char const s[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnchr(s, 3, 'b')); + TEST_PTR_NULL(stlsoft::c_string::strnchr(s, 2, 'b')); +} + +static void TEST_c_string_strnchr_HIGH_BIT() +{ + unsigned char const s_u[] = { 0xE9, 'b', 'c' }; + char const* const s = reinterpret_cast(s_u); + + TEST_PTR_EQ(s, stlsoft::c_string::strnchr(s, 3, s[0])); + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnchr(s, 3, 'b')); + TEST_PTR_NULL(stlsoft::c_string::strnchr(s, 3, 'x')); +} + +static void TEST_c_string_wcsnchr_n_0() +{ + TEST_PTR_NULL(wcsnchr_both_(L"abc", 0, L'a')); + TEST_PTR_NULL(wcsnchr_both_(L"", 0, L'\0')); +} + +static void TEST_c_string_wcsnchr_MATCH_AT_START() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, wcsnchr_both_(s, 3, L'a')); + TEST_PTR_EQ(s, wcsnchr_both_(s, 1, L'a')); +} + +static void TEST_c_string_wcsnchr_MATCH_IN_MIDDLE() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, wcsnchr_both_(s, 3, L'b')); +} + +static void TEST_c_string_wcsnchr_MATCH_AT_END() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 2, wcsnchr_both_(s, 3, L'c')); +} + +static void TEST_c_string_wcsnchr_FIRST_OF_SEVERAL() +{ + wchar_t const s[] = L"abaca"; + + TEST_PTR_EQ(s, wcsnchr_both_(s, 5, L'a')); + TEST_PTR_EQ(s + 1, wcsnchr_both_(s, 5, L'b')); +} + +static void TEST_c_string_wcsnchr_MISS() +{ + TEST_PTR_NULL(wcsnchr_both_(L"abc", 3, L'z')); + TEST_PTR_NULL(wcsnchr_both_(L"abc", 3, L'A')); +} + +static void TEST_c_string_wcsnchr_DOES_NOT_READ_PAST_n() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_NULL(wcsnchr_both_(s, 2, L'c')); + TEST_PTR_EQ(s + 2, wcsnchr_both_(s, 3, L'c')); +} + +static void TEST_c_string_wcsnchr_FINDS_EMBEDDED_NUL() +{ + wchar_t const s[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(s + 1, wcsnchr_both_(s, 3, L'\0')); + TEST_PTR_EQ(L"", wcsnchr_both_(L"", 1, L'\0')); +} + +static void TEST_c_string_wcsnchr_CONTINUES_PAST_NUL() +{ + wchar_t const s[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(s + 2, wcsnchr_both_(s, 3, L'b')); + TEST_PTR_NULL(wcsnchr_both_(s, 2, L'b')); +} + +static void TEST_c_string_wcsnchr_HIGH_BIT() +{ + wchar_t const s[] = { L'\x00E9', L'b', L'c' }; + + TEST_PTR_EQ(s, wcsnchr_both_(s, 3, s[0])); + TEST_PTR_EQ(s + 1, wcsnchr_both_(s, 3, L'b')); + TEST_PTR_NULL(wcsnchr_both_(s, 3, L'x')); +} +} // anonymous namespace + + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/test/unit/stlsoft/string/c_string.strnicmp.C/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnicmp.C/CMakeLists.txt similarity index 100% rename from test/unit/stlsoft/string/c_string.strnicmp.C/CMakeLists.txt rename to test/unit/stlsoft/string/c_string/strnicmp.C/CMakeLists.txt diff --git a/test/unit/stlsoft/string/c_string.strnicmp.C/entry.c b/test/unit/stlsoft/string/c_string/strnicmp.C/entry.c similarity index 66% rename from test/unit/stlsoft/string/c_string.strnicmp.C/entry.c rename to test/unit/stlsoft/string/c_string/strnicmp.C/entry.c index 3184f3ab6..4c8e71d7f 100644 --- a/test/unit/stlsoft/string/c_string.strnicmp.C/entry.c +++ b/test/unit/stlsoft/string/c_string/strnicmp.C/entry.c @@ -4,7 +4,7 @@ * Purpose: Unit-tests for stlsoft_C_strnicmp() and stlsoft_C_wcsnicmp(). * * Created: 29th September 2026 - * Updated: 29th September 2026 + * Updated: 23rd October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -34,17 +34,27 @@ static void TEST_stlsoft_C_strnicmp_EQUAL(void); static void TEST_stlsoft_C_strnicmp_LESS(void); static void TEST_stlsoft_C_strnicmp_GREATER(void); static void TEST_stlsoft_C_strnicmp_n_0(void); +static void TEST_stlsoft_C_strnicmp_n_1(void); static void TEST_stlsoft_C_strnicmp_STOPS_AT_NUL(void); +static void TEST_stlsoft_C_strnicmp_NUL_AT_START(void); static void TEST_stlsoft_C_strnicmp_IGNORES_BYTE_PAST_n(void); +static void TEST_stlsoft_C_strnicmp_DIFFER_AT_LAST(void); static void TEST_stlsoft_C_strnicmp_ASCII_CASE_FOLD(void); +static void TEST_stlsoft_C_strnicmp_CASE_THEN_DIFFER(void); +static void TEST_stlsoft_C_strnicmp_NON_LETTER(void); static void TEST_stlsoft_C_strnicmp_HIGH_BIT(void); static void TEST_stlsoft_C_wcsnicmp_EQUAL(void); static void TEST_stlsoft_C_wcsnicmp_LESS(void); static void TEST_stlsoft_C_wcsnicmp_GREATER(void); static void TEST_stlsoft_C_wcsnicmp_n_0(void); +static void TEST_stlsoft_C_wcsnicmp_n_1(void); static void TEST_stlsoft_C_wcsnicmp_STOPS_AT_NUL(void); +static void TEST_stlsoft_C_wcsnicmp_NUL_AT_START(void); static void TEST_stlsoft_C_wcsnicmp_IGNORES_BYTE_PAST_n(void); +static void TEST_stlsoft_C_wcsnicmp_DIFFER_AT_LAST(void); static void TEST_stlsoft_C_wcsnicmp_ASCII_CASE_FOLD(void); +static void TEST_stlsoft_C_wcsnicmp_CASE_THEN_DIFFER(void); +static void TEST_stlsoft_C_wcsnicmp_NON_LETTER(void); static void TEST_stlsoft_C_wcsnicmp_HIGH_BIT(void); @@ -65,17 +75,27 @@ int main(int argc, char* argv[]) XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_LESS); XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_GREATER); XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_n_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_n_1); XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_STOPS_AT_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_NUL_AT_START); XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_IGNORES_BYTE_PAST_n); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_DIFFER_AT_LAST); XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_ASCII_CASE_FOLD); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_CASE_THEN_DIFFER); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_NON_LETTER); XTESTS_RUN_CASE(TEST_stlsoft_C_strnicmp_HIGH_BIT); XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_EQUAL); XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_LESS); XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_GREATER); XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_n_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_n_1); XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_STOPS_AT_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_NUL_AT_START); XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_IGNORES_BYTE_PAST_n); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_DIFFER_AT_LAST); XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_ASCII_CASE_FOLD); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_CASE_THEN_DIFFER); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_NON_LETTER); XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnicmp_HIGH_BIT); XTESTS_PRINT_RESULTS(); @@ -116,6 +136,13 @@ static void TEST_stlsoft_C_strnicmp_n_0(void) TEST_INT_EQ(0, stlsoft_C_strnicmp("", "abc", 0)); } +static void TEST_stlsoft_C_strnicmp_n_1(void) +{ + TEST_INT_EQ(0, stlsoft_C_strnicmp("aX", "Ay", 1)); + TEST_INT_LT(0, stlsoft_C_strnicmp("A", "b", 1)); + TEST_INT_GT(0, stlsoft_C_strnicmp("b", "A", 1)); +} + static void TEST_stlsoft_C_strnicmp_STOPS_AT_NUL(void) { char const s1[] = { 'a', '\0', 'x' }; @@ -124,12 +151,29 @@ static void TEST_stlsoft_C_strnicmp_STOPS_AT_NUL(void) TEST_INT_EQ(0, stlsoft_C_strnicmp(s1, s2, 3)); } +static void TEST_stlsoft_C_strnicmp_NUL_AT_START(void) +{ + char const both[] = { '\0', 'x' }; + char const only[] = { '\0', 'y' }; + + TEST_INT_EQ(0, stlsoft_C_strnicmp(both, only, 2)); + TEST_INT_LT(0, stlsoft_C_strnicmp(both, "a", 1)); + TEST_INT_GT(0, stlsoft_C_strnicmp("a", only, 1)); +} + static void TEST_stlsoft_C_strnicmp_IGNORES_BYTE_PAST_n(void) { TEST_INT_EQ(0, stlsoft_C_strnicmp("abX", "abY", 2)); TEST_INT_LT(0, stlsoft_C_strnicmp("abX", "abY", 3)); } +static void TEST_stlsoft_C_strnicmp_DIFFER_AT_LAST(void) +{ + TEST_INT_EQ(0, stlsoft_C_strnicmp("abcd", "abce", 3)); + TEST_INT_LT(0, stlsoft_C_strnicmp("abcd", "abce", 4)); + TEST_INT_GT(0, stlsoft_C_strnicmp("abce", "abcd", 4)); +} + static void TEST_stlsoft_C_strnicmp_ASCII_CASE_FOLD(void) { TEST_INT_EQ(0, stlsoft_C_strnicmp("AbC", "aBc", 3)); @@ -138,6 +182,20 @@ static void TEST_stlsoft_C_strnicmp_ASCII_CASE_FOLD(void) TEST_INT_GT(0, stlsoft_C_strnicmp("B", "a", 1)); } +static void TEST_stlsoft_C_strnicmp_CASE_THEN_DIFFER(void) +{ + TEST_INT_EQ(0, stlsoft_C_strnicmp("abcX", "ABCx", 4)); + TEST_INT_LT(0, stlsoft_C_strnicmp("abcX", "ABCY", 4)); + TEST_INT_GT(0, stlsoft_C_strnicmp("ABCY", "abcX", 4)); +} + +static void TEST_stlsoft_C_strnicmp_NON_LETTER(void) +{ + TEST_INT_EQ(0, stlsoft_C_strnicmp("a1!", "A1!", 3)); + TEST_INT_LT(0, stlsoft_C_strnicmp("a1!", "A1?", 3)); + TEST_INT_GT(0, stlsoft_C_strnicmp("A1?", "a1!", 3)); +} + static void TEST_stlsoft_C_strnicmp_HIGH_BIT(void) { unsigned char const same1_u[] = { 0xE9, 'A', 0 }; @@ -182,6 +240,13 @@ static void TEST_stlsoft_C_wcsnicmp_n_0(void) TEST_INT_EQ(0, stlsoft_C_wcsnicmp(L"", L"abc", 0)); } +static void TEST_stlsoft_C_wcsnicmp_n_1(void) +{ + TEST_INT_EQ(0, stlsoft_C_wcsnicmp(L"aX", L"Ay", 1)); + TEST_INT_LT(0, stlsoft_C_wcsnicmp(L"A", L"b", 1)); + TEST_INT_GT(0, stlsoft_C_wcsnicmp(L"b", L"A", 1)); +} + static void TEST_stlsoft_C_wcsnicmp_STOPS_AT_NUL(void) { wchar_t const s1[] = { L'a', L'\0', L'x' }; @@ -190,12 +255,29 @@ static void TEST_stlsoft_C_wcsnicmp_STOPS_AT_NUL(void) TEST_INT_EQ(0, stlsoft_C_wcsnicmp(s1, s2, 3)); } +static void TEST_stlsoft_C_wcsnicmp_NUL_AT_START(void) +{ + wchar_t const both[] = { L'\0', L'x' }; + wchar_t const only[] = { L'\0', L'y' }; + + TEST_INT_EQ(0, stlsoft_C_wcsnicmp(both, only, 2)); + TEST_INT_LT(0, stlsoft_C_wcsnicmp(both, L"a", 1)); + TEST_INT_GT(0, stlsoft_C_wcsnicmp(L"a", only, 1)); +} + static void TEST_stlsoft_C_wcsnicmp_IGNORES_BYTE_PAST_n(void) { TEST_INT_EQ(0, stlsoft_C_wcsnicmp(L"abX", L"abY", 2)); TEST_INT_LT(0, stlsoft_C_wcsnicmp(L"abX", L"abY", 3)); } +static void TEST_stlsoft_C_wcsnicmp_DIFFER_AT_LAST(void) +{ + TEST_INT_EQ(0, stlsoft_C_wcsnicmp(L"abcd", L"abce", 3)); + TEST_INT_LT(0, stlsoft_C_wcsnicmp(L"abcd", L"abce", 4)); + TEST_INT_GT(0, stlsoft_C_wcsnicmp(L"abce", L"abcd", 4)); +} + static void TEST_stlsoft_C_wcsnicmp_ASCII_CASE_FOLD(void) { TEST_INT_EQ(0, stlsoft_C_wcsnicmp(L"AbC", L"aBc", 3)); @@ -204,6 +286,20 @@ static void TEST_stlsoft_C_wcsnicmp_ASCII_CASE_FOLD(void) TEST_INT_GT(0, stlsoft_C_wcsnicmp(L"B", L"a", 1)); } +static void TEST_stlsoft_C_wcsnicmp_CASE_THEN_DIFFER(void) +{ + TEST_INT_EQ(0, stlsoft_C_wcsnicmp(L"abcX", L"ABCx", 4)); + TEST_INT_LT(0, stlsoft_C_wcsnicmp(L"abcX", L"ABCY", 4)); + TEST_INT_GT(0, stlsoft_C_wcsnicmp(L"ABCY", L"abcX", 4)); +} + +static void TEST_stlsoft_C_wcsnicmp_NON_LETTER(void) +{ + TEST_INT_EQ(0, stlsoft_C_wcsnicmp(L"a1!", L"A1!", 3)); + TEST_INT_LT(0, stlsoft_C_wcsnicmp(L"a1!", L"A1?", 3)); + TEST_INT_GT(0, stlsoft_C_wcsnicmp(L"A1?", L"a1!", 3)); +} + static void TEST_stlsoft_C_wcsnicmp_HIGH_BIT(void) { wchar_t const same1[] = { L'\x00E9', L'A', L'\0' }; diff --git a/test/unit/stlsoft/string/c_string.strnicmp/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnicmp/CMakeLists.txt similarity index 100% rename from test/unit/stlsoft/string/c_string.strnicmp/CMakeLists.txt rename to test/unit/stlsoft/string/c_string/strnicmp/CMakeLists.txt diff --git a/test/unit/stlsoft/string/c_string.strnicmp/entry.cpp b/test/unit/stlsoft/string/c_string/strnicmp/entry.cpp similarity index 67% rename from test/unit/stlsoft/string/c_string.strnicmp/entry.cpp rename to test/unit/stlsoft/string/c_string/strnicmp/entry.cpp index 35c7108ae..b2562f042 100644 --- a/test/unit/stlsoft/string/c_string.strnicmp/entry.cpp +++ b/test/unit/stlsoft/string/c_string/strnicmp/entry.cpp @@ -4,7 +4,7 @@ * Purpose: Unit-tests for stlsoft::c_string::strnicmp() and wcsnicmp(). * * Created: 29th September 2026 - * Updated: 29th September 2026 + * Updated: 25th October 2026 * * ////////////////////////////////////////////////////////////////////// */ @@ -37,22 +37,31 @@ namespace static void TEST_c_string_strnicmp_LESS(); static void TEST_c_string_strnicmp_GREATER(); static void TEST_c_string_strnicmp_n_0(); + static void TEST_c_string_strnicmp_n_1(); static void TEST_c_string_strnicmp_STOPS_AT_NUL(); + static void TEST_c_string_strnicmp_NUL_AT_START(); static void TEST_c_string_strnicmp_IGNORES_BYTE_PAST_n(); + static void TEST_c_string_strnicmp_DIFFER_AT_LAST(); static void TEST_c_string_strnicmp_ASCII_CASE_FOLD(); + static void TEST_c_string_strnicmp_CASE_THEN_DIFFER(); + static void TEST_c_string_strnicmp_NON_LETTER(); static void TEST_c_string_strnicmp_HIGH_BIT(); static void TEST_c_string_wcsnicmp_EQUAL(); static void TEST_c_string_wcsnicmp_LESS(); static void TEST_c_string_wcsnicmp_GREATER(); static void TEST_c_string_wcsnicmp_n_0(); + static void TEST_c_string_wcsnicmp_n_1(); static void TEST_c_string_wcsnicmp_STOPS_AT_NUL(); + static void TEST_c_string_wcsnicmp_NUL_AT_START(); static void TEST_c_string_wcsnicmp_IGNORES_BYTE_PAST_n(); + static void TEST_c_string_wcsnicmp_DIFFER_AT_LAST(); static void TEST_c_string_wcsnicmp_ASCII_CASE_FOLD(); + static void TEST_c_string_wcsnicmp_CASE_THEN_DIFFER(); + static void TEST_c_string_wcsnicmp_NON_LETTER(); static void TEST_c_string_wcsnicmp_HIGH_BIT(); static int wcsnicmp_both_(wchar_t const* s1, wchar_t const* s2, size_t n); - -} /* anonymous namespace */ +} // anonymous namespace /* ///////////////////////////////////////////////////////////////////////// @@ -72,17 +81,27 @@ int main(int argc, char* argv[]) XTESTS_RUN_CASE(TEST_c_string_strnicmp_LESS); XTESTS_RUN_CASE(TEST_c_string_strnicmp_GREATER); XTESTS_RUN_CASE(TEST_c_string_strnicmp_n_0); + XTESTS_RUN_CASE(TEST_c_string_strnicmp_n_1); XTESTS_RUN_CASE(TEST_c_string_strnicmp_STOPS_AT_NUL); + XTESTS_RUN_CASE(TEST_c_string_strnicmp_NUL_AT_START); XTESTS_RUN_CASE(TEST_c_string_strnicmp_IGNORES_BYTE_PAST_n); + XTESTS_RUN_CASE(TEST_c_string_strnicmp_DIFFER_AT_LAST); XTESTS_RUN_CASE(TEST_c_string_strnicmp_ASCII_CASE_FOLD); + XTESTS_RUN_CASE(TEST_c_string_strnicmp_CASE_THEN_DIFFER); + XTESTS_RUN_CASE(TEST_c_string_strnicmp_NON_LETTER); XTESTS_RUN_CASE(TEST_c_string_strnicmp_HIGH_BIT); XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_EQUAL); XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_LESS); XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_GREATER); XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_n_0); + XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_n_1); XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_STOPS_AT_NUL); + XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_NUL_AT_START); XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_IGNORES_BYTE_PAST_n); + XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_DIFFER_AT_LAST); XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_ASCII_CASE_FOLD); + XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_CASE_THEN_DIFFER); + XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_NON_LETTER); XTESTS_RUN_CASE(TEST_c_string_wcsnicmp_HIGH_BIT); XTESTS_PRINT_RESULTS(); @@ -136,6 +155,13 @@ static void TEST_c_string_strnicmp_n_0() TEST_INT_EQ(0, stlsoft::c_string::strnicmp("", "abc", 0)); } +static void TEST_c_string_strnicmp_n_1() +{ + TEST_INT_EQ(0, stlsoft::c_string::strnicmp("aX", "Ay", 1)); + TEST_INT_LT(0, stlsoft::c_string::strnicmp("A", "b", 1)); + TEST_INT_GT(0, stlsoft::c_string::strnicmp("b", "A", 1)); +} + static void TEST_c_string_strnicmp_STOPS_AT_NUL() { char const s1[] = { 'a', '\0', 'x' }; @@ -144,12 +170,29 @@ static void TEST_c_string_strnicmp_STOPS_AT_NUL() TEST_INT_EQ(0, stlsoft::c_string::strnicmp(s1, s2, 3)); } +static void TEST_c_string_strnicmp_NUL_AT_START() +{ + char const both[] = { '\0', 'x' }; + char const only[] = { '\0', 'y' }; + + TEST_INT_EQ(0, stlsoft::c_string::strnicmp(both, only, 2)); + TEST_INT_LT(0, stlsoft::c_string::strnicmp(both, "a", 1)); + TEST_INT_GT(0, stlsoft::c_string::strnicmp("a", only, 1)); +} + static void TEST_c_string_strnicmp_IGNORES_BYTE_PAST_n() { TEST_INT_EQ(0, stlsoft::c_string::strnicmp("abX", "abY", 2)); TEST_INT_LT(0, stlsoft::c_string::strnicmp("abX", "abY", 3)); } +static void TEST_c_string_strnicmp_DIFFER_AT_LAST() +{ + TEST_INT_EQ(0, stlsoft::c_string::strnicmp("abcd", "abce", 3)); + TEST_INT_LT(0, stlsoft::c_string::strnicmp("abcd", "abce", 4)); + TEST_INT_GT(0, stlsoft::c_string::strnicmp("abce", "abcd", 4)); +} + static void TEST_c_string_strnicmp_ASCII_CASE_FOLD() { TEST_INT_EQ(0, stlsoft::c_string::strnicmp("AbC", "aBc", 3)); @@ -158,6 +201,20 @@ static void TEST_c_string_strnicmp_ASCII_CASE_FOLD() TEST_INT_GT(0, stlsoft::c_string::strnicmp("B", "a", 1)); } +static void TEST_c_string_strnicmp_CASE_THEN_DIFFER() +{ + TEST_INT_EQ(0, stlsoft::c_string::strnicmp("abcX", "ABCx", 4)); + TEST_INT_LT(0, stlsoft::c_string::strnicmp("abcX", "ABCY", 4)); + TEST_INT_GT(0, stlsoft::c_string::strnicmp("ABCY", "abcX", 4)); +} + +static void TEST_c_string_strnicmp_NON_LETTER() +{ + TEST_INT_EQ(0, stlsoft::c_string::strnicmp("a1!", "A1!", 3)); + TEST_INT_LT(0, stlsoft::c_string::strnicmp("a1!", "A1?", 3)); + TEST_INT_GT(0, stlsoft::c_string::strnicmp("A1?", "a1!", 3)); +} + static void TEST_c_string_strnicmp_HIGH_BIT() { unsigned char const same1_u[] = { 0xE9, 'A', 0 }; @@ -202,6 +259,13 @@ static void TEST_c_string_wcsnicmp_n_0() TEST_INT_EQ(0, wcsnicmp_both_(L"", L"abc", 0)); } +static void TEST_c_string_wcsnicmp_n_1() +{ + TEST_INT_EQ(0, wcsnicmp_both_(L"aX", L"Ay", 1)); + TEST_INT_LT(0, wcsnicmp_both_(L"A", L"b", 1)); + TEST_INT_GT(0, wcsnicmp_both_(L"b", L"A", 1)); +} + static void TEST_c_string_wcsnicmp_STOPS_AT_NUL() { wchar_t const s1[] = { L'a', L'\0', L'x' }; @@ -210,12 +274,29 @@ static void TEST_c_string_wcsnicmp_STOPS_AT_NUL() TEST_INT_EQ(0, wcsnicmp_both_(s1, s2, 3)); } +static void TEST_c_string_wcsnicmp_NUL_AT_START() +{ + wchar_t const both[] = { L'\0', L'x' }; + wchar_t const only[] = { L'\0', L'y' }; + + TEST_INT_EQ(0, wcsnicmp_both_(both, only, 2)); + TEST_INT_LT(0, wcsnicmp_both_(both, L"a", 1)); + TEST_INT_GT(0, wcsnicmp_both_(L"a", only, 1)); +} + static void TEST_c_string_wcsnicmp_IGNORES_BYTE_PAST_n() { TEST_INT_EQ(0, wcsnicmp_both_(L"abX", L"abY", 2)); TEST_INT_LT(0, wcsnicmp_both_(L"abX", L"abY", 3)); } +static void TEST_c_string_wcsnicmp_DIFFER_AT_LAST() +{ + TEST_INT_EQ(0, wcsnicmp_both_(L"abcd", L"abce", 3)); + TEST_INT_LT(0, wcsnicmp_both_(L"abcd", L"abce", 4)); + TEST_INT_GT(0, wcsnicmp_both_(L"abce", L"abcd", 4)); +} + static void TEST_c_string_wcsnicmp_ASCII_CASE_FOLD() { TEST_INT_EQ(0, wcsnicmp_both_(L"AbC", L"aBc", 3)); @@ -224,6 +305,20 @@ static void TEST_c_string_wcsnicmp_ASCII_CASE_FOLD() TEST_INT_GT(0, wcsnicmp_both_(L"B", L"a", 1)); } +static void TEST_c_string_wcsnicmp_CASE_THEN_DIFFER() +{ + TEST_INT_EQ(0, wcsnicmp_both_(L"abcX", L"ABCx", 4)); + TEST_INT_LT(0, wcsnicmp_both_(L"abcX", L"ABCY", 4)); + TEST_INT_GT(0, wcsnicmp_both_(L"ABCY", L"abcX", 4)); +} + +static void TEST_c_string_wcsnicmp_NON_LETTER() +{ + TEST_INT_EQ(0, wcsnicmp_both_(L"a1!", L"A1!", 3)); + TEST_INT_LT(0, wcsnicmp_both_(L"a1!", L"A1?", 3)); + TEST_INT_GT(0, wcsnicmp_both_(L"A1?", L"a1!", 3)); +} + static void TEST_c_string_wcsnicmp_HIGH_BIT() { wchar_t const same1[] = { L'\x00E9', L'A', L'\0' }; @@ -237,8 +332,7 @@ static void TEST_c_string_wcsnicmp_HIGH_BIT() TEST_INT_LT(0, wcsnicmp_both_(lo, hi, 1)); TEST_INT_GT(0, wcsnicmp_both_(hi, lo, 1)); } - -} /* anonymous namespace */ +} // anonymous namespace /* ///////////////////////////// end of file //////////////////////////// */ diff --git a/test/unit/stlsoft/string/c_string/strnistrn.C/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnistrn.C/CMakeLists.txt new file mode 100644 index 000000000..e891dadfb --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnistrn.C/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnistrn.C entry.c) diff --git a/test/unit/stlsoft/string/c_string/strnistrn.C/entry.c b/test/unit/stlsoft/string/c_string/strnistrn.C/entry.c new file mode 100644 index 000000000..90f22172e --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnistrn.C/entry.c @@ -0,0 +1,354 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnistrn.C/entry.c + * + * Purpose: Unit-tests for stlsoft_C_strnistrn() and stlsoft_C_wcsnistrn(). + * + * Created: 23rd October 2026 + * Updated: 23rd October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +static void TEST_stlsoft_C_strnistrn_n2_0(void); +static void TEST_stlsoft_C_strnistrn_n1_0(void); +static void TEST_stlsoft_C_strnistrn_n2_GT_n1(void); +static void TEST_stlsoft_C_strnistrn_EXACT_MATCH(void); +static void TEST_stlsoft_C_strnistrn_CASE_FOLD_FULL(void); +static void TEST_stlsoft_C_strnistrn_CASE_FOLD_IN_MIDDLE(void); +static void TEST_stlsoft_C_strnistrn_CASE_FOLD_AT_END(void); +static void TEST_stlsoft_C_strnistrn_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_strnistrn_MATCH_AT_END(void); +static void TEST_stlsoft_C_strnistrn_MISS(void); +static void TEST_stlsoft_C_strnistrn_FIRST_CHAR_ONLY_THEN_MATCH(void); +static void TEST_stlsoft_C_strnistrn_DOES_NOT_READ_PAST_n1(void); +static void TEST_stlsoft_C_strnistrn_DOES_NOT_READ_PAST_n2(void); +static void TEST_stlsoft_C_strnistrn_SINGLE_BYTE(void); +static void TEST_stlsoft_C_strnistrn_HIGH_BIT(void); +static void TEST_stlsoft_C_wcsnistrn_n2_0(void); +static void TEST_stlsoft_C_wcsnistrn_n1_0(void); +static void TEST_stlsoft_C_wcsnistrn_n2_GT_n1(void); +static void TEST_stlsoft_C_wcsnistrn_EXACT_MATCH(void); +static void TEST_stlsoft_C_wcsnistrn_CASE_FOLD_FULL(void); +static void TEST_stlsoft_C_wcsnistrn_CASE_FOLD_IN_MIDDLE(void); +static void TEST_stlsoft_C_wcsnistrn_CASE_FOLD_AT_END(void); +static void TEST_stlsoft_C_wcsnistrn_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_wcsnistrn_MATCH_AT_END(void); +static void TEST_stlsoft_C_wcsnistrn_MISS(void); +static void TEST_stlsoft_C_wcsnistrn_FIRST_CHAR_ONLY_THEN_MATCH(void); +static void TEST_stlsoft_C_wcsnistrn_DOES_NOT_READ_PAST_n1(void); +static void TEST_stlsoft_C_wcsnistrn_DOES_NOT_READ_PAST_n2(void); +static void TEST_stlsoft_C_wcsnistrn_SINGLE_BYTE(void); +static void TEST_stlsoft_C_wcsnistrn_HIGH_BIT(void); + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnistrn.C", verbosity)) + { + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_n2_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_n1_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_n2_GT_n1); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_EXACT_MATCH); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_CASE_FOLD_FULL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_CASE_FOLD_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_CASE_FOLD_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_FIRST_CHAR_ONLY_THEN_MATCH); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_DOES_NOT_READ_PAST_n1); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_DOES_NOT_READ_PAST_n2); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_SINGLE_BYTE); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnistrn_HIGH_BIT); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_n2_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_n1_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_n2_GT_n1); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_EXACT_MATCH); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_CASE_FOLD_FULL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_CASE_FOLD_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_CASE_FOLD_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_FIRST_CHAR_ONLY_THEN_MATCH); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_DOES_NOT_READ_PAST_n1); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_DOES_NOT_READ_PAST_n2); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_SINGLE_BYTE); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnistrn_HIGH_BIT); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +static void TEST_stlsoft_C_strnistrn_n2_0(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft_C_strnistrn(s, 3, "", 0)); + TEST_PTR_EQ(s, stlsoft_C_strnistrn(s, 0, "xyz", 0)); +} + +static void TEST_stlsoft_C_strnistrn_n1_0(void) +{ + TEST_PTR_NULL(stlsoft_C_strnistrn("abc", 0, "a", 1)); +} + +static void TEST_stlsoft_C_strnistrn_n2_GT_n1(void) +{ + TEST_PTR_NULL(stlsoft_C_strnistrn("ab", 2, "abc", 3)); +} + +static void TEST_stlsoft_C_strnistrn_EXACT_MATCH(void) +{ + char const s[] = "abcdef"; + + TEST_PTR_EQ(s, stlsoft_C_strnistrn(s, 6, "abc", 3)); + TEST_PTR_EQ(s, stlsoft_C_strnistrn(s, 3, "abc", 3)); +} + +static void TEST_stlsoft_C_strnistrn_CASE_FOLD_FULL(void) +{ + char const s[] = "xxAbCxx"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnistrn(s, 7, "aBc", 3)); + TEST_PTR_EQ(s + 2, stlsoft_C_strnistrn(s, 7, "ABC", 3)); +} + +static void TEST_stlsoft_C_strnistrn_CASE_FOLD_IN_MIDDLE(void) +{ + char const s[] = "aBc"; + + TEST_PTR_EQ(s, stlsoft_C_strnistrn(s, 3, "abc", 3)); + TEST_PTR_NULL(stlsoft_C_strnistrn(s, 3, "axc", 3)); +} + +static void TEST_stlsoft_C_strnistrn_CASE_FOLD_AT_END(void) +{ + char const s[] = "zzAB"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnistrn(s, 4, "ab", 2)); + TEST_PTR_NULL(stlsoft_C_strnistrn(s, 3, "ab", 2)); +} + +static void TEST_stlsoft_C_strnistrn_MATCH_IN_MIDDLE(void) +{ + char const s[] = "xxabcxx"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnistrn(s, 7, "AbC", 3)); +} + +static void TEST_stlsoft_C_strnistrn_MATCH_AT_END(void) +{ + char const s[] = "xxabc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnistrn(s, 5, "ABC", 3)); +} + +static void TEST_stlsoft_C_strnistrn_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_strnistrn("abcdef", 6, "zzz", 3)); + TEST_PTR_NULL(stlsoft_C_strnistrn("abcdef", 6, "abx", 3)); + TEST_PTR_NULL(stlsoft_C_strnistrn("aXY", 3, "abc", 3)); +} + +static void TEST_stlsoft_C_strnistrn_FIRST_CHAR_ONLY_THEN_MATCH(void) +{ + char const s[] = "aXYabc"; + + TEST_PTR_EQ(s + 3, stlsoft_C_strnistrn(s, 6, "ABC", 3)); + TEST_PTR_NULL(stlsoft_C_strnistrn("aXY", 3, "ABC", 3)); +} + +static void TEST_stlsoft_C_strnistrn_DOES_NOT_READ_PAST_n1(void) +{ + char const s[] = "xxabc"; + + TEST_PTR_NULL(stlsoft_C_strnistrn(s, 4, "ABC", 3)); + TEST_PTR_EQ(s + 2, stlsoft_C_strnistrn(s, 5, "ABC", 3)); +} + +static void TEST_stlsoft_C_strnistrn_DOES_NOT_READ_PAST_n2(void) +{ + char const hay[] = "abX"; + char const needle[] = { 'A', 'B', 'Y' }; + + TEST_PTR_EQ(hay, stlsoft_C_strnistrn(hay, 3, needle, 2)); + TEST_PTR_NULL(stlsoft_C_strnistrn(hay, 3, needle, 3)); +} + +static void TEST_stlsoft_C_strnistrn_SINGLE_BYTE(void) +{ + char const s[] = "xxA"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnistrn(s, 3, "a", 1)); + TEST_PTR_NULL(stlsoft_C_strnistrn(s, 2, "a", 1)); +} + +static void TEST_stlsoft_C_strnistrn_HIGH_BIT(void) +{ + unsigned char const hay_u[] = { 0xE9, 'A', 'b' }; + unsigned char const needle_u[] = { 0xE9, 'a', 'B' }; + unsigned char const other_u[] = { 0xE2, 'a' }; + char const* const hay = (char const*)hay_u; + char const* const needle = (char const*)needle_u; + char const* const other = (char const*)other_u; + + TEST_PTR_EQ(hay, stlsoft_C_strnistrn(hay, 3, needle, 3)); + TEST_PTR_NULL(stlsoft_C_strnistrn(hay, 2, other, 2)); +} + +static void TEST_stlsoft_C_wcsnistrn_n2_0(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnistrn(s, 3, L"", 0)); + TEST_PTR_EQ(s, stlsoft_C_wcsnistrn(s, 0, L"xyz", 0)); +} + +static void TEST_stlsoft_C_wcsnistrn_n1_0(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnistrn(L"abc", 0, L"a", 1)); +} + +static void TEST_stlsoft_C_wcsnistrn_n2_GT_n1(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnistrn(L"ab", 2, L"abc", 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_EXACT_MATCH(void) +{ + wchar_t const s[] = L"abcdef"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnistrn(s, 6, L"abc", 3)); + TEST_PTR_EQ(s, stlsoft_C_wcsnistrn(s, 3, L"abc", 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_CASE_FOLD_FULL(void) +{ + wchar_t const s[] = L"xxAbCxx"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnistrn(s, 7, L"aBc", 3)); + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnistrn(s, 7, L"ABC", 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_CASE_FOLD_IN_MIDDLE(void) +{ + wchar_t const s[] = L"aBc"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnistrn(s, 3, L"abc", 3)); + TEST_PTR_NULL(stlsoft_C_wcsnistrn(s, 3, L"axc", 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_CASE_FOLD_AT_END(void) +{ + wchar_t const s[] = L"zzAB"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnistrn(s, 4, L"ab", 2)); + TEST_PTR_NULL(stlsoft_C_wcsnistrn(s, 3, L"ab", 2)); +} + +static void TEST_stlsoft_C_wcsnistrn_MATCH_IN_MIDDLE(void) +{ + wchar_t const s[] = L"xxabcxx"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnistrn(s, 7, L"AbC", 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_MATCH_AT_END(void) +{ + wchar_t const s[] = L"xxabc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnistrn(s, 5, L"ABC", 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnistrn(L"abcdef", 6, L"zzz", 3)); + TEST_PTR_NULL(stlsoft_C_wcsnistrn(L"abcdef", 6, L"abx", 3)); + TEST_PTR_NULL(stlsoft_C_wcsnistrn(L"aXY", 3, L"abc", 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_FIRST_CHAR_ONLY_THEN_MATCH(void) +{ + wchar_t const s[] = L"aXYabc"; + + TEST_PTR_EQ(s + 3, stlsoft_C_wcsnistrn(s, 6, L"ABC", 3)); + TEST_PTR_NULL(stlsoft_C_wcsnistrn(L"aXY", 3, L"ABC", 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_DOES_NOT_READ_PAST_n1(void) +{ + wchar_t const s[] = L"xxabc"; + + TEST_PTR_NULL(stlsoft_C_wcsnistrn(s, 4, L"ABC", 3)); + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnistrn(s, 5, L"ABC", 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_DOES_NOT_READ_PAST_n2(void) +{ + wchar_t const hay[] = L"abX"; + wchar_t const needle[] = { L'A', L'B', L'Y' }; + + TEST_PTR_EQ(hay, stlsoft_C_wcsnistrn(hay, 3, needle, 2)); + TEST_PTR_NULL(stlsoft_C_wcsnistrn(hay, 3, needle, 3)); +} + +static void TEST_stlsoft_C_wcsnistrn_SINGLE_BYTE(void) +{ + wchar_t const s[] = L"xxA"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnistrn(s, 3, L"a", 1)); + TEST_PTR_NULL(stlsoft_C_wcsnistrn(s, 2, L"a", 1)); +} + +static void TEST_stlsoft_C_wcsnistrn_HIGH_BIT(void) +{ + wchar_t const hay[] = { L'\x00E9', L'A', L'b' }; + wchar_t const needle[] = { L'\x00E9', L'a', L'B' }; + wchar_t const other[] = { L'\x00E2', L'a' }; + + TEST_PTR_EQ(hay, stlsoft_C_wcsnistrn(hay, 3, needle, 3)); + TEST_PTR_NULL(stlsoft_C_wcsnistrn(hay, 2, other, 2)); +} + + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/test/unit/stlsoft/string/c_string/strnistrn/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnistrn/CMakeLists.txt new file mode 100644 index 000000000..c30c96bfc --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnistrn/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnistrn entry.cpp) diff --git a/test/unit/stlsoft/string/c_string/strnistrn/entry.cpp b/test/unit/stlsoft/string/c_string/strnistrn/entry.cpp new file mode 100644 index 000000000..9e0c6cc7a --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnistrn/entry.cpp @@ -0,0 +1,374 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnistrn/entry.cpp + * + * Purpose: Unit-tests for stlsoft::c_string::strnistrn() and wcsnistrn(). + * + * Created: 23rd October 2026 + * Updated: 25th October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +namespace +{ + + static void TEST_c_string_strnistrn_n2_0(); + static void TEST_c_string_strnistrn_n1_0(); + static void TEST_c_string_strnistrn_n2_GT_n1(); + static void TEST_c_string_strnistrn_EXACT_MATCH(); + static void TEST_c_string_strnistrn_CASE_FOLD_FULL(); + static void TEST_c_string_strnistrn_CASE_FOLD_IN_MIDDLE(); + static void TEST_c_string_strnistrn_CASE_FOLD_AT_END(); + static void TEST_c_string_strnistrn_MATCH_IN_MIDDLE(); + static void TEST_c_string_strnistrn_MATCH_AT_END(); + static void TEST_c_string_strnistrn_MISS(); + static void TEST_c_string_strnistrn_FIRST_CHAR_ONLY_THEN_MATCH(); + static void TEST_c_string_strnistrn_DOES_NOT_READ_PAST_n1(); + static void TEST_c_string_strnistrn_DOES_NOT_READ_PAST_n2(); + static void TEST_c_string_strnistrn_SINGLE_BYTE(); + static void TEST_c_string_strnistrn_HIGH_BIT(); + static void TEST_c_string_wcsnistrn_n2_0(); + static void TEST_c_string_wcsnistrn_n1_0(); + static void TEST_c_string_wcsnistrn_n2_GT_n1(); + static void TEST_c_string_wcsnistrn_EXACT_MATCH(); + static void TEST_c_string_wcsnistrn_CASE_FOLD_FULL(); + static void TEST_c_string_wcsnistrn_CASE_FOLD_IN_MIDDLE(); + static void TEST_c_string_wcsnistrn_CASE_FOLD_AT_END(); + static void TEST_c_string_wcsnistrn_MATCH_IN_MIDDLE(); + static void TEST_c_string_wcsnistrn_MATCH_AT_END(); + static void TEST_c_string_wcsnistrn_MISS(); + static void TEST_c_string_wcsnistrn_FIRST_CHAR_ONLY_THEN_MATCH(); + static void TEST_c_string_wcsnistrn_DOES_NOT_READ_PAST_n1(); + static void TEST_c_string_wcsnistrn_DOES_NOT_READ_PAST_n2(); + static void TEST_c_string_wcsnistrn_SINGLE_BYTE(); + static void TEST_c_string_wcsnistrn_HIGH_BIT(); + + static wchar_t const* wcsnistrn_both_(wchar_t const* s1, size_t n1, wchar_t const* s2, size_t n2); +} // anonymous namespace + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnistrn", verbosity)) + { + XTESTS_RUN_CASE(TEST_c_string_strnistrn_n2_0); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_n1_0); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_n2_GT_n1); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_EXACT_MATCH); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_CASE_FOLD_FULL); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_CASE_FOLD_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_CASE_FOLD_AT_END); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_MISS); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_FIRST_CHAR_ONLY_THEN_MATCH); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_DOES_NOT_READ_PAST_n1); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_DOES_NOT_READ_PAST_n2); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_SINGLE_BYTE); + XTESTS_RUN_CASE(TEST_c_string_strnistrn_HIGH_BIT); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_n2_0); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_n1_0); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_n2_GT_n1); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_EXACT_MATCH); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_CASE_FOLD_FULL); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_CASE_FOLD_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_CASE_FOLD_AT_END); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_MISS); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_FIRST_CHAR_ONLY_THEN_MATCH); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_DOES_NOT_READ_PAST_n1); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_DOES_NOT_READ_PAST_n2); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_SINGLE_BYTE); + XTESTS_RUN_CASE(TEST_c_string_wcsnistrn_HIGH_BIT); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +namespace +{ + +static wchar_t const* wcsnistrn_both_(wchar_t const* s1, size_t n1, wchar_t const* s2, size_t n2) +{ + wchar_t const* const via_str = stlsoft::c_string::strnistrn(s1, n1, s2, n2); + wchar_t const* const via_wcs = stlsoft::c_string::wcsnistrn(s1, n1, s2, n2); + + TEST_PTR_EQ(via_wcs, via_str); + + return via_wcs; +} + +static void TEST_c_string_strnistrn_n2_0() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnistrn(s, 3, "", 0)); + TEST_PTR_EQ(s, stlsoft::c_string::strnistrn(s, 0, "xyz", 0)); +} + +static void TEST_c_string_strnistrn_n1_0() +{ + TEST_PTR_NULL(stlsoft::c_string::strnistrn("abc", 0, "a", 1)); +} + +static void TEST_c_string_strnistrn_n2_GT_n1() +{ + TEST_PTR_NULL(stlsoft::c_string::strnistrn("ab", 2, "abc", 3)); +} + +static void TEST_c_string_strnistrn_EXACT_MATCH() +{ + char const s[] = "abcdef"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnistrn(s, 6, "abc", 3)); + TEST_PTR_EQ(s, stlsoft::c_string::strnistrn(s, 3, "abc", 3)); +} + +static void TEST_c_string_strnistrn_CASE_FOLD_FULL() +{ + char const s[] = "xxAbCxx"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnistrn(s, 7, "aBc", 3)); + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnistrn(s, 7, "ABC", 3)); +} + +static void TEST_c_string_strnistrn_CASE_FOLD_IN_MIDDLE() +{ + char const s[] = "aBc"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnistrn(s, 3, "abc", 3)); + TEST_PTR_NULL(stlsoft::c_string::strnistrn(s, 3, "axc", 3)); +} + +static void TEST_c_string_strnistrn_CASE_FOLD_AT_END() +{ + char const s[] = "zzAB"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnistrn(s, 4, "ab", 2)); + TEST_PTR_NULL(stlsoft::c_string::strnistrn(s, 3, "ab", 2)); +} + +static void TEST_c_string_strnistrn_MATCH_IN_MIDDLE() +{ + char const s[] = "xxabcxx"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnistrn(s, 7, "AbC", 3)); +} + +static void TEST_c_string_strnistrn_MATCH_AT_END() +{ + char const s[] = "xxabc"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnistrn(s, 5, "ABC", 3)); +} + +static void TEST_c_string_strnistrn_MISS() +{ + TEST_PTR_NULL(stlsoft::c_string::strnistrn("abcdef", 6, "zzz", 3)); + TEST_PTR_NULL(stlsoft::c_string::strnistrn("abcdef", 6, "abx", 3)); + TEST_PTR_NULL(stlsoft::c_string::strnistrn("aXY", 3, "abc", 3)); +} + +static void TEST_c_string_strnistrn_FIRST_CHAR_ONLY_THEN_MATCH() +{ + char const s[] = "aXYabc"; + + TEST_PTR_EQ(s + 3, stlsoft::c_string::strnistrn(s, 6, "ABC", 3)); + TEST_PTR_NULL(stlsoft::c_string::strnistrn("aXY", 3, "ABC", 3)); +} + +static void TEST_c_string_strnistrn_DOES_NOT_READ_PAST_n1() +{ + char const s[] = "xxabc"; + + TEST_PTR_NULL(stlsoft::c_string::strnistrn(s, 4, "ABC", 3)); + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnistrn(s, 5, "ABC", 3)); +} + +static void TEST_c_string_strnistrn_DOES_NOT_READ_PAST_n2() +{ + char const hay[] = "abX"; + char const needle[] = { 'A', 'B', 'Y' }; + + TEST_PTR_EQ(hay, stlsoft::c_string::strnistrn(hay, 3, needle, 2)); + TEST_PTR_NULL(stlsoft::c_string::strnistrn(hay, 3, needle, 3)); +} + +static void TEST_c_string_strnistrn_SINGLE_BYTE() +{ + char const s[] = "xxA"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnistrn(s, 3, "a", 1)); + TEST_PTR_NULL(stlsoft::c_string::strnistrn(s, 2, "a", 1)); +} + +static void TEST_c_string_strnistrn_HIGH_BIT() +{ + unsigned char const hay_u[] = { 0xE9, 'A', 'b' }; + unsigned char const needle_u[] = { 0xE9, 'a', 'B' }; + unsigned char const other_u[] = { 0xE2, 'a' }; + char const* const hay = reinterpret_cast(hay_u); + char const* const needle = reinterpret_cast(needle_u); + char const* const other = reinterpret_cast(other_u); + + TEST_PTR_EQ(hay, stlsoft::c_string::strnistrn(hay, 3, needle, 3)); + TEST_PTR_NULL(stlsoft::c_string::strnistrn(hay, 2, other, 2)); +} + +static void TEST_c_string_wcsnistrn_n2_0() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, wcsnistrn_both_(s, 3, L"", 0)); + TEST_PTR_EQ(s, wcsnistrn_both_(s, 0, L"xyz", 0)); +} + +static void TEST_c_string_wcsnistrn_n1_0() +{ + TEST_PTR_NULL(wcsnistrn_both_(L"abc", 0, L"a", 1)); +} + +static void TEST_c_string_wcsnistrn_n2_GT_n1() +{ + TEST_PTR_NULL(wcsnistrn_both_(L"ab", 2, L"abc", 3)); +} + +static void TEST_c_string_wcsnistrn_EXACT_MATCH() +{ + wchar_t const s[] = L"abcdef"; + + TEST_PTR_EQ(s, wcsnistrn_both_(s, 6, L"abc", 3)); + TEST_PTR_EQ(s, wcsnistrn_both_(s, 3, L"abc", 3)); +} + +static void TEST_c_string_wcsnistrn_CASE_FOLD_FULL() +{ + wchar_t const s[] = L"xxAbCxx"; + + TEST_PTR_EQ(s + 2, wcsnistrn_both_(s, 7, L"aBc", 3)); + TEST_PTR_EQ(s + 2, wcsnistrn_both_(s, 7, L"ABC", 3)); +} + +static void TEST_c_string_wcsnistrn_CASE_FOLD_IN_MIDDLE() +{ + wchar_t const s[] = L"aBc"; + + TEST_PTR_EQ(s, wcsnistrn_both_(s, 3, L"abc", 3)); + TEST_PTR_NULL(wcsnistrn_both_(s, 3, L"axc", 3)); +} + +static void TEST_c_string_wcsnistrn_CASE_FOLD_AT_END() +{ + wchar_t const s[] = L"zzAB"; + + TEST_PTR_EQ(s + 2, wcsnistrn_both_(s, 4, L"ab", 2)); + TEST_PTR_NULL(wcsnistrn_both_(s, 3, L"ab", 2)); +} + +static void TEST_c_string_wcsnistrn_MATCH_IN_MIDDLE() +{ + wchar_t const s[] = L"xxabcxx"; + + TEST_PTR_EQ(s + 2, wcsnistrn_both_(s, 7, L"AbC", 3)); +} + +static void TEST_c_string_wcsnistrn_MATCH_AT_END() +{ + wchar_t const s[] = L"xxabc"; + + TEST_PTR_EQ(s + 2, wcsnistrn_both_(s, 5, L"ABC", 3)); +} + +static void TEST_c_string_wcsnistrn_MISS() +{ + TEST_PTR_NULL(wcsnistrn_both_(L"abcdef", 6, L"zzz", 3)); + TEST_PTR_NULL(wcsnistrn_both_(L"abcdef", 6, L"abx", 3)); + TEST_PTR_NULL(wcsnistrn_both_(L"aXY", 3, L"abc", 3)); +} + +static void TEST_c_string_wcsnistrn_FIRST_CHAR_ONLY_THEN_MATCH() +{ + wchar_t const s[] = L"aXYabc"; + + TEST_PTR_EQ(s + 3, wcsnistrn_both_(s, 6, L"ABC", 3)); + TEST_PTR_NULL(wcsnistrn_both_(L"aXY", 3, L"ABC", 3)); +} + +static void TEST_c_string_wcsnistrn_DOES_NOT_READ_PAST_n1() +{ + wchar_t const s[] = L"xxabc"; + + TEST_PTR_NULL(wcsnistrn_both_(s, 4, L"ABC", 3)); + TEST_PTR_EQ(s + 2, wcsnistrn_both_(s, 5, L"ABC", 3)); +} + +static void TEST_c_string_wcsnistrn_DOES_NOT_READ_PAST_n2() +{ + wchar_t const hay[] = L"abX"; + wchar_t const needle[] = { L'A', L'B', L'Y' }; + + TEST_PTR_EQ(hay, wcsnistrn_both_(hay, 3, needle, 2)); + TEST_PTR_NULL(wcsnistrn_both_(hay, 3, needle, 3)); +} + +static void TEST_c_string_wcsnistrn_SINGLE_BYTE() +{ + wchar_t const s[] = L"xxA"; + + TEST_PTR_EQ(s + 2, wcsnistrn_both_(s, 3, L"a", 1)); + TEST_PTR_NULL(wcsnistrn_both_(s, 2, L"a", 1)); +} + +static void TEST_c_string_wcsnistrn_HIGH_BIT() +{ + wchar_t const hay[] = { L'\x00E9', L'A', L'b' }; + wchar_t const needle[] = { L'\x00E9', L'a', L'B' }; + wchar_t const other[] = { L'\x00E2', L'a' }; + + TEST_PTR_EQ(hay, wcsnistrn_both_(hay, 3, needle, 3)); + TEST_PTR_NULL(wcsnistrn_both_(hay, 2, other, 2)); +} +} // anonymous namespace + + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/test/unit/stlsoft/string/c_string/strnpbrkn.C/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnpbrkn.C/CMakeLists.txt new file mode 100644 index 000000000..9b2707e8b --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnpbrkn.C/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnpbrkn.C entry.c) diff --git a/test/unit/stlsoft/string/c_string/strnpbrkn.C/entry.c b/test/unit/stlsoft/string/c_string/strnpbrkn.C/entry.c new file mode 100644 index 000000000..b43737693 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnpbrkn.C/entry.c @@ -0,0 +1,325 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnpbrkn.C/entry.c + * + * Purpose: Unit-tests for stlsoft_C_strnpbrkn() and stlsoft_C_wcsnpbrkn(). + * + * Created: 23rd October 2026 + * Updated: 23rd October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +static void TEST_stlsoft_C_strnpbrkn_cchStr_0(void); +static void TEST_stlsoft_C_strnpbrkn_cchCharSet_0(void); +static void TEST_stlsoft_C_strnpbrkn_MATCH_AT_START_FIRST_IN_SET(void); +static void TEST_stlsoft_C_strnpbrkn_MATCH_AT_START_LAST_IN_SET(void); +static void TEST_stlsoft_C_strnpbrkn_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_strnpbrkn_MATCH_AT_END(void); +static void TEST_stlsoft_C_strnpbrkn_FIRST_OF_SEVERAL(void); +static void TEST_stlsoft_C_strnpbrkn_MISS(void); +static void TEST_stlsoft_C_strnpbrkn_DOES_NOT_READ_PAST_cchStr(void); +static void TEST_stlsoft_C_strnpbrkn_DOES_NOT_READ_PAST_cchCharSet(void); +static void TEST_stlsoft_C_strnpbrkn_EMBEDDED_NUL_IN_STRING(void); +static void TEST_stlsoft_C_strnpbrkn_NUL_IN_SET(void); +static void TEST_stlsoft_C_strnpbrkn_SINGLE_BYTE_SET(void); +static void TEST_stlsoft_C_strnpbrkn_SET_LONGER_THAN_STRING(void); +static void TEST_stlsoft_C_wcsnpbrkn_cchStr_0(void); +static void TEST_stlsoft_C_wcsnpbrkn_cchCharSet_0(void); +static void TEST_stlsoft_C_wcsnpbrkn_MATCH_AT_START_FIRST_IN_SET(void); +static void TEST_stlsoft_C_wcsnpbrkn_MATCH_AT_START_LAST_IN_SET(void); +static void TEST_stlsoft_C_wcsnpbrkn_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_wcsnpbrkn_MATCH_AT_END(void); +static void TEST_stlsoft_C_wcsnpbrkn_FIRST_OF_SEVERAL(void); +static void TEST_stlsoft_C_wcsnpbrkn_MISS(void); +static void TEST_stlsoft_C_wcsnpbrkn_DOES_NOT_READ_PAST_cchStr(void); +static void TEST_stlsoft_C_wcsnpbrkn_DOES_NOT_READ_PAST_cchCharSet(void); +static void TEST_stlsoft_C_wcsnpbrkn_EMBEDDED_NUL_IN_STRING(void); +static void TEST_stlsoft_C_wcsnpbrkn_NUL_IN_SET(void); +static void TEST_stlsoft_C_wcsnpbrkn_SINGLE_BYTE_SET(void); +static void TEST_stlsoft_C_wcsnpbrkn_SET_LONGER_THAN_STRING(void); + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnpbrkn.C", verbosity)) + { + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_cchStr_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_cchCharSet_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_MATCH_AT_START_FIRST_IN_SET); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_MATCH_AT_START_LAST_IN_SET); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_FIRST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_DOES_NOT_READ_PAST_cchStr); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_DOES_NOT_READ_PAST_cchCharSet); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_EMBEDDED_NUL_IN_STRING); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_NUL_IN_SET); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_SINGLE_BYTE_SET); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnpbrkn_SET_LONGER_THAN_STRING); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_cchStr_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_cchCharSet_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_MATCH_AT_START_FIRST_IN_SET); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_MATCH_AT_START_LAST_IN_SET); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_FIRST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_DOES_NOT_READ_PAST_cchStr); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_DOES_NOT_READ_PAST_cchCharSet); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_EMBEDDED_NUL_IN_STRING); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_NUL_IN_SET); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_SINGLE_BYTE_SET); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnpbrkn_SET_LONGER_THAN_STRING); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +static void TEST_stlsoft_C_strnpbrkn_cchStr_0(void) +{ + TEST_PTR_NULL(stlsoft_C_strnpbrkn("abc", 0, "a", 1)); + TEST_PTR_NULL(stlsoft_C_strnpbrkn("", 0, "", 0)); +} + +static void TEST_stlsoft_C_strnpbrkn_cchCharSet_0(void) +{ + TEST_PTR_NULL(stlsoft_C_strnpbrkn("abc", 3, "xyz", 0)); + TEST_PTR_NULL(stlsoft_C_strnpbrkn("abc", 3, "", 0)); +} + +static void TEST_stlsoft_C_strnpbrkn_MATCH_AT_START_FIRST_IN_SET(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft_C_strnpbrkn(s, 3, "ax", 2)); +} + +static void TEST_stlsoft_C_strnpbrkn_MATCH_AT_START_LAST_IN_SET(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft_C_strnpbrkn(s, 3, "xya", 3)); +} + +static void TEST_stlsoft_C_strnpbrkn_MATCH_IN_MIDDLE(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnpbrkn(s, 3, "xb", 2)); +} + +static void TEST_stlsoft_C_strnpbrkn_MATCH_AT_END(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnpbrkn(s, 3, "zc", 2)); +} + +static void TEST_stlsoft_C_strnpbrkn_FIRST_OF_SEVERAL(void) +{ + char const s[] = "bXa"; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnpbrkn(s, 3, "aX", 2)); +} + +static void TEST_stlsoft_C_strnpbrkn_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_strnpbrkn("abc", 3, "xyz", 3)); +} + +static void TEST_stlsoft_C_strnpbrkn_DOES_NOT_READ_PAST_cchStr(void) +{ + char const s[] = "abcZ"; + + TEST_PTR_NULL(stlsoft_C_strnpbrkn(s, 3, "Z", 1)); + TEST_PTR_EQ(s + 3, stlsoft_C_strnpbrkn(s, 4, "Z", 1)); +} + +static void TEST_stlsoft_C_strnpbrkn_DOES_NOT_READ_PAST_cchCharSet(void) +{ + char const str[] = "Zzz"; + char const set[] = { 'x', 'y', 'Z' }; + + TEST_PTR_NULL(stlsoft_C_strnpbrkn(str, 3, set, 2)); + TEST_PTR_EQ(str, stlsoft_C_strnpbrkn(str, 3, set, 3)); +} + +static void TEST_stlsoft_C_strnpbrkn_EMBEDDED_NUL_IN_STRING(void) +{ + char const str[] = { 'a', '\0', 'b' }; + char const set[] = { 'b' }; + + TEST_PTR_EQ(str + 2, stlsoft_C_strnpbrkn(str, 3, set, 1)); + TEST_PTR_NULL(stlsoft_C_strnpbrkn(str, 2, set, 1)); +} + +static void TEST_stlsoft_C_strnpbrkn_NUL_IN_SET(void) +{ + char const str[] = { 'a', '\0', 'b' }; + char const set[] = { 'x', '\0', 'q' }; + + TEST_PTR_EQ(str + 1, stlsoft_C_strnpbrkn(str, 3, set, 3)); + TEST_PTR_NULL(stlsoft_C_strnpbrkn(str, 3, set, 1)); +} + +static void TEST_stlsoft_C_strnpbrkn_SINGLE_BYTE_SET(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnpbrkn(s, 3, "b", 1)); + TEST_PTR_NULL(stlsoft_C_strnpbrkn(s, 3, "z", 1)); +} + +static void TEST_stlsoft_C_strnpbrkn_SET_LONGER_THAN_STRING(void) +{ + char const s[] = "b"; + + TEST_PTR_EQ(s, stlsoft_C_strnpbrkn(s, 1, "xyzb", 4)); + TEST_PTR_NULL(stlsoft_C_strnpbrkn(s, 1, "xyza", 4)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_cchStr_0(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(L"abc", 0, L"a", 1)); + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(L"", 0, L"", 0)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_cchCharSet_0(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(L"abc", 3, L"xyz", 0)); + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(L"abc", 3, L"", 0)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_MATCH_AT_START_FIRST_IN_SET(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnpbrkn(s, 3, L"ax", 2)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_MATCH_AT_START_LAST_IN_SET(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnpbrkn(s, 3, L"xya", 3)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_MATCH_IN_MIDDLE(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnpbrkn(s, 3, L"xb", 2)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_MATCH_AT_END(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnpbrkn(s, 3, L"zc", 2)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_FIRST_OF_SEVERAL(void) +{ + wchar_t const s[] = L"bXa"; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnpbrkn(s, 3, L"aX", 2)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(L"abc", 3, L"xyz", 3)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_DOES_NOT_READ_PAST_cchStr(void) +{ + wchar_t const s[] = L"abcZ"; + + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(s, 3, L"Z", 1)); + TEST_PTR_EQ(s + 3, stlsoft_C_wcsnpbrkn(s, 4, L"Z", 1)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_DOES_NOT_READ_PAST_cchCharSet(void) +{ + wchar_t const str[] = L"Zzz"; + wchar_t const set[] = { L'x', L'y', L'Z' }; + + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(str, 3, set, 2)); + TEST_PTR_EQ(str, stlsoft_C_wcsnpbrkn(str, 3, set, 3)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_EMBEDDED_NUL_IN_STRING(void) +{ + wchar_t const str[] = { L'a', L'\0', L'b' }; + wchar_t const set[] = { L'b' }; + + TEST_PTR_EQ(str + 2, stlsoft_C_wcsnpbrkn(str, 3, set, 1)); + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(str, 2, set, 1)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_NUL_IN_SET(void) +{ + wchar_t const str[] = { L'a', L'\0', L'b' }; + wchar_t const set[] = { L'x', L'\0', L'q' }; + + TEST_PTR_EQ(str + 1, stlsoft_C_wcsnpbrkn(str, 3, set, 3)); + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(str, 3, set, 1)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_SINGLE_BYTE_SET(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnpbrkn(s, 3, L"b", 1)); + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(s, 3, L"z", 1)); +} + +static void TEST_stlsoft_C_wcsnpbrkn_SET_LONGER_THAN_STRING(void) +{ + wchar_t const s[] = L"b"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnpbrkn(s, 1, L"xyzb", 4)); + TEST_PTR_NULL(stlsoft_C_wcsnpbrkn(s, 1, L"xyza", 4)); +} + + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/test/unit/stlsoft/string/c_string/strnpbrkn/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnpbrkn/CMakeLists.txt new file mode 100644 index 000000000..b345c981a --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnpbrkn/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnpbrkn entry.cpp) diff --git a/test/unit/stlsoft/string/c_string/strnpbrkn/entry.cpp b/test/unit/stlsoft/string/c_string/strnpbrkn/entry.cpp new file mode 100644 index 000000000..622b67d41 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnpbrkn/entry.cpp @@ -0,0 +1,345 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnpbrkn/entry.cpp + * + * Purpose: Unit-tests for stlsoft::c_string::strnpbrkn() and wcsnpbrkn(). + * + * Created: 23rd October 2026 + * Updated: 25th October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +namespace +{ + + static void TEST_c_string_strnpbrkn_cchStr_0(); + static void TEST_c_string_strnpbrkn_cchCharSet_0(); + static void TEST_c_string_strnpbrkn_MATCH_AT_START_FIRST_IN_SET(); + static void TEST_c_string_strnpbrkn_MATCH_AT_START_LAST_IN_SET(); + static void TEST_c_string_strnpbrkn_MATCH_IN_MIDDLE(); + static void TEST_c_string_strnpbrkn_MATCH_AT_END(); + static void TEST_c_string_strnpbrkn_FIRST_OF_SEVERAL(); + static void TEST_c_string_strnpbrkn_MISS(); + static void TEST_c_string_strnpbrkn_DOES_NOT_READ_PAST_cchStr(); + static void TEST_c_string_strnpbrkn_DOES_NOT_READ_PAST_cchCharSet(); + static void TEST_c_string_strnpbrkn_EMBEDDED_NUL_IN_STRING(); + static void TEST_c_string_strnpbrkn_NUL_IN_SET(); + static void TEST_c_string_strnpbrkn_SINGLE_BYTE_SET(); + static void TEST_c_string_strnpbrkn_SET_LONGER_THAN_STRING(); + static void TEST_c_string_wcsnpbrkn_cchStr_0(); + static void TEST_c_string_wcsnpbrkn_cchCharSet_0(); + static void TEST_c_string_wcsnpbrkn_MATCH_AT_START_FIRST_IN_SET(); + static void TEST_c_string_wcsnpbrkn_MATCH_AT_START_LAST_IN_SET(); + static void TEST_c_string_wcsnpbrkn_MATCH_IN_MIDDLE(); + static void TEST_c_string_wcsnpbrkn_MATCH_AT_END(); + static void TEST_c_string_wcsnpbrkn_FIRST_OF_SEVERAL(); + static void TEST_c_string_wcsnpbrkn_MISS(); + static void TEST_c_string_wcsnpbrkn_DOES_NOT_READ_PAST_cchStr(); + static void TEST_c_string_wcsnpbrkn_DOES_NOT_READ_PAST_cchCharSet(); + static void TEST_c_string_wcsnpbrkn_EMBEDDED_NUL_IN_STRING(); + static void TEST_c_string_wcsnpbrkn_NUL_IN_SET(); + static void TEST_c_string_wcsnpbrkn_SINGLE_BYTE_SET(); + static void TEST_c_string_wcsnpbrkn_SET_LONGER_THAN_STRING(); + + static wchar_t const* wcsnpbrkn_both_(wchar_t const* str, size_t cchStr, wchar_t const* charSet, size_t cchCharSet); +} // anonymous namespace + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnpbrkn", verbosity)) + { + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_cchStr_0); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_cchCharSet_0); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_MATCH_AT_START_FIRST_IN_SET); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_MATCH_AT_START_LAST_IN_SET); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_FIRST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_MISS); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_DOES_NOT_READ_PAST_cchStr); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_DOES_NOT_READ_PAST_cchCharSet); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_EMBEDDED_NUL_IN_STRING); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_NUL_IN_SET); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_SINGLE_BYTE_SET); + XTESTS_RUN_CASE(TEST_c_string_strnpbrkn_SET_LONGER_THAN_STRING); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_cchStr_0); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_cchCharSet_0); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_MATCH_AT_START_FIRST_IN_SET); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_MATCH_AT_START_LAST_IN_SET); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_FIRST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_MISS); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_DOES_NOT_READ_PAST_cchStr); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_DOES_NOT_READ_PAST_cchCharSet); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_EMBEDDED_NUL_IN_STRING); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_NUL_IN_SET); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_SINGLE_BYTE_SET); + XTESTS_RUN_CASE(TEST_c_string_wcsnpbrkn_SET_LONGER_THAN_STRING); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +namespace +{ + +static wchar_t const* wcsnpbrkn_both_(wchar_t const* str, size_t cchStr, wchar_t const* charSet, size_t cchCharSet) +{ + wchar_t const* const via_str = stlsoft::c_string::strnpbrkn(str, cchStr, charSet, cchCharSet); + wchar_t const* const via_wcs = stlsoft::c_string::wcsnpbrkn(str, cchStr, charSet, cchCharSet); + + TEST_PTR_EQ(via_wcs, via_str); + + return via_wcs; +} + +static void TEST_c_string_strnpbrkn_cchStr_0() +{ + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn("abc", 0, "a", 1)); + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn("", 0, "", 0)); +} + +static void TEST_c_string_strnpbrkn_cchCharSet_0() +{ + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn("abc", 3, "xyz", 0)); + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn("abc", 3, "", 0)); +} + +static void TEST_c_string_strnpbrkn_MATCH_AT_START_FIRST_IN_SET() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnpbrkn(s, 3, "ax", 2)); +} + +static void TEST_c_string_strnpbrkn_MATCH_AT_START_LAST_IN_SET() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnpbrkn(s, 3, "xya", 3)); +} + +static void TEST_c_string_strnpbrkn_MATCH_IN_MIDDLE() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnpbrkn(s, 3, "xb", 2)); +} + +static void TEST_c_string_strnpbrkn_MATCH_AT_END() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnpbrkn(s, 3, "zc", 2)); +} + +static void TEST_c_string_strnpbrkn_FIRST_OF_SEVERAL() +{ + char const s[] = "bXa"; + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnpbrkn(s, 3, "aX", 2)); +} + +static void TEST_c_string_strnpbrkn_MISS() +{ + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn("abc", 3, "xyz", 3)); +} + +static void TEST_c_string_strnpbrkn_DOES_NOT_READ_PAST_cchStr() +{ + char const s[] = "abcZ"; + + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn(s, 3, "Z", 1)); + TEST_PTR_EQ(s + 3, stlsoft::c_string::strnpbrkn(s, 4, "Z", 1)); +} + +static void TEST_c_string_strnpbrkn_DOES_NOT_READ_PAST_cchCharSet() +{ + char const str[] = "Zzz"; + char const set[] = { 'x', 'y', 'Z' }; + + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn(str, 3, set, 2)); + TEST_PTR_EQ(str, stlsoft::c_string::strnpbrkn(str, 3, set, 3)); +} + +static void TEST_c_string_strnpbrkn_EMBEDDED_NUL_IN_STRING() +{ + char const str[] = { 'a', '\0', 'b' }; + char const set[] = { 'b' }; + + TEST_PTR_EQ(str + 2, stlsoft::c_string::strnpbrkn(str, 3, set, 1)); + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn(str, 2, set, 1)); +} + +static void TEST_c_string_strnpbrkn_NUL_IN_SET() +{ + char const str[] = { 'a', '\0', 'b' }; + char const set[] = { 'x', '\0', 'q' }; + + TEST_PTR_EQ(str + 1, stlsoft::c_string::strnpbrkn(str, 3, set, 3)); + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn(str, 3, set, 1)); +} + +static void TEST_c_string_strnpbrkn_SINGLE_BYTE_SET() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnpbrkn(s, 3, "b", 1)); + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn(s, 3, "z", 1)); +} + +static void TEST_c_string_strnpbrkn_SET_LONGER_THAN_STRING() +{ + char const s[] = "b"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnpbrkn(s, 1, "xyzb", 4)); + TEST_PTR_NULL(stlsoft::c_string::strnpbrkn(s, 1, "xyza", 4)); +} + +static void TEST_c_string_wcsnpbrkn_cchStr_0() +{ + TEST_PTR_NULL(wcsnpbrkn_both_(L"abc", 0, L"a", 1)); + TEST_PTR_NULL(wcsnpbrkn_both_(L"", 0, L"", 0)); +} + +static void TEST_c_string_wcsnpbrkn_cchCharSet_0() +{ + TEST_PTR_NULL(wcsnpbrkn_both_(L"abc", 3, L"xyz", 0)); + TEST_PTR_NULL(wcsnpbrkn_both_(L"abc", 3, L"", 0)); +} + +static void TEST_c_string_wcsnpbrkn_MATCH_AT_START_FIRST_IN_SET() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, wcsnpbrkn_both_(s, 3, L"ax", 2)); +} + +static void TEST_c_string_wcsnpbrkn_MATCH_AT_START_LAST_IN_SET() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, wcsnpbrkn_both_(s, 3, L"xya", 3)); +} + +static void TEST_c_string_wcsnpbrkn_MATCH_IN_MIDDLE() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, wcsnpbrkn_both_(s, 3, L"xb", 2)); +} + +static void TEST_c_string_wcsnpbrkn_MATCH_AT_END() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 2, wcsnpbrkn_both_(s, 3, L"zc", 2)); +} + +static void TEST_c_string_wcsnpbrkn_FIRST_OF_SEVERAL() +{ + wchar_t const s[] = L"bXa"; + + TEST_PTR_EQ(s + 1, wcsnpbrkn_both_(s, 3, L"aX", 2)); +} + +static void TEST_c_string_wcsnpbrkn_MISS() +{ + TEST_PTR_NULL(wcsnpbrkn_both_(L"abc", 3, L"xyz", 3)); +} + +static void TEST_c_string_wcsnpbrkn_DOES_NOT_READ_PAST_cchStr() +{ + wchar_t const s[] = L"abcZ"; + + TEST_PTR_NULL(wcsnpbrkn_both_(s, 3, L"Z", 1)); + TEST_PTR_EQ(s + 3, wcsnpbrkn_both_(s, 4, L"Z", 1)); +} + +static void TEST_c_string_wcsnpbrkn_DOES_NOT_READ_PAST_cchCharSet() +{ + wchar_t const str[] = L"Zzz"; + wchar_t const set[] = { L'x', L'y', L'Z' }; + + TEST_PTR_NULL(wcsnpbrkn_both_(str, 3, set, 2)); + TEST_PTR_EQ(str, wcsnpbrkn_both_(str, 3, set, 3)); +} + +static void TEST_c_string_wcsnpbrkn_EMBEDDED_NUL_IN_STRING() +{ + wchar_t const str[] = { L'a', L'\0', L'b' }; + wchar_t const set[] = { L'b' }; + + TEST_PTR_EQ(str + 2, wcsnpbrkn_both_(str, 3, set, 1)); + TEST_PTR_NULL(wcsnpbrkn_both_(str, 2, set, 1)); +} + +static void TEST_c_string_wcsnpbrkn_NUL_IN_SET() +{ + wchar_t const str[] = { L'a', L'\0', L'b' }; + wchar_t const set[] = { L'x', L'\0', L'q' }; + + TEST_PTR_EQ(str + 1, wcsnpbrkn_both_(str, 3, set, 3)); + TEST_PTR_NULL(wcsnpbrkn_both_(str, 3, set, 1)); +} + +static void TEST_c_string_wcsnpbrkn_SINGLE_BYTE_SET() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, wcsnpbrkn_both_(s, 3, L"b", 1)); + TEST_PTR_NULL(wcsnpbrkn_both_(s, 3, L"z", 1)); +} + +static void TEST_c_string_wcsnpbrkn_SET_LONGER_THAN_STRING() +{ + wchar_t const s[] = L"b"; + + TEST_PTR_EQ(s, wcsnpbrkn_both_(s, 1, L"xyzb", 4)); + TEST_PTR_NULL(wcsnpbrkn_both_(s, 1, L"xyza", 4)); +} +} // anonymous namespace + + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/test/unit/stlsoft/string/c_string/strnrchr.C/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnrchr.C/CMakeLists.txt new file mode 100644 index 000000000..7b30a40c0 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnrchr.C/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnrchr.C entry.c) diff --git a/test/unit/stlsoft/string/c_string/strnrchr.C/entry.c b/test/unit/stlsoft/string/c_string/strnrchr.C/entry.c new file mode 100644 index 000000000..32bd47a71 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnrchr.C/entry.c @@ -0,0 +1,254 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnrchr.C/entry.c + * + * Purpose: Unit-tests for stlsoft_C_strnrchr() and stlsoft_C_wcsnrchr(). + * + * Created: 23rd October 2026 + * Updated: 23rd October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +static void TEST_stlsoft_C_strnrchr_n_0(void); +static void TEST_stlsoft_C_strnrchr_MATCH_AT_END(void); +static void TEST_stlsoft_C_strnrchr_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_strnrchr_MATCH_AT_START(void); +static void TEST_stlsoft_C_strnrchr_LAST_OF_SEVERAL(void); +static void TEST_stlsoft_C_strnrchr_MISS(void); +static void TEST_stlsoft_C_strnrchr_DOES_NOT_READ_PAST_n(void); +static void TEST_stlsoft_C_strnrchr_FINDS_EMBEDDED_NUL(void); +static void TEST_stlsoft_C_strnrchr_CONTINUES_PAST_NUL(void); +static void TEST_stlsoft_C_strnrchr_HIGH_BIT(void); +static void TEST_stlsoft_C_wcsnrchr_n_0(void); +static void TEST_stlsoft_C_wcsnrchr_MATCH_AT_END(void); +static void TEST_stlsoft_C_wcsnrchr_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_wcsnrchr_MATCH_AT_START(void); +static void TEST_stlsoft_C_wcsnrchr_LAST_OF_SEVERAL(void); +static void TEST_stlsoft_C_wcsnrchr_MISS(void); +static void TEST_stlsoft_C_wcsnrchr_DOES_NOT_READ_PAST_n(void); +static void TEST_stlsoft_C_wcsnrchr_FINDS_EMBEDDED_NUL(void); +static void TEST_stlsoft_C_wcsnrchr_CONTINUES_PAST_NUL(void); +static void TEST_stlsoft_C_wcsnrchr_HIGH_BIT(void); + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnrchr.C", verbosity)) + { + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_n_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_LAST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_DOES_NOT_READ_PAST_n); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_FINDS_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_CONTINUES_PAST_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnrchr_HIGH_BIT); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_n_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_LAST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_DOES_NOT_READ_PAST_n); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_FINDS_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_CONTINUES_PAST_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnrchr_HIGH_BIT); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +static void TEST_stlsoft_C_strnrchr_n_0(void) +{ + TEST_PTR_NULL(stlsoft_C_strnrchr("abc", 0, 'a')); + TEST_PTR_NULL(stlsoft_C_strnrchr("", 0, '\0')); +} + +static void TEST_stlsoft_C_strnrchr_MATCH_AT_END(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnrchr(s, 3, 'c')); + TEST_PTR_EQ(s, stlsoft_C_strnrchr(s, 1, 'a')); +} + +static void TEST_stlsoft_C_strnrchr_MATCH_IN_MIDDLE(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnrchr(s, 3, 'b')); +} + +static void TEST_stlsoft_C_strnrchr_MATCH_AT_START(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft_C_strnrchr(s, 3, 'a')); +} + +static void TEST_stlsoft_C_strnrchr_LAST_OF_SEVERAL(void) +{ + char const s[] = "abaca"; + + TEST_PTR_EQ(s + 4, stlsoft_C_strnrchr(s, 5, 'a')); + TEST_PTR_EQ(s + 2, stlsoft_C_strnrchr(s, 4, 'a')); +} + +static void TEST_stlsoft_C_strnrchr_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_strnrchr("abc", 3, 'z')); + TEST_PTR_NULL(stlsoft_C_strnrchr("abc", 3, 'A')); +} + +static void TEST_stlsoft_C_strnrchr_DOES_NOT_READ_PAST_n(void) +{ + char const s[] = "abc"; + + TEST_PTR_NULL(stlsoft_C_strnrchr(s, 2, 'c')); + TEST_PTR_EQ(s + 2, stlsoft_C_strnrchr(s, 3, 'c')); +} + +static void TEST_stlsoft_C_strnrchr_FINDS_EMBEDDED_NUL(void) +{ + char const s[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnrchr(s, 3, '\0')); +} + +static void TEST_stlsoft_C_strnrchr_CONTINUES_PAST_NUL(void) +{ + char const s[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(s, stlsoft_C_strnrchr(s, 3, 'a')); + TEST_PTR_EQ(s + 2, stlsoft_C_strnrchr(s, 3, 'b')); + TEST_PTR_NULL(stlsoft_C_strnrchr(s, 1, 'b')); +} + +static void TEST_stlsoft_C_strnrchr_HIGH_BIT(void) +{ + unsigned char const s_u[] = { 'a', 0xE9, 'b' }; + char const* const s = (char const*)s_u; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnrchr(s, 3, s[1])); + TEST_PTR_EQ(s, stlsoft_C_strnrchr(s, 1, 'a')); + TEST_PTR_NULL(stlsoft_C_strnrchr(s, 3, 'x')); +} + +static void TEST_stlsoft_C_wcsnrchr_n_0(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnrchr(L"abc", 0, L'a')); + TEST_PTR_NULL(stlsoft_C_wcsnrchr(L"", 0, L'\0')); +} + +static void TEST_stlsoft_C_wcsnrchr_MATCH_AT_END(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnrchr(s, 3, L'c')); + TEST_PTR_EQ(s, stlsoft_C_wcsnrchr(s, 1, L'a')); +} + +static void TEST_stlsoft_C_wcsnrchr_MATCH_IN_MIDDLE(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnrchr(s, 3, L'b')); +} + +static void TEST_stlsoft_C_wcsnrchr_MATCH_AT_START(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnrchr(s, 3, L'a')); +} + +static void TEST_stlsoft_C_wcsnrchr_LAST_OF_SEVERAL(void) +{ + wchar_t const s[] = L"abaca"; + + TEST_PTR_EQ(s + 4, stlsoft_C_wcsnrchr(s, 5, L'a')); + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnrchr(s, 4, L'a')); +} + +static void TEST_stlsoft_C_wcsnrchr_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnrchr(L"abc", 3, L'z')); + TEST_PTR_NULL(stlsoft_C_wcsnrchr(L"abc", 3, L'A')); +} + +static void TEST_stlsoft_C_wcsnrchr_DOES_NOT_READ_PAST_n(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_NULL(stlsoft_C_wcsnrchr(s, 2, L'c')); + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnrchr(s, 3, L'c')); +} + +static void TEST_stlsoft_C_wcsnrchr_FINDS_EMBEDDED_NUL(void) +{ + wchar_t const s[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnrchr(s, 3, L'\0')); +} + +static void TEST_stlsoft_C_wcsnrchr_CONTINUES_PAST_NUL(void) +{ + wchar_t const s[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(s, stlsoft_C_wcsnrchr(s, 3, L'a')); + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnrchr(s, 3, L'b')); + TEST_PTR_NULL(stlsoft_C_wcsnrchr(s, 1, L'b')); +} + +static void TEST_stlsoft_C_wcsnrchr_HIGH_BIT(void) +{ + wchar_t const s[] = { L'a', L'\x00E9', L'b' }; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnrchr(s, 3, s[1])); + TEST_PTR_EQ(s, stlsoft_C_wcsnrchr(s, 1, L'a')); + TEST_PTR_NULL(stlsoft_C_wcsnrchr(s, 3, L'x')); +} + + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/test/unit/stlsoft/string/c_string/strnrchr/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnrchr/CMakeLists.txt new file mode 100644 index 000000000..82686f1a3 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnrchr/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnrchr entry.cpp) diff --git a/test/unit/stlsoft/string/c_string/strnrchr/entry.cpp b/test/unit/stlsoft/string/c_string/strnrchr/entry.cpp new file mode 100644 index 000000000..89fdcad4e --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnrchr/entry.cpp @@ -0,0 +1,274 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnrchr/entry.cpp + * + * Purpose: Unit-tests for stlsoft::c_string::strnrchr() and wcsnrchr(). + * + * Created: 23rd October 2026 + * Updated: 25th October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +namespace +{ + + static void TEST_c_string_strnrchr_n_0(); + static void TEST_c_string_strnrchr_MATCH_AT_END(); + static void TEST_c_string_strnrchr_MATCH_IN_MIDDLE(); + static void TEST_c_string_strnrchr_MATCH_AT_START(); + static void TEST_c_string_strnrchr_LAST_OF_SEVERAL(); + static void TEST_c_string_strnrchr_MISS(); + static void TEST_c_string_strnrchr_DOES_NOT_READ_PAST_n(); + static void TEST_c_string_strnrchr_FINDS_EMBEDDED_NUL(); + static void TEST_c_string_strnrchr_CONTINUES_PAST_NUL(); + static void TEST_c_string_strnrchr_HIGH_BIT(); + static void TEST_c_string_wcsnrchr_n_0(); + static void TEST_c_string_wcsnrchr_MATCH_AT_END(); + static void TEST_c_string_wcsnrchr_MATCH_IN_MIDDLE(); + static void TEST_c_string_wcsnrchr_MATCH_AT_START(); + static void TEST_c_string_wcsnrchr_LAST_OF_SEVERAL(); + static void TEST_c_string_wcsnrchr_MISS(); + static void TEST_c_string_wcsnrchr_DOES_NOT_READ_PAST_n(); + static void TEST_c_string_wcsnrchr_FINDS_EMBEDDED_NUL(); + static void TEST_c_string_wcsnrchr_CONTINUES_PAST_NUL(); + static void TEST_c_string_wcsnrchr_HIGH_BIT(); + + static wchar_t const* wcsnrchr_both_(wchar_t const* s, size_t n, int ch); +} // anonymous namespace + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnrchr", verbosity)) + { + XTESTS_RUN_CASE(TEST_c_string_strnrchr_n_0); + XTESTS_RUN_CASE(TEST_c_string_strnrchr_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_strnrchr_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_strnrchr_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_c_string_strnrchr_LAST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_c_string_strnrchr_MISS); + XTESTS_RUN_CASE(TEST_c_string_strnrchr_DOES_NOT_READ_PAST_n); + XTESTS_RUN_CASE(TEST_c_string_strnrchr_FINDS_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_c_string_strnrchr_CONTINUES_PAST_NUL); + XTESTS_RUN_CASE(TEST_c_string_strnrchr_HIGH_BIT); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_n_0); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_LAST_OF_SEVERAL); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_MISS); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_DOES_NOT_READ_PAST_n); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_FINDS_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_CONTINUES_PAST_NUL); + XTESTS_RUN_CASE(TEST_c_string_wcsnrchr_HIGH_BIT); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +namespace +{ + +static wchar_t const* wcsnrchr_both_(wchar_t const* s, size_t n, int ch) +{ + wchar_t const* const via_str = stlsoft::c_string::strnrchr(s, n, ch); + wchar_t const* const via_wcs = stlsoft::c_string::wcsnrchr(s, n, ch); + + TEST_PTR_EQ(via_wcs, via_str); + + return via_wcs; +} + +static void TEST_c_string_strnrchr_n_0() +{ + TEST_PTR_NULL(stlsoft::c_string::strnrchr("abc", 0, 'a')); + TEST_PTR_NULL(stlsoft::c_string::strnrchr("", 0, '\0')); +} + +static void TEST_c_string_strnrchr_MATCH_AT_END() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnrchr(s, 3, 'c')); + TEST_PTR_EQ(s, stlsoft::c_string::strnrchr(s, 1, 'a')); +} + +static void TEST_c_string_strnrchr_MATCH_IN_MIDDLE() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnrchr(s, 3, 'b')); +} + +static void TEST_c_string_strnrchr_MATCH_AT_START() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnrchr(s, 3, 'a')); +} + +static void TEST_c_string_strnrchr_LAST_OF_SEVERAL() +{ + char const s[] = "abaca"; + + TEST_PTR_EQ(s + 4, stlsoft::c_string::strnrchr(s, 5, 'a')); + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnrchr(s, 4, 'a')); +} + +static void TEST_c_string_strnrchr_MISS() +{ + TEST_PTR_NULL(stlsoft::c_string::strnrchr("abc", 3, 'z')); + TEST_PTR_NULL(stlsoft::c_string::strnrchr("abc", 3, 'A')); +} + +static void TEST_c_string_strnrchr_DOES_NOT_READ_PAST_n() +{ + char const s[] = "abc"; + + TEST_PTR_NULL(stlsoft::c_string::strnrchr(s, 2, 'c')); + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnrchr(s, 3, 'c')); +} + +static void TEST_c_string_strnrchr_FINDS_EMBEDDED_NUL() +{ + char const s[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnrchr(s, 3, '\0')); +} + +static void TEST_c_string_strnrchr_CONTINUES_PAST_NUL() +{ + char const s[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(s, stlsoft::c_string::strnrchr(s, 3, 'a')); + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnrchr(s, 3, 'b')); + TEST_PTR_NULL(stlsoft::c_string::strnrchr(s, 1, 'b')); +} + +static void TEST_c_string_strnrchr_HIGH_BIT() +{ + unsigned char const s_u[] = { 'a', 0xE9, 'b' }; + char const* const s = reinterpret_cast(s_u); + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnrchr(s, 3, s[1])); + TEST_PTR_EQ(s, stlsoft::c_string::strnrchr(s, 1, 'a')); + TEST_PTR_NULL(stlsoft::c_string::strnrchr(s, 3, 'x')); +} + +static void TEST_c_string_wcsnrchr_n_0() +{ + TEST_PTR_NULL(wcsnrchr_both_(L"abc", 0, L'a')); + TEST_PTR_NULL(wcsnrchr_both_(L"", 0, L'\0')); +} + +static void TEST_c_string_wcsnrchr_MATCH_AT_END() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 2, wcsnrchr_both_(s, 3, L'c')); + TEST_PTR_EQ(s, wcsnrchr_both_(s, 1, L'a')); +} + +static void TEST_c_string_wcsnrchr_MATCH_IN_MIDDLE() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, wcsnrchr_both_(s, 3, L'b')); +} + +static void TEST_c_string_wcsnrchr_MATCH_AT_START() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, wcsnrchr_both_(s, 3, L'a')); +} + +static void TEST_c_string_wcsnrchr_LAST_OF_SEVERAL() +{ + wchar_t const s[] = L"abaca"; + + TEST_PTR_EQ(s + 4, wcsnrchr_both_(s, 5, L'a')); + TEST_PTR_EQ(s + 2, wcsnrchr_both_(s, 4, L'a')); +} + +static void TEST_c_string_wcsnrchr_MISS() +{ + TEST_PTR_NULL(wcsnrchr_both_(L"abc", 3, L'z')); + TEST_PTR_NULL(wcsnrchr_both_(L"abc", 3, L'A')); +} + +static void TEST_c_string_wcsnrchr_DOES_NOT_READ_PAST_n() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_NULL(wcsnrchr_both_(s, 2, L'c')); + TEST_PTR_EQ(s + 2, wcsnrchr_both_(s, 3, L'c')); +} + +static void TEST_c_string_wcsnrchr_FINDS_EMBEDDED_NUL() +{ + wchar_t const s[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(s + 1, wcsnrchr_both_(s, 3, L'\0')); +} + +static void TEST_c_string_wcsnrchr_CONTINUES_PAST_NUL() +{ + wchar_t const s[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(s, wcsnrchr_both_(s, 3, L'a')); + TEST_PTR_EQ(s + 2, wcsnrchr_both_(s, 3, L'b')); + TEST_PTR_NULL(wcsnrchr_both_(s, 1, L'b')); +} + +static void TEST_c_string_wcsnrchr_HIGH_BIT() +{ + wchar_t const s[] = { L'a', L'\x00E9', L'b' }; + + TEST_PTR_EQ(s + 1, wcsnrchr_both_(s, 3, s[1])); + TEST_PTR_EQ(s, wcsnrchr_both_(s, 1, L'a')); + TEST_PTR_NULL(wcsnrchr_both_(s, 3, L'x')); +} +} // anonymous namespace + + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/test/unit/stlsoft/string/c_string/strnstrn.C/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnstrn.C/CMakeLists.txt new file mode 100644 index 000000000..52a7dbc2f --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnstrn.C/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnstrn.C entry.c) diff --git a/test/unit/stlsoft/string/c_string/strnstrn.C/entry.c b/test/unit/stlsoft/string/c_string/strnstrn.C/entry.c new file mode 100644 index 000000000..d9482ee77 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnstrn.C/entry.c @@ -0,0 +1,337 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnstrn.C/entry.c + * + * Purpose: Unit-tests for stlsoft_C_strnstrn() and stlsoft_C_wcsnstrn(). + * + * Created: 23rd October 2026 + * Updated: 23rd October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +static void TEST_stlsoft_C_strnstrn_n2_0(void); +static void TEST_stlsoft_C_strnstrn_n1_0(void); +static void TEST_stlsoft_C_strnstrn_n2_GT_n1(void); +static void TEST_stlsoft_C_strnstrn_MATCH_AT_START(void); +static void TEST_stlsoft_C_strnstrn_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_strnstrn_MATCH_AT_END(void); +static void TEST_stlsoft_C_strnstrn_MISS(void); +static void TEST_stlsoft_C_strnstrn_PARTIAL_THEN_MATCH(void); +static void TEST_stlsoft_C_strnstrn_REPEATED_FIRST_BYTE(void); +static void TEST_stlsoft_C_strnstrn_DOES_NOT_READ_PAST_n1(void); +static void TEST_stlsoft_C_strnstrn_DOES_NOT_READ_PAST_n2(void); +static void TEST_stlsoft_C_strnstrn_EMBEDDED_NUL(void); +static void TEST_stlsoft_C_strnstrn_SINGLE_BYTE(void); +static void TEST_stlsoft_C_strnstrn_FULL_SPAN(void); +static void TEST_stlsoft_C_wcsnstrn_n2_0(void); +static void TEST_stlsoft_C_wcsnstrn_n1_0(void); +static void TEST_stlsoft_C_wcsnstrn_n2_GT_n1(void); +static void TEST_stlsoft_C_wcsnstrn_MATCH_AT_START(void); +static void TEST_stlsoft_C_wcsnstrn_MATCH_IN_MIDDLE(void); +static void TEST_stlsoft_C_wcsnstrn_MATCH_AT_END(void); +static void TEST_stlsoft_C_wcsnstrn_MISS(void); +static void TEST_stlsoft_C_wcsnstrn_PARTIAL_THEN_MATCH(void); +static void TEST_stlsoft_C_wcsnstrn_REPEATED_FIRST_BYTE(void); +static void TEST_stlsoft_C_wcsnstrn_DOES_NOT_READ_PAST_n1(void); +static void TEST_stlsoft_C_wcsnstrn_DOES_NOT_READ_PAST_n2(void); +static void TEST_stlsoft_C_wcsnstrn_EMBEDDED_NUL(void); +static void TEST_stlsoft_C_wcsnstrn_SINGLE_BYTE(void); +static void TEST_stlsoft_C_wcsnstrn_FULL_SPAN(void); + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnstrn.C", verbosity)) + { + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_n2_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_n1_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_n2_GT_n1); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_PARTIAL_THEN_MATCH); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_REPEATED_FIRST_BYTE); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_DOES_NOT_READ_PAST_n1); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_DOES_NOT_READ_PAST_n2); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_SINGLE_BYTE); + XTESTS_RUN_CASE(TEST_stlsoft_C_strnstrn_FULL_SPAN); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_n2_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_n1_0); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_n2_GT_n1); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_MISS); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_PARTIAL_THEN_MATCH); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_REPEATED_FIRST_BYTE); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_DOES_NOT_READ_PAST_n1); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_DOES_NOT_READ_PAST_n2); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_SINGLE_BYTE); + XTESTS_RUN_CASE(TEST_stlsoft_C_wcsnstrn_FULL_SPAN); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +static void TEST_stlsoft_C_strnstrn_n2_0(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft_C_strnstrn(s, 3, "", 0)); + TEST_PTR_EQ(s, stlsoft_C_strnstrn(s, 0, "", 0)); + TEST_PTR_EQ(s, stlsoft_C_strnstrn(s, 3, "xyz", 0)); +} + +static void TEST_stlsoft_C_strnstrn_n1_0(void) +{ + char const s[] = "abc"; + + TEST_PTR_NULL(stlsoft_C_strnstrn(s, 0, "a", 1)); +} + +static void TEST_stlsoft_C_strnstrn_n2_GT_n1(void) +{ + TEST_PTR_NULL(stlsoft_C_strnstrn("ab", 2, "abc", 3)); + TEST_PTR_NULL(stlsoft_C_strnstrn("abcd", 4, "abcde", 5)); +} + +static void TEST_stlsoft_C_strnstrn_MATCH_AT_START(void) +{ + char const s[] = "abcdef"; + + TEST_PTR_EQ(s, stlsoft_C_strnstrn(s, 6, "abc", 3)); + TEST_PTR_EQ(s, stlsoft_C_strnstrn(s, 3, "abc", 3)); +} + +static void TEST_stlsoft_C_strnstrn_MATCH_IN_MIDDLE(void) +{ + char const s[] = "xxabcxx"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnstrn(s, 7, "abc", 3)); +} + +static void TEST_stlsoft_C_strnstrn_MATCH_AT_END(void) +{ + char const s[] = "xxabc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_strnstrn(s, 5, "abc", 3)); + TEST_PTR_NULL(stlsoft_C_strnstrn(s, 4, "abc", 3)); +} + +static void TEST_stlsoft_C_strnstrn_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_strnstrn("abcdef", 6, "zzz", 3)); + TEST_PTR_NULL(stlsoft_C_strnstrn("abcdef", 6, "abx", 3)); +} + +static void TEST_stlsoft_C_strnstrn_PARTIAL_THEN_MATCH(void) +{ + char const s[] = "abXabc"; + + TEST_PTR_EQ(s + 3, stlsoft_C_strnstrn(s, 6, "abc", 3)); +} + +static void TEST_stlsoft_C_strnstrn_REPEATED_FIRST_BYTE(void) +{ + char const s[] = "aaab"; + char const t[] = "aaa"; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnstrn(s, 4, "aab", 3)); + TEST_PTR_EQ(t, stlsoft_C_strnstrn(t, 3, "aa", 2)); +} + +static void TEST_stlsoft_C_strnstrn_DOES_NOT_READ_PAST_n1(void) +{ + char const s[] = "xxabc"; + + TEST_PTR_NULL(stlsoft_C_strnstrn(s, 4, "abc", 3)); + TEST_PTR_EQ(s + 2, stlsoft_C_strnstrn(s, 5, "abc", 3)); +} + +static void TEST_stlsoft_C_strnstrn_DOES_NOT_READ_PAST_n2(void) +{ + char const hay[] = "abX"; + char const needle[] = { 'a', 'b', 'Y' }; + + TEST_PTR_EQ(hay, stlsoft_C_strnstrn(hay, 3, needle, 2)); + TEST_PTR_NULL(stlsoft_C_strnstrn(hay, 3, needle, 3)); +} + +static void TEST_stlsoft_C_strnstrn_EMBEDDED_NUL(void) +{ + char const hay[] = { 'a', '\0', 'b', 'x', 'a', '\0', 'b' }; + char const needle[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(hay, stlsoft_C_strnstrn(hay, 7, needle, 3)); + TEST_PTR_EQ(hay + 4, stlsoft_C_strnstrn(hay + 1, 6, needle, 3)); +} + +static void TEST_stlsoft_C_strnstrn_SINGLE_BYTE(void) +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_strnstrn(s, 3, "b", 1)); + TEST_PTR_NULL(stlsoft_C_strnstrn(s, 3, "z", 1)); +} + +static void TEST_stlsoft_C_strnstrn_FULL_SPAN(void) +{ + char const s[] = "abcd"; + + TEST_PTR_EQ(s, stlsoft_C_strnstrn(s, 4, "abcd", 4)); + TEST_PTR_NULL(stlsoft_C_strnstrn(s, 4, "abce", 4)); +} + +static void TEST_stlsoft_C_wcsnstrn_n2_0(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnstrn(s, 3, L"", 0)); + TEST_PTR_EQ(s, stlsoft_C_wcsnstrn(s, 0, L"", 0)); + TEST_PTR_EQ(s, stlsoft_C_wcsnstrn(s, 3, L"xyz", 0)); +} + +static void TEST_stlsoft_C_wcsnstrn_n1_0(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_NULL(stlsoft_C_wcsnstrn(s, 0, L"a", 1)); +} + +static void TEST_stlsoft_C_wcsnstrn_n2_GT_n1(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnstrn(L"ab", 2, L"abc", 3)); + TEST_PTR_NULL(stlsoft_C_wcsnstrn(L"abcd", 4, L"abcde", 5)); +} + +static void TEST_stlsoft_C_wcsnstrn_MATCH_AT_START(void) +{ + wchar_t const s[] = L"abcdef"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnstrn(s, 6, L"abc", 3)); + TEST_PTR_EQ(s, stlsoft_C_wcsnstrn(s, 3, L"abc", 3)); +} + +static void TEST_stlsoft_C_wcsnstrn_MATCH_IN_MIDDLE(void) +{ + wchar_t const s[] = L"xxabcxx"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnstrn(s, 7, L"abc", 3)); +} + +static void TEST_stlsoft_C_wcsnstrn_MATCH_AT_END(void) +{ + wchar_t const s[] = L"xxabc"; + + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnstrn(s, 5, L"abc", 3)); + TEST_PTR_NULL(stlsoft_C_wcsnstrn(s, 4, L"abc", 3)); +} + +static void TEST_stlsoft_C_wcsnstrn_MISS(void) +{ + TEST_PTR_NULL(stlsoft_C_wcsnstrn(L"abcdef", 6, L"zzz", 3)); + TEST_PTR_NULL(stlsoft_C_wcsnstrn(L"abcdef", 6, L"abx", 3)); +} + +static void TEST_stlsoft_C_wcsnstrn_PARTIAL_THEN_MATCH(void) +{ + wchar_t const s[] = L"abXabc"; + + TEST_PTR_EQ(s + 3, stlsoft_C_wcsnstrn(s, 6, L"abc", 3)); +} + +static void TEST_stlsoft_C_wcsnstrn_REPEATED_FIRST_BYTE(void) +{ + wchar_t const s[] = L"aaab"; + wchar_t const t[] = L"aaa"; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnstrn(s, 4, L"aab", 3)); + TEST_PTR_EQ(t, stlsoft_C_wcsnstrn(t, 3, L"aa", 2)); +} + +static void TEST_stlsoft_C_wcsnstrn_DOES_NOT_READ_PAST_n1(void) +{ + wchar_t const s[] = L"xxabc"; + + TEST_PTR_NULL(stlsoft_C_wcsnstrn(s, 4, L"abc", 3)); + TEST_PTR_EQ(s + 2, stlsoft_C_wcsnstrn(s, 5, L"abc", 3)); +} + +static void TEST_stlsoft_C_wcsnstrn_DOES_NOT_READ_PAST_n2(void) +{ + wchar_t const hay[] = L"abX"; + wchar_t const needle[] = { L'a', L'b', L'Y' }; + + TEST_PTR_EQ(hay, stlsoft_C_wcsnstrn(hay, 3, needle, 2)); + TEST_PTR_NULL(stlsoft_C_wcsnstrn(hay, 3, needle, 3)); +} + +static void TEST_stlsoft_C_wcsnstrn_EMBEDDED_NUL(void) +{ + wchar_t const hay[] = { L'a', L'\0', L'b', L'x', L'a', L'\0', L'b' }; + wchar_t const needle[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(hay, stlsoft_C_wcsnstrn(hay, 7, needle, 3)); + TEST_PTR_EQ(hay + 4, stlsoft_C_wcsnstrn(hay + 1, 6, needle, 3)); +} + +static void TEST_stlsoft_C_wcsnstrn_SINGLE_BYTE(void) +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, stlsoft_C_wcsnstrn(s, 3, L"b", 1)); + TEST_PTR_NULL(stlsoft_C_wcsnstrn(s, 3, L"z", 1)); +} + +static void TEST_stlsoft_C_wcsnstrn_FULL_SPAN(void) +{ + wchar_t const s[] = L"abcd"; + + TEST_PTR_EQ(s, stlsoft_C_wcsnstrn(s, 4, L"abcd", 4)); + TEST_PTR_NULL(stlsoft_C_wcsnstrn(s, 4, L"abce", 4)); +} + + +/* ///////////////////////////// end of file //////////////////////////// */ diff --git a/test/unit/stlsoft/string/c_string/strnstrn/CMakeLists.txt b/test/unit/stlsoft/string/c_string/strnstrn/CMakeLists.txt new file mode 100644 index 000000000..72fdc21fe --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnstrn/CMakeLists.txt @@ -0,0 +1,2 @@ +# SIS:AUTO_GENERATED: Remove this line if you edit the file, otherwise it will be overwritten +define_automated_test_program(test.unit.stlsoft.string.c_string.strnstrn entry.cpp) diff --git a/test/unit/stlsoft/string/c_string/strnstrn/entry.cpp b/test/unit/stlsoft/string/c_string/strnstrn/entry.cpp new file mode 100644 index 000000000..e8b1aee26 --- /dev/null +++ b/test/unit/stlsoft/string/c_string/strnstrn/entry.cpp @@ -0,0 +1,357 @@ +/* ///////////////////////////////////////////////////////////////////////// + * File: c_string.strnstrn/entry.cpp + * + * Purpose: Unit-tests for stlsoft::c_string::strnstrn() and wcsnstrn(). + * + * Created: 23rd October 2026 + * Updated: 25th October 2026 + * + * ////////////////////////////////////////////////////////////////////// */ + + +/* ///////////////////////////////////////////////////////////////////////// + * test component header file include(s) + */ + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * includes + */ + +#include +#include + +#include + + +/* ///////////////////////////////////////////////////////////////////////// + * forward declarations + */ + +namespace +{ + + static void TEST_c_string_strnstrn_n2_0(); + static void TEST_c_string_strnstrn_n1_0(); + static void TEST_c_string_strnstrn_n2_GT_n1(); + static void TEST_c_string_strnstrn_MATCH_AT_START(); + static void TEST_c_string_strnstrn_MATCH_IN_MIDDLE(); + static void TEST_c_string_strnstrn_MATCH_AT_END(); + static void TEST_c_string_strnstrn_MISS(); + static void TEST_c_string_strnstrn_PARTIAL_THEN_MATCH(); + static void TEST_c_string_strnstrn_REPEATED_FIRST_BYTE(); + static void TEST_c_string_strnstrn_DOES_NOT_READ_PAST_n1(); + static void TEST_c_string_strnstrn_DOES_NOT_READ_PAST_n2(); + static void TEST_c_string_strnstrn_EMBEDDED_NUL(); + static void TEST_c_string_strnstrn_SINGLE_BYTE(); + static void TEST_c_string_strnstrn_FULL_SPAN(); + static void TEST_c_string_wcsnstrn_n2_0(); + static void TEST_c_string_wcsnstrn_n1_0(); + static void TEST_c_string_wcsnstrn_n2_GT_n1(); + static void TEST_c_string_wcsnstrn_MATCH_AT_START(); + static void TEST_c_string_wcsnstrn_MATCH_IN_MIDDLE(); + static void TEST_c_string_wcsnstrn_MATCH_AT_END(); + static void TEST_c_string_wcsnstrn_MISS(); + static void TEST_c_string_wcsnstrn_PARTIAL_THEN_MATCH(); + static void TEST_c_string_wcsnstrn_REPEATED_FIRST_BYTE(); + static void TEST_c_string_wcsnstrn_DOES_NOT_READ_PAST_n1(); + static void TEST_c_string_wcsnstrn_DOES_NOT_READ_PAST_n2(); + static void TEST_c_string_wcsnstrn_EMBEDDED_NUL(); + static void TEST_c_string_wcsnstrn_SINGLE_BYTE(); + static void TEST_c_string_wcsnstrn_FULL_SPAN(); + + static wchar_t const* wcsnstrn_both_(wchar_t const* s1, size_t n1, wchar_t const* s2, size_t n2); +} // anonymous namespace + + +/* ///////////////////////////////////////////////////////////////////////// + * main() + */ + +int main(int argc, char* argv[]) +{ + int retCode = EXIT_SUCCESS; + int verbosity = 2; + + XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity); + + if (XTESTS_START_RUNNER("test.unit.stlsoft.string.c_string.strnstrn", verbosity)) + { + XTESTS_RUN_CASE(TEST_c_string_strnstrn_n2_0); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_n1_0); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_n2_GT_n1); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_MISS); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_PARTIAL_THEN_MATCH); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_REPEATED_FIRST_BYTE); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_DOES_NOT_READ_PAST_n1); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_DOES_NOT_READ_PAST_n2); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_SINGLE_BYTE); + XTESTS_RUN_CASE(TEST_c_string_strnstrn_FULL_SPAN); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_n2_0); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_n1_0); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_n2_GT_n1); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_MATCH_AT_START); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_MATCH_IN_MIDDLE); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_MATCH_AT_END); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_MISS); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_PARTIAL_THEN_MATCH); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_REPEATED_FIRST_BYTE); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_DOES_NOT_READ_PAST_n1); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_DOES_NOT_READ_PAST_n2); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_EMBEDDED_NUL); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_SINGLE_BYTE); + XTESTS_RUN_CASE(TEST_c_string_wcsnstrn_FULL_SPAN); + + XTESTS_PRINT_RESULTS(); + + XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode); + } + + return retCode; +} + + +/* ///////////////////////////////////////////////////////////////////////// + * test function implementations + */ + +namespace +{ + +static wchar_t const* wcsnstrn_both_(wchar_t const* s1, size_t n1, wchar_t const* s2, size_t n2) +{ + wchar_t const* const via_str = stlsoft::c_string::strnstrn(s1, n1, s2, n2); + wchar_t const* const via_wcs = stlsoft::c_string::wcsnstrn(s1, n1, s2, n2); + + TEST_PTR_EQ(via_wcs, via_str); + + return via_wcs; +} + +static void TEST_c_string_strnstrn_n2_0() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnstrn(s, 3, "", 0)); + TEST_PTR_EQ(s, stlsoft::c_string::strnstrn(s, 0, "", 0)); + TEST_PTR_EQ(s, stlsoft::c_string::strnstrn(s, 3, "xyz", 0)); +} + +static void TEST_c_string_strnstrn_n1_0() +{ + char const s[] = "abc"; + + TEST_PTR_NULL(stlsoft::c_string::strnstrn(s, 0, "a", 1)); +} + +static void TEST_c_string_strnstrn_n2_GT_n1() +{ + TEST_PTR_NULL(stlsoft::c_string::strnstrn("ab", 2, "abc", 3)); + TEST_PTR_NULL(stlsoft::c_string::strnstrn("abcd", 4, "abcde", 5)); +} + +static void TEST_c_string_strnstrn_MATCH_AT_START() +{ + char const s[] = "abcdef"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnstrn(s, 6, "abc", 3)); + TEST_PTR_EQ(s, stlsoft::c_string::strnstrn(s, 3, "abc", 3)); +} + +static void TEST_c_string_strnstrn_MATCH_IN_MIDDLE() +{ + char const s[] = "xxabcxx"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnstrn(s, 7, "abc", 3)); +} + +static void TEST_c_string_strnstrn_MATCH_AT_END() +{ + char const s[] = "xxabc"; + + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnstrn(s, 5, "abc", 3)); + TEST_PTR_NULL(stlsoft::c_string::strnstrn(s, 4, "abc", 3)); +} + +static void TEST_c_string_strnstrn_MISS() +{ + TEST_PTR_NULL(stlsoft::c_string::strnstrn("abcdef", 6, "zzz", 3)); + TEST_PTR_NULL(stlsoft::c_string::strnstrn("abcdef", 6, "abx", 3)); +} + +static void TEST_c_string_strnstrn_PARTIAL_THEN_MATCH() +{ + char const s[] = "abXabc"; + + TEST_PTR_EQ(s + 3, stlsoft::c_string::strnstrn(s, 6, "abc", 3)); +} + +static void TEST_c_string_strnstrn_REPEATED_FIRST_BYTE() +{ + char const s[] = "aaab"; + char const t[] = "aaa"; + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnstrn(s, 4, "aab", 3)); + TEST_PTR_EQ(t, stlsoft::c_string::strnstrn(t, 3, "aa", 2)); +} + +static void TEST_c_string_strnstrn_DOES_NOT_READ_PAST_n1() +{ + char const s[] = "xxabc"; + + TEST_PTR_NULL(stlsoft::c_string::strnstrn(s, 4, "abc", 3)); + TEST_PTR_EQ(s + 2, stlsoft::c_string::strnstrn(s, 5, "abc", 3)); +} + +static void TEST_c_string_strnstrn_DOES_NOT_READ_PAST_n2() +{ + char const hay[] = "abX"; + char const needle[] = { 'a', 'b', 'Y' }; + + TEST_PTR_EQ(hay, stlsoft::c_string::strnstrn(hay, 3, needle, 2)); + TEST_PTR_NULL(stlsoft::c_string::strnstrn(hay, 3, needle, 3)); +} + +static void TEST_c_string_strnstrn_EMBEDDED_NUL() +{ + char const hay[] = { 'a', '\0', 'b', 'x', 'a', '\0', 'b' }; + char const needle[] = { 'a', '\0', 'b' }; + + TEST_PTR_EQ(hay, stlsoft::c_string::strnstrn(hay, 7, needle, 3)); + TEST_PTR_EQ(hay + 4, stlsoft::c_string::strnstrn(hay + 1, 6, needle, 3)); +} + +static void TEST_c_string_strnstrn_SINGLE_BYTE() +{ + char const s[] = "abc"; + + TEST_PTR_EQ(s + 1, stlsoft::c_string::strnstrn(s, 3, "b", 1)); + TEST_PTR_NULL(stlsoft::c_string::strnstrn(s, 3, "z", 1)); +} + +static void TEST_c_string_strnstrn_FULL_SPAN() +{ + char const s[] = "abcd"; + + TEST_PTR_EQ(s, stlsoft::c_string::strnstrn(s, 4, "abcd", 4)); + TEST_PTR_NULL(stlsoft::c_string::strnstrn(s, 4, "abce", 4)); +} + +static void TEST_c_string_wcsnstrn_n2_0() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s, wcsnstrn_both_(s, 3, L"", 0)); + TEST_PTR_EQ(s, wcsnstrn_both_(s, 0, L"", 0)); + TEST_PTR_EQ(s, wcsnstrn_both_(s, 3, L"xyz", 0)); +} + +static void TEST_c_string_wcsnstrn_n1_0() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_NULL(wcsnstrn_both_(s, 0, L"a", 1)); +} + +static void TEST_c_string_wcsnstrn_n2_GT_n1() +{ + TEST_PTR_NULL(wcsnstrn_both_(L"ab", 2, L"abc", 3)); + TEST_PTR_NULL(wcsnstrn_both_(L"abcd", 4, L"abcde", 5)); +} + +static void TEST_c_string_wcsnstrn_MATCH_AT_START() +{ + wchar_t const s[] = L"abcdef"; + + TEST_PTR_EQ(s, wcsnstrn_both_(s, 6, L"abc", 3)); + TEST_PTR_EQ(s, wcsnstrn_both_(s, 3, L"abc", 3)); +} + +static void TEST_c_string_wcsnstrn_MATCH_IN_MIDDLE() +{ + wchar_t const s[] = L"xxabcxx"; + + TEST_PTR_EQ(s + 2, wcsnstrn_both_(s, 7, L"abc", 3)); +} + +static void TEST_c_string_wcsnstrn_MATCH_AT_END() +{ + wchar_t const s[] = L"xxabc"; + + TEST_PTR_EQ(s + 2, wcsnstrn_both_(s, 5, L"abc", 3)); + TEST_PTR_NULL(wcsnstrn_both_(s, 4, L"abc", 3)); +} + +static void TEST_c_string_wcsnstrn_MISS() +{ + TEST_PTR_NULL(wcsnstrn_both_(L"abcdef", 6, L"zzz", 3)); + TEST_PTR_NULL(wcsnstrn_both_(L"abcdef", 6, L"abx", 3)); +} + +static void TEST_c_string_wcsnstrn_PARTIAL_THEN_MATCH() +{ + wchar_t const s[] = L"abXabc"; + + TEST_PTR_EQ(s + 3, wcsnstrn_both_(s, 6, L"abc", 3)); +} + +static void TEST_c_string_wcsnstrn_REPEATED_FIRST_BYTE() +{ + wchar_t const s[] = L"aaab"; + wchar_t const t[] = L"aaa"; + + TEST_PTR_EQ(s + 1, wcsnstrn_both_(s, 4, L"aab", 3)); + TEST_PTR_EQ(t, wcsnstrn_both_(t, 3, L"aa", 2)); +} + +static void TEST_c_string_wcsnstrn_DOES_NOT_READ_PAST_n1() +{ + wchar_t const s[] = L"xxabc"; + + TEST_PTR_NULL(wcsnstrn_both_(s, 4, L"abc", 3)); + TEST_PTR_EQ(s + 2, wcsnstrn_both_(s, 5, L"abc", 3)); +} + +static void TEST_c_string_wcsnstrn_DOES_NOT_READ_PAST_n2() +{ + wchar_t const hay[] = L"abX"; + wchar_t const needle[] = { L'a', L'b', L'Y' }; + + TEST_PTR_EQ(hay, wcsnstrn_both_(hay, 3, needle, 2)); + TEST_PTR_NULL(wcsnstrn_both_(hay, 3, needle, 3)); +} + +static void TEST_c_string_wcsnstrn_EMBEDDED_NUL() +{ + wchar_t const hay[] = { L'a', L'\0', L'b', L'x', L'a', L'\0', L'b' }; + wchar_t const needle[] = { L'a', L'\0', L'b' }; + + TEST_PTR_EQ(hay, wcsnstrn_both_(hay, 7, needle, 3)); + TEST_PTR_EQ(hay + 4, wcsnstrn_both_(hay + 1, 6, needle, 3)); +} + +static void TEST_c_string_wcsnstrn_SINGLE_BYTE() +{ + wchar_t const s[] = L"abc"; + + TEST_PTR_EQ(s + 1, wcsnstrn_both_(s, 3, L"b", 1)); + TEST_PTR_NULL(wcsnstrn_both_(s, 3, L"z", 1)); +} + +static void TEST_c_string_wcsnstrn_FULL_SPAN() +{ + wchar_t const s[] = L"abcd"; + + TEST_PTR_EQ(s, wcsnstrn_both_(s, 4, L"abcd", 4)); + TEST_PTR_NULL(wcsnstrn_both_(s, 4, L"abce", 4)); +} +} // anonymous namespace + + +/* ///////////////////////////// end of file //////////////////////////// */ From 410025668b34399e0fb964c8a3e1f8342649aa3f Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Tue, 27 Oct 2026 16:10:34 +1100 Subject: [PATCH 21/22] tidying --- TODO.md | 1 + include/stlsoft/string/c_string/strnicmp.h | 21 ++++++++++------ include/stlsoft/string/c_string/strnistrn.h | 27 ++++++++++++--------- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/TODO.md b/TODO.md index 7b49f60e4..a6de96598 100644 --- a/TODO.md +++ b/TODO.md @@ -132,6 +132,7 @@ Must resolve before finalising the **1.11.3** release: Misc: * [ ] Bring in **include/stlsoft/string/trim_functions.h** and **test/unit/stlsoft/string/trim_functions** from `mwsis/trim_functions` (on the **STLSoft** clone); * [ ] Bring in the `memchr` / `memcmp` and ASCII case-fold performance work for `strnchr`, `strnicmp`, `strnistrn`, and `strnstrn`, plus **test.performance.stlsoft.string.c_string**, from `mwsis/mem-fns` (on the **STLSoft** clone). The `strnistrn` correctness fix is already in **1.11.2**; +* [ ] Replace the duplicated ASCII case-fold helpers with one shared pair: `stlsoft_C_strnicmp_fold_char_m_()` / `stlsoft_C_strnistrn_fold_char_m_()`, and `stlsoft_C_strnicmp_fold_char_w_()` / `stlsoft_C_strnistrn_fold_char_w_()`; Normalise C API (and related C-facing) identifier prefixes. **House rule** (documented in **c-cpp-standards** → *STLSoft C API identifier prefixes*): diff --git a/include/stlsoft/string/c_string/strnicmp.h b/include/stlsoft/string/c_string/strnicmp.h index f39e93e55..021f0d5bd 100644 --- a/include/stlsoft/string/c_string/strnicmp.h +++ b/include/stlsoft/string/c_string/strnicmp.h @@ -4,7 +4,7 @@ * Purpose: Definition of stlsoft_C_strnicmp() and stlsoft_C_wcsnicmp() * * Created: 25th November 2020 - * Updated: 26th October 2026 + * Updated: 27th October 2026 * * Home: http://stlsoft.org/ * @@ -54,7 +54,7 @@ # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNICMP_MAJOR 1 # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNICMP_MINOR 0 # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNICMP_REVISION 3 -# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNICMP_EDIT 5 +# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNICMP_EDIT 6 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -79,10 +79,13 @@ * helpers */ +#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION + /* ASCII letters fold by 32. Every other byte is returned unchanged. */ +/* Duplicate of stlsoft_C_strnistrn_fold_char_m_(). */ STLSOFT_INLINE int -stlsoft_C_strnicmp_fold_char_( +stlsoft_C_strnicmp_fold_char_m_( unsigned char ch ) { @@ -96,9 +99,10 @@ stlsoft_C_strnicmp_fold_char_( } /* ASCII letters fold by 32. Units outside 0-127 use towupper. */ +/* Duplicate of stlsoft_C_strnistrn_fold_char_w_(). */ STLSOFT_INLINE int -stlsoft_C_wcsnicmp_fold_( +stlsoft_C_strnicmp_fold_char_w_( wchar_t ch ) { @@ -115,6 +119,7 @@ stlsoft_C_wcsnicmp_fold_( return (int)STLSOFT_NS_GLOBAL(towupper)(ch); } +#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ /* ///////////////////////////////////////////////////////////////////////// @@ -146,8 +151,8 @@ stlsoft_C_strnicmp( if (c1 != c2) { - int const d = stlsoft_C_strnicmp_fold_char_(c1) - - stlsoft_C_strnicmp_fold_char_(c2); + int const d = stlsoft_C_strnicmp_fold_char_m_(c1) - + stlsoft_C_strnicmp_fold_char_m_(c2); if (0 != d) { @@ -188,8 +193,8 @@ stlsoft_C_wcsnicmp( if (c1 != c2) { - int const d = stlsoft_C_wcsnicmp_fold_(c1) - - stlsoft_C_wcsnicmp_fold_(c2); + int const d = stlsoft_C_strnicmp_fold_char_w_(c1) - + stlsoft_C_strnicmp_fold_char_w_(c2); if (0 != d) { diff --git a/include/stlsoft/string/c_string/strnistrn.h b/include/stlsoft/string/c_string/strnistrn.h index a332bc2c0..7a30ff84b 100644 --- a/include/stlsoft/string/c_string/strnistrn.h +++ b/include/stlsoft/string/c_string/strnistrn.h @@ -54,7 +54,7 @@ # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_MAJOR 1 # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_MINOR 0 # define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_REVISION 4 -# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_EDIT 5 +# define STLSOFT_VER_STLSOFT_STRING_C_STRING_H_STRNISTRN_EDIT 6 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ @@ -79,10 +79,13 @@ * helpers */ +#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION + /* ASCII letters fold by 32. Every other byte is returned unchanged. */ +/* Duplicate of stlsoft_C_strnicmp_fold_char_m_(). */ STLSOFT_INLINE int -stlsoft_C_strnistrn_fold_char_( +stlsoft_C_strnistrn_fold_char_m_( unsigned char ch ) { @@ -96,9 +99,10 @@ stlsoft_C_strnistrn_fold_char_( } /* ASCII letters fold by 32. Units outside 0-127 use towupper. */ +/* Duplicate of stlsoft_C_strnicmp_fold_char_w_(). */ STLSOFT_INLINE int -stlsoft_C_wcsnistrn_fold_( +stlsoft_C_strnistrn_fold_char_w_( wchar_t ch ) { @@ -115,6 +119,7 @@ stlsoft_C_wcsnistrn_fold_( return (int)STLSOFT_NS_GLOBAL(towupper)(ch); } +#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ /* ///////////////////////////////////////////////////////////////////////// @@ -147,14 +152,14 @@ stlsoft_C_strnistrn( else { unsigned char const ch0 = (unsigned char)s2[0]; - int const fc0 = stlsoft_C_strnistrn_fold_char_(ch0); + int const fc0 = stlsoft_C_strnistrn_fold_char_m_(ch0); for (; n1 >= n2; --n1, ++s1) { unsigned char const h0 = (unsigned char)s1[0]; if (h0 == ch0 || - stlsoft_C_strnistrn_fold_char_(h0) == fc0) + stlsoft_C_strnistrn_fold_char_m_(h0) == fc0) { size_t i; @@ -163,8 +168,8 @@ stlsoft_C_strnistrn( unsigned char const h = (unsigned char)s1[i]; unsigned char const n = (unsigned char)s2[i]; - if (stlsoft_C_strnistrn_fold_char_(h) != - stlsoft_C_strnistrn_fold_char_(n)) + if (stlsoft_C_strnistrn_fold_char_m_(h) != + stlsoft_C_strnistrn_fold_char_m_(n)) { break; } @@ -207,21 +212,21 @@ stlsoft_C_wcsnistrn( else { wchar_t const ch0 = s2[0]; - int const fc0 = stlsoft_C_wcsnistrn_fold_(ch0); + int const fc0 = stlsoft_C_strnistrn_fold_char_w_(ch0); for (; n1 >= n2; --n1, ++s1) { wchar_t const h0 = s1[0]; if (h0 == ch0 || - stlsoft_C_wcsnistrn_fold_(h0) == fc0) + stlsoft_C_strnistrn_fold_char_w_(h0) == fc0) { size_t i; for (i = 1; i != n2; ++i) { - if (stlsoft_C_wcsnistrn_fold_(s1[i]) != - stlsoft_C_wcsnistrn_fold_(s2[i])) + if (stlsoft_C_strnistrn_fold_char_w_(s1[i]) != + stlsoft_C_strnistrn_fold_char_w_(s2[i])) { break; } From 679692893fd3bc6bb2d776400de145638d6e06d2 Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Tue, 27 Oct 2026 17:28:21 +1100 Subject: [PATCH 22/22] docs(stlsoft): summarise c_string performance by function Add one table per helper covering the local Mac and the six CI cells. Paired cells are baseline time divided by the STLSoft time, so a value above 1 means the STLSoft function was faster. strnistrn stays as total nanoseconds because it has no paired baseline. --- strategy/performance/C_STRING.md | 747 +++++++++++++++++++++++++++++++ 1 file changed, 747 insertions(+) create mode 100644 strategy/performance/C_STRING.md diff --git a/strategy/performance/C_STRING.md b/strategy/performance/C_STRING.md new file mode 100644 index 000000000..3924dfd05 --- /dev/null +++ b/strategy/performance/C_STRING.md @@ -0,0 +1,747 @@ +# STLSoft - C-string Performance + +Strategy note for the **STLSoft** C string helpers. Measurements are of **test/performance/stlsoft/string/c_string/main.cpp** (`test.performance.stlsoft.string.c_string`). Library sources are **include/stlsoft/string/c_string/strnicmp.h**, **strnchr.h**, **strnistrn.h**, **strnpbrkn.h**, **strnrchr.h**, and **strnstrn.h**. + +The char forms are timed. The wide forms are not in this program. + + +## Status + +The local mains-power run and the six CI cells of this wave are recorded: `linux-gcc`, `linux-clang`, `macos-gcc`, `macos-clang`, `windows-cl`, and `windows-mingw`. Anchors match within every pair on every run, so each pair did the same work. The local paragraphs describe that machine only. **Summary** is the cross-cell comparison. **Directions so far** is the reading of those tables. Compiler banners are still missing, so that reading is not yet a settled claim. + + +## What was measured + +1,000,000 iterations. Haystack length 96. Case-insensitive compare length 45 (`"The Quick Brown Fox Jumps Over The Lazy Dog!!"`, with the other side case-flipped). The harness times each row twice and prints the second pass. `SIS_PERFTESTS_GROUPGAPS=1` inserts a blank line between groups. + +Printed **nanoseconds** are the total for that pass, not nanoseconds per call. Divide by 1,000,000 for a per-call figure. The **anchor** is the sum of the return values over the pass: comparison sign (`+1`, `0`, `-1`) or byte index, or `-1` for a miss. A matching anchor means both functions did the same work. + +Search positions in the haystack: + +* character near the start: index 3 (`Q`); +* character near the end: index 92 (`Z`); +* needle near the start: index 8 (`brown` / `BROWN`); +* needle near the end: index 84 (`jumps` / `JUMPS`); +* character-set needles are four bytes (`xyzQ`, `xyzZ`, `xyz#`). + +`strpbrk` and `strstr` are NUL-terminated. The fixture places a NUL at index 96, so on this haystack they scan the same 96 bytes as the length-bounded helpers. `strncasecmp` is the non-Windows name of the case-insensitive baseline (`_strnicmp` on Windows). `local_strnrchr` is a reverse scan written in the performance program, the same shape as `stlsoft_C_strnrchr`. `stlsoft_C_strnistrn` has no paired baseline. + + +## Local: Gorbicx-MacBook-Pro, mains power, 27th October 2026 + +Built with `./build_cmake.sh test.performance.stlsoft.string.c_string` and run with `SIS_PERFTESTS_GROUPGAPS=1`. Compiler, optimisation level, and CPU model were not recorded with the log. + + +### `strnicmp` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ------------ | ----------- | ---------- | +| `stlsoft_C_strnicmp` | differ-early | 1,122,791 | 1,000,000 | +| `strncasecmp` | differ-early | 2,506,375 | 1,000,000 | +| `stlsoft_C_strnicmp` | differ-late | 23,609,000 | -1,000,000 | +| `strncasecmp` | differ-late | 29,995,250 | -1,000,000 | +| `stlsoft_C_strnicmp` | equal | 24,446,375 | 0 | +| `strncasecmp` | equal | 27,942,125 | 0 | + +`stlsoft_C_strnicmp` is about 2.2× faster when the strings differ at the first byte, about 1.3× when they differ at the last byte, and about 1.1× when they compare equal. + + +### `strnchr` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| ------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnchr` | near-start | 1,906,750 | 3,000,000 | +| `memchr` | near-start | 1,905,375 | 3,000,000 | +| `stlsoft_C_strnchr` | near-end | 3,285,250 | 92,000,000 | +| `memchr` | near-end | 3,266,875 | 92,000,000 | +| `stlsoft_C_strnchr` | miss | 3,042,042 | -1,000,000 | +| `memchr` | miss | 3,043,958 | -1,000,000 | + +The three needles are ASCII. `stlsoft_C_strnchr` calls `memchr` for a needle in 0–127, and the totals match `memchr` within about 1%. + + +### `strnistrn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| --------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnistrn` | near-start | 4,170,750 | 8,000,000 | +| `stlsoft_C_strnistrn` | near-end | 30,920,458 | 84,000,000 | +| `stlsoft_C_strnistrn` | miss | 32,696,042 | -1,000,000 | + +No paired function. A hit at index 8 costs about 4.2 ms for the pass. A hit at index 84 and a full miss both cost about 31–33 ms. + + +### `strnpbrkn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| --------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnpbrkn` | near-start | 1,570,750 | 3,000,000 | +| `strpbrk` | near-start | 6,051,041 | 3,000,000 | +| `stlsoft_C_strnpbrkn` | near-end | 28,256,583 | 92,000,000 | +| `strpbrk` | near-end | 111,063,917 | 92,000,000 | +| `stlsoft_C_strnpbrkn` | miss | 22,008,584 | -1,000,000 | +| `strpbrk` | miss | 114,684,875 | -1,000,000 | + +On this four-byte set, `stlsoft_C_strnpbrkn` is about 3.9× faster for both hits and about 5.2× faster on a miss. + + +### `strnrchr` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnrchr` | near-start | 22,345,375 | 3,000,000 | +| `local_strnrchr` | near-start | 22,353,958 | 3,000,000 | +| `stlsoft_C_strnrchr` | near-end | 1,570,917 | 92,000,000 | +| `local_strnrchr` | near-end | 1,572,625 | 92,000,000 | +| `stlsoft_C_strnrchr` | miss | 23,019,708 | -1,000,000 | +| `local_strnrchr` | miss | 23,153,875 | -1,000,000 | + +The two reverse scans match within about 1%. A hit at index 92 is the short walk. A hit at index 3 and a miss both walk almost the whole haystack. + + +### `strnstrn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnstrn` | near-start | 2,381,125 | 8,000,000 | +| `strstr` | near-start | 5,680,209 | 8,000,000 | +| `stlsoft_C_strnstrn` | near-end | 3,370,500 | 84,000,000 | +| `strstr` | near-end | 24,235,375 | 84,000,000 | +| `stlsoft_C_strnstrn` | miss | 3,357,291 | -1,000,000 | +| `strstr` | miss | 25,758,125 | -1,000,000 | + +`stlsoft_C_strnstrn` searches with `memchr` and `memcmp`. It is about 2.4× faster than `strstr` for the early needle, and about 7× faster for the late needle and the miss. + + +## CI: `linux-gcc`, 27th October 2026 + +GitHub-hosted Linux runner. Log path `/home/runner/work/STLSoft/STLSoft/build/test/performance/stlsoft/string/c_string/test.performance.stlsoft.string.c_string`. Compiler version was not in the log. Baseline name `strncasecmp`. + + +### `strnicmp` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ------------ | ----------- | ---------- | +| `stlsoft_C_strnicmp` | differ-early | 1,306,644 | 1,000,000 | +| `strncasecmp` | differ-early | 2,431,603 | 1,000,000 | +| `stlsoft_C_strnicmp` | differ-late | 33,280,865 | -1,000,000 | +| `strncasecmp` | differ-late | 3,354,707 | -1,000,000 | +| `stlsoft_C_strnicmp` | equal | 32,641,089 | 0 | +| `strncasecmp` | equal | 2,959,610 | 0 | + +Early difference: `stlsoft_C_strnicmp` is about 1.9× faster. A compare that walks all 45 bytes goes the other way: `strncasecmp` is about 10× faster on `differ-late` and about 11× faster on `equal`. + + +### `strnchr` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| ------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnchr` | near-start | 2,408,749 | 3,000,000 | +| `memchr` | near-start | 2,147,924 | 3,000,000 | +| `stlsoft_C_strnchr` | near-end | 2,361,727 | 92,000,000 | +| `memchr` | near-end | 2,127,463 | 92,000,000 | +| `stlsoft_C_strnchr` | miss | 2,594,659 | -1,000,000 | +| `memchr` | miss | 2,613,036 | -1,000,000 | + +Hits are about 11–12% slower than `memchr`. The miss matches. + + +### `strnistrn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| --------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnistrn` | near-start | 3,513,096 | 8,000,000 | +| `stlsoft_C_strnistrn` | near-end | 21,807,977 | 84,000,000 | +| `stlsoft_C_strnistrn` | miss | 23,401,324 | -1,000,000 | + +No paired function. Early hit about 3.5 ms for the pass. Late hit and miss about 22–23 ms. + + +### `strnpbrkn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| --------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnpbrkn` | near-start | 2,578,625 | 3,000,000 | +| `strpbrk` | near-start | 3,125,110 | 3,000,000 | +| `stlsoft_C_strnpbrkn` | near-end | 12,024,270 | 92,000,000 | +| `strpbrk` | near-end | 5,966,191 | 92,000,000 | +| `stlsoft_C_strnpbrkn` | miss | 1,947,021 | -1,000,000 | +| `strpbrk` | miss | 7,771,849 | -1,000,000 | + +Early hit: `stlsoft_C_strnpbrkn` is about 1.2× faster. Late hit: `strpbrk` is about 2× faster. Miss: `stlsoft_C_strnpbrkn` is about 4× faster. + + +### `strnrchr` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnrchr` | near-start | 8,243,921 | 3,000,000 | +| `local_strnrchr` | near-start | 8,170,841 | 3,000,000 | +| `stlsoft_C_strnrchr` | near-end | 2,076,877 | 92,000,000 | +| `local_strnrchr` | near-end | 2,142,867 | 92,000,000 | +| `stlsoft_C_strnrchr` | miss | 1,667,779 | -1,000,000 | +| `local_strnrchr` | miss | 1,667,698 | -1,000,000 | + +The two reverse scans match. + + +### `strnstrn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnstrn` | near-start | 2,137,469 | 8,000,000 | +| `strstr` | near-start | 7,696,324 | 8,000,000 | +| `stlsoft_C_strnstrn` | near-end | 2,403,370 | 84,000,000 | +| `strstr` | near-end | 7,782,854 | 84,000,000 | +| `stlsoft_C_strnstrn` | miss | 2,362,438 | -1,000,000 | +| `strstr` | miss | 4,263,720 | -1,000,000 | + +`stlsoft_C_strnstrn` is about 3.6× faster on the early needle, about 3.2× on the late needle, and about 1.8× on the miss. + + +## CI: `linux-clang`, 27th October 2026 + +GitHub-hosted Linux runner. Same log path shape as `linux-gcc`. Compiler version was not in the log. Baseline name `strncasecmp`. + + +### `strnicmp` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ------------ | ----------- | ---------- | +| `stlsoft_C_strnicmp` | differ-early | 2,352,087 | 1,000,000 | +| `strncasecmp` | differ-early | 5,621,520 | 1,000,000 | +| `stlsoft_C_strnicmp` | differ-late | 54,867,515 | -1,000,000 | +| `strncasecmp` | differ-late | 5,678,476 | -1,000,000 | +| `stlsoft_C_strnicmp` | equal | 58,239,579 | 0 | +| `strncasecmp` | equal | 6,235,392 | 0 | + +Early difference: `stlsoft_C_strnicmp` is about 2.4× faster. Full compares: `strncasecmp` is about 9.7× faster on `differ-late` and about 9.3× faster on `equal`. + + +### `strnchr` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| ------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnchr` | near-start | 4,683,385 | 3,000,000 | +| `memchr` | near-start | 4,659,881 | 3,000,000 | +| `stlsoft_C_strnchr` | near-end | 5,914,095 | 92,000,000 | +| `memchr` | near-end | 5,915,517 | 92,000,000 | +| `stlsoft_C_strnchr` | miss | 5,921,138 | -1,000,000 | +| `memchr` | miss | 5,914,916 | -1,000,000 | + +The totals match `memchr`. + + +### `strnistrn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| --------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnistrn` | near-start | 10,443,673 | 8,000,000 | +| `stlsoft_C_strnistrn` | near-end | 70,170,801 | 84,000,000 | +| `stlsoft_C_strnistrn` | miss | 88,993,444 | -1,000,000 | + +No paired function. Early hit about 10 ms for the pass. Late hit about 70 ms. Miss about 89 ms. + + +### `strnpbrkn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| --------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnpbrkn` | near-start | 3,416,647 | 3,000,000 | +| `strpbrk` | near-start | 5,287,069 | 3,000,000 | +| `stlsoft_C_strnpbrkn` | near-end | 40,470,816 | 92,000,000 | +| `strpbrk` | near-end | 9,745,945 | 92,000,000 | +| `stlsoft_C_strnpbrkn` | miss | 38,400,505 | -1,000,000 | +| `strpbrk` | miss | 10,286,771 | -1,000,000 | + +Early hit: `stlsoft_C_strnpbrkn` is about 1.5× faster. Late hit: `strpbrk` is about 4.2× faster. Miss: `strpbrk` is about 3.7× faster. + + +### `strnrchr` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnrchr` | near-start | 21,246,034 | 3,000,000 | +| `local_strnrchr` | near-start | 22,013,291 | 3,000,000 | +| `stlsoft_C_strnrchr` | near-end | 2,548,813 | 92,000,000 | +| `local_strnrchr` | near-end | 3,678,845 | 92,000,000 | +| `stlsoft_C_strnrchr` | miss | 22,545,882 | -1,000,000 | +| `local_strnrchr` | miss | 23,680,623 | -1,000,000 | + +Near-start and miss match within about 5%. On the short walk, `local_strnrchr` is about 1.4× slower. + + +### `strnstrn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnstrn` | near-start | 4,671,913 | 8,000,000 | +| `strstr` | near-start | 13,699,301 | 8,000,000 | +| `stlsoft_C_strnstrn` | near-end | 6,226,656 | 84,000,000 | +| `strstr` | near-end | 15,013,356 | 84,000,000 | +| `stlsoft_C_strnstrn` | miss | 7,156,116 | -1,000,000 | +| `strstr` | miss | 9,722,912 | -1,000,000 | + +`stlsoft_C_strnstrn` is about 2.9× faster on the early needle, about 2.4× on the late needle, and about 1.4× on the miss. + + +## CI: `windows-cl`, 27th October 2026 + +GitHub-hosted Windows runner. The log path includes `Release`: `D:\a\STLSoft\STLSoft\build\test\performance\stlsoft\string\c_string\Release\test.performance.stlsoft.string.c_string.exe`. Compiler version was not in the log. Baseline name `_strnicmp`. + + +### `strnicmp` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ------------ | ----------- | ---------- | +| `stlsoft_C_strnicmp` | differ-early | 2,115,700 | 1,000,000 | +| `_strnicmp` | differ-early | 6,005,500 | 1,000,000 | +| `stlsoft_C_strnicmp` | differ-late | 67,217,000 | -1,000,000 | +| `_strnicmp` | differ-late | 58,964,300 | -1,000,000 | +| `stlsoft_C_strnicmp` | equal | 67,159,500 | 0 | +| `_strnicmp` | equal | 57,670,400 | 0 | + +Early difference: `stlsoft_C_strnicmp` is about 2.8× faster. Full compares: `_strnicmp` is about 1.1× faster on `differ-late` and about 1.2× faster on `equal`. + + +### `strnchr` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| ------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnchr` | near-start | 4,227,900 | 3,000,000 | +| `memchr` | near-start | 4,227,100 | 3,000,000 | +| `stlsoft_C_strnchr` | near-end | 7,072,900 | 92,000,000 | +| `memchr` | near-end | 7,068,500 | 92,000,000 | +| `stlsoft_C_strnchr` | miss | 7,901,100 | -1,000,000 | +| `memchr` | miss | 5,649,600 | -1,000,000 | + +Both hits match `memchr`. The miss is about 1.4× slower than `memchr`. + + +### `strnistrn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| --------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnistrn` | near-start | 12,717,900 | 8,000,000 | +| `stlsoft_C_strnistrn` | near-end | 125,310,200 | 84,000,000 | +| `stlsoft_C_strnistrn` | miss | 83,978,900 | -1,000,000 | + +No paired function. Early hit about 13 ms for the pass. Late hit about 125 ms. Miss about 84 ms. + + +### `strnpbrkn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| --------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnpbrkn` | near-start | 9,904,300 | 3,000,000 | +| `strpbrk` | near-start | 7,802,700 | 3,000,000 | +| `stlsoft_C_strnpbrkn` | near-end | 173,617,700 | 92,000,000 | +| `strpbrk` | near-end | 75,973,400 | 92,000,000 | +| `stlsoft_C_strnpbrkn` | miss | 170,429,600 | -1,000,000 | +| `strpbrk` | miss | 78,826,700 | -1,000,000 | + +`strpbrk` is faster on all three scenarios: about 1.3× on the early hit, about 2.3× on the late hit, and about 2.2× on the miss. + + +### `strnrchr` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnrchr` | near-start | 40,073,000 | 3,000,000 | +| `local_strnrchr` | near-start | 42,470,500 | 3,000,000 | +| `stlsoft_C_strnrchr` | near-end | 4,252,000 | 92,000,000 | +| `local_strnrchr` | near-end | 4,224,000 | 92,000,000 | +| `stlsoft_C_strnrchr` | miss | 36,445,600 | -1,000,000 | +| `local_strnrchr` | miss | 36,491,200 | -1,000,000 | + +The two reverse scans match within about 6%. + + +### `strnstrn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnstrn` | near-start | 5,296,300 | 8,000,000 | +| `strstr` | near-start | 6,715,400 | 8,000,000 | +| `stlsoft_C_strnstrn` | near-end | 15,942,700 | 84,000,000 | +| `strstr` | near-end | 10,608,000 | 84,000,000 | +| `stlsoft_C_strnstrn` | miss | 15,908,300 | -1,000,000 | +| `strstr` | miss | 10,243,700 | -1,000,000 | + +Early needle: `stlsoft_C_strnstrn` is about 1.3× faster. Late needle and miss: `strstr` is about 1.5× faster. + + +## CI: `windows-mingw`, 27th October 2026 + +GitHub-hosted Windows runner. Log path `D:\a\STLSoft\STLSoft\build\test\performance\stlsoft\string\c_string\test.performance.stlsoft.string.c_string.exe`. Compiler version was not in the log. Baseline name `_strnicmp`. + + +### `strnicmp` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ------------ | ----------- | ---------- | +| `stlsoft_C_strnicmp` | differ-early | 2,824,100 | 1,000,000 | +| `_strnicmp` | differ-early | 4,920,600 | 1,000,000 | +| `stlsoft_C_strnicmp` | differ-late | 49,843,900 | -1,000,000 | +| `_strnicmp` | differ-late | 55,206,000 | -1,000,000 | +| `stlsoft_C_strnicmp` | equal | 48,906,500 | 0 | +| `_strnicmp` | equal | 53,434,000 | 0 | + +`stlsoft_C_strnicmp` is faster on all three scenarios: about 1.7× on an early difference, and about 1.1× when the compare walks all 45 bytes. + + +### `strnchr` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| ------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnchr` | near-start | 3,775,100 | 3,000,000 | +| `memchr` | near-start | 4,178,200 | 3,000,000 | +| `stlsoft_C_strnchr` | near-end | 8,832,200 | 92,000,000 | +| `memchr` | near-end | 8,823,100 | 92,000,000 | +| `stlsoft_C_strnchr` | miss | 11,899,800 | -1,000,000 | +| `memchr` | miss | 9,913,400 | -1,000,000 | + +The early hit is about 10% faster than `memchr`. The late hit matches. The miss is about 1.2× slower than `memchr`. + + +### `strnistrn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| --------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnistrn` | near-start | 5,942,800 | 8,000,000 | +| `stlsoft_C_strnistrn` | near-end | 30,763,200 | 84,000,000 | +| `stlsoft_C_strnistrn` | miss | 39,626,000 | -1,000,000 | + +No paired function. Early hit about 5.9 ms for the pass. Late hit about 31 ms. Miss about 40 ms. + + +### `strnpbrkn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| --------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnpbrkn` | near-start | 3,105,900 | 3,000,000 | +| `strpbrk` | near-start | 9,204,800 | 3,000,000 | +| `stlsoft_C_strnpbrkn` | near-end | 54,639,400 | 92,000,000 | +| `strpbrk` | near-end | 86,318,100 | 92,000,000 | +| `stlsoft_C_strnpbrkn` | miss | 46,111,200 | -1,000,000 | +| `strpbrk` | miss | 75,250,200 | -1,000,000 | + +`stlsoft_C_strnpbrkn` is faster on all three scenarios: about 3.0× on the early hit, and about 1.6× on the late hit and the miss. + + +### `strnrchr` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnrchr` | near-start | 37,272,200 | 3,000,000 | +| `local_strnrchr` | near-start | 37,243,400 | 3,000,000 | +| `stlsoft_C_strnrchr` | near-end | 3,753,200 | 92,000,000 | +| `local_strnrchr` | near-end | 3,750,600 | 92,000,000 | +| `stlsoft_C_strnrchr` | miss | 33,195,500 | -1,000,000 | +| `local_strnrchr` | miss | 32,295,000 | -1,000,000 | + +The two reverse scans match. On the miss, `local_strnrchr` is about 3% faster. + + +### `strnstrn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnstrn` | near-start | 4,077,600 | 8,000,000 | +| `strstr` | near-start | 5,372,700 | 8,000,000 | +| `stlsoft_C_strnstrn` | near-end | 19,505,800 | 84,000,000 | +| `strstr` | near-end | 10,045,600 | 84,000,000 | +| `stlsoft_C_strnstrn` | miss | 26,070,700 | -1,000,000 | +| `strstr` | miss | 10,585,500 | -1,000,000 | + +Early needle: `stlsoft_C_strnstrn` is about 1.3× faster. Late needle: `strstr` is about 1.9× faster. Miss: `strstr` is about 2.5× faster. + + +## CI: `macos-gcc`, 27th October 2026 + +GitHub-hosted macOS runner. Log path `/Users/runner/work/STLSoft/STLSoft/build/test/performance/stlsoft/string/c_string/test.performance.stlsoft.string.c_string`. The job label is `macos-gcc`. The compiler banner was not in the log. Baseline name `strncasecmp`. + + +### `strnicmp` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ------------ | ----------- | ---------- | +| `stlsoft_C_strnicmp` | differ-early | 2,394,458 | 1,000,000 | +| `strncasecmp` | differ-early | 6,480,250 | 1,000,000 | +| `stlsoft_C_strnicmp` | differ-late | 51,592,250 | -1,000,000 | +| `strncasecmp` | differ-late | 62,526,166 | -1,000,000 | +| `stlsoft_C_strnicmp` | equal | 50,033,334 | 0 | +| `strncasecmp` | equal | 70,283,917 | 0 | + +`stlsoft_C_strnicmp` is faster on all three scenarios: about 2.7× on an early difference, about 1.2× on `differ-late`, and about 1.4× on `equal`. + + +### `strnchr` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| ------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnchr` | near-start | 2,898,250 | 3,000,000 | +| `memchr` | near-start | 2,736,916 | 3,000,000 | +| `stlsoft_C_strnchr` | near-end | 5,399,916 | 92,000,000 | +| `memchr` | near-end | 5,618,667 | 92,000,000 | +| `stlsoft_C_strnchr` | miss | 6,546,416 | -1,000,000 | +| `memchr` | miss | 7,220,917 | -1,000,000 | + +The early hit is about 6% slower than `memchr`. The late hit is about 4% faster. The miss is about 10% faster. + + +### `strnistrn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| --------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnistrn` | near-start | 9,386,750 | 8,000,000 | +| `stlsoft_C_strnistrn` | near-end | 62,101,083 | 84,000,000 | +| `stlsoft_C_strnistrn` | miss | 67,250,583 | -1,000,000 | + +No paired function. Early hit about 9.4 ms for the pass. Late hit about 62 ms. Miss about 67 ms. + + +### `strnpbrkn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| --------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnpbrkn` | near-start | 2,814,000 | 3,000,000 | +| `strpbrk` | near-start | 11,398,458 | 3,000,000 | +| `stlsoft_C_strnpbrkn` | near-end | 53,440,167 | 92,000,000 | +| `strpbrk` | near-end | 233,870,083 | 92,000,000 | +| `stlsoft_C_strnpbrkn` | miss | 49,903,667 | -1,000,000 | +| `strpbrk` | miss | 282,749,459 | -1,000,000 | + +`stlsoft_C_strnpbrkn` is faster on all three scenarios: about 4.1× on the early hit, about 4.4× on the late hit, and about 5.7× on the miss. + + +### `strnrchr` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnrchr` | near-start | 39,948,000 | 3,000,000 | +| `local_strnrchr` | near-start | 37,833,666 | 3,000,000 | +| `stlsoft_C_strnrchr` | near-end | 3,498,167 | 92,000,000 | +| `local_strnrchr` | near-end | 3,501,333 | 92,000,000 | +| `stlsoft_C_strnrchr` | miss | 40,382,959 | -1,000,000 | +| `local_strnrchr` | miss | 36,178,583 | -1,000,000 | + +The short walk matches. On the long walks `local_strnrchr` is about 6% faster for the early hit and about 12% faster on the miss. + + +### `strnstrn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnstrn` | near-start | 3,406,208 | 8,000,000 | +| `strstr` | near-start | 10,469,375 | 8,000,000 | +| `stlsoft_C_strnstrn` | near-end | 5,458,958 | 84,000,000 | +| `strstr` | near-end | 37,513,500 | 84,000,000 | +| `stlsoft_C_strnstrn` | miss | 11,252,917 | -1,000,000 | +| `strstr` | miss | 37,514,000 | -1,000,000 | + +`stlsoft_C_strnstrn` is about 3.1× faster on the early needle, about 6.9× on the late needle, and about 3.3× on the miss. + + +## CI: `macos-clang`, 27th October 2026 + +GitHub-hosted macOS runner. Same log path shape as `macos-gcc`. Compiler version was not in the log. Baseline name `strncasecmp`. + + +### `strnicmp` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ------------ | ----------- | ---------- | +| `stlsoft_C_strnicmp` | differ-early | 1,881,375 | 1,000,000 | +| `strncasecmp` | differ-early | 4,066,208 | 1,000,000 | +| `stlsoft_C_strnicmp` | differ-late | 42,403,042 | -1,000,000 | +| `strncasecmp` | differ-late | 53,013,167 | -1,000,000 | +| `stlsoft_C_strnicmp` | equal | 44,810,917 | 0 | +| `strncasecmp` | equal | 55,570,375 | 0 | + +`stlsoft_C_strnicmp` is faster on all three scenarios: about 2.2× on an early difference, about 1.3× on `differ-late`, and about 1.2× on `equal`. + + +### `strnchr` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| ------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnchr` | near-start | 2,498,042 | 3,000,000 | +| `memchr` | near-start | 2,513,750 | 3,000,000 | +| `stlsoft_C_strnchr` | near-end | 5,011,708 | 92,000,000 | +| `memchr` | near-end | 5,605,417 | 92,000,000 | +| `stlsoft_C_strnchr` | miss | 6,333,500 | -1,000,000 | +| `memchr` | miss | 6,872,458 | -1,000,000 | + +The early hit matches `memchr`. The late hit is about 12% faster. The miss is about 9% faster. + + +### `strnistrn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| --------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnistrn` | near-start | 9,103,375 | 8,000,000 | +| `stlsoft_C_strnistrn` | near-end | 61,779,041 | 84,000,000 | +| `stlsoft_C_strnistrn` | miss | 65,838,750 | -1,000,000 | + +No paired function. Early hit about 9.1 ms for the pass. Late hit about 62 ms. Miss about 66 ms. + + +### `strnpbrkn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| --------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnpbrkn` | near-start | 2,856,500 | 3,000,000 | +| `strpbrk` | near-start | 11,621,750 | 3,000,000 | +| `stlsoft_C_strnpbrkn` | near-end | 50,464,459 | 92,000,000 | +| `strpbrk` | near-end | 234,734,667 | 92,000,000 | +| `stlsoft_C_strnpbrkn` | miss | 47,424,500 | -1,000,000 | +| `strpbrk` | miss | 237,860,709 | -1,000,000 | + +`stlsoft_C_strnpbrkn` is faster on all three scenarios: about 4.1× on the early hit, about 4.7× on the late hit, and about 5.0× on the miss. + + +### `strnrchr` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnrchr` | near-start | 34,054,083 | 3,000,000 | +| `local_strnrchr` | near-start | 36,654,167 | 3,000,000 | +| `stlsoft_C_strnrchr` | near-end | 3,205,334 | 92,000,000 | +| `local_strnrchr` | near-end | 3,179,125 | 92,000,000 | +| `stlsoft_C_strnrchr` | miss | 36,397,666 | -1,000,000 | +| `local_strnrchr` | miss | 34,966,208 | -1,000,000 | + +The short walk matches. On the long walk to index 3, `local_strnrchr` is about 8% slower. On the miss it is about 4% faster. + + +### `strnstrn` (total ns) + +| Function | Scenario | Nanoseconds | Anchor | +| -------------------- | ---------- | ----------- | ---------- | +| `stlsoft_C_strnstrn` | near-start | 3,394,084 | 8,000,000 | +| `strstr` | near-start | 10,459,542 | 8,000,000 | +| `stlsoft_C_strnstrn` | near-end | 5,457,875 | 84,000,000 | +| `strstr` | near-end | 36,866,708 | 84,000,000 | +| `stlsoft_C_strnstrn` | miss | 10,954,917 | -1,000,000 | +| `strstr` | miss | 37,858,500 | -1,000,000 | + +`stlsoft_C_strnstrn` is about 3.1× faster on the early needle, about 6.8× on the late needle, and about 3.5× on the miss. + + +## Summary + +One row per platform. For every paired helper the cell is **baseline ÷ STLSoft**, from the total nanoseconds above, to two decimal places. Above 1, the STLSoft function was faster. `stlsoft_C_strnistrn` has no baseline, so that table is the total nanoseconds for the pass. + + +### `strnicmp` + +Baseline is `strncasecmp`, and `_strnicmp` on both Windows cells. + +| Platform | differ-early | differ-late | equal | +| ------------- | ------------ | ----------- | ----- | +| local Mac | 2.23× | 1.27× | 1.14× | +| linux-clang | 2.39× | 0.10× | 0.11× | +| linux-gcc | 1.86× | 0.10× | 0.09× | +| macos-clang | 2.16× | 1.25× | 1.24× | +| macos-gcc | 2.71× | 1.21× | 1.40× | +| windows-cl | 2.84× | 0.88× | 0.86× | +| windows-mingw | 1.74× | 1.11× | 1.09× | + + +### `strnchr` + +Baseline is `memchr`. + +| Platform | near-start | near-end | miss | +| ------------- | ---------- | -------- | ----- | +| local Mac | 1.00× | 0.99× | 1.00× | +| linux-clang | 0.99× | 1.00× | 1.00× | +| linux-gcc | 0.89× | 0.90× | 1.01× | +| macos-clang | 1.01× | 1.12× | 1.09× | +| macos-gcc | 0.94× | 1.04× | 1.10× | +| windows-cl | 1.00× | 1.00× | 0.72× | +| windows-mingw | 1.11× | 1.00× | 0.83× | + + +### `strnistrn` + +Total nanoseconds. No paired baseline. + +| Platform | near-start | near-end | miss | +| ------------- | ---------- | ----------- | ---------- | +| local Mac | 4,170,750 | 30,920,458 | 32,696,042 | +| linux-clang | 10,443,673 | 70,170,801 | 88,993,444 | +| linux-gcc | 3,513,096 | 21,807,977 | 23,401,324 | +| macos-clang | 9,103,375 | 61,779,041 | 65,838,750 | +| macos-gcc | 9,386,750 | 62,101,083 | 67,250,583 | +| windows-cl | 12,717,900 | 125,310,200 | 83,978,900 | +| windows-mingw | 5,942,800 | 30,763,200 | 39,626,000 | + + +### `strnpbrkn` + +Baseline is `strpbrk`. + +| Platform | near-start | near-end | miss | +| ------------- | ---------- | -------- | ----- | +| local Mac | 3.85× | 3.93× | 5.21× | +| linux-clang | 1.55× | 0.24× | 0.27× | +| linux-gcc | 1.21× | 0.50× | 3.99× | +| macos-clang | 4.07× | 4.65× | 5.02× | +| macos-gcc | 4.05× | 4.38× | 5.67× | +| windows-cl | 0.79× | 0.44× | 0.46× | +| windows-mingw | 2.96× | 1.58× | 1.63× | + + +### `strnrchr` + +Baseline is `local_strnrchr`. + +| Platform | near-start | near-end | miss | +| ------------- | ---------- | -------- | ----- | +| local Mac | 1.00× | 1.00× | 1.01× | +| linux-clang | 1.04× | 1.44× | 1.05× | +| linux-gcc | 0.99× | 1.03× | 1.00× | +| macos-clang | 1.08× | 0.99× | 0.96× | +| macos-gcc | 0.95× | 1.00× | 0.90× | +| windows-cl | 1.06× | 0.99× | 1.00× | +| windows-mingw | 1.00× | 1.00× | 0.97× | + + +### `strnstrn` + +Baseline is `strstr`. + +| Platform | near-start | near-end | miss | +| ------------- | ---------- | -------- | ----- | +| local Mac | 2.39× | 7.19× | 7.67× | +| linux-clang | 2.93× | 2.41× | 1.36× | +| linux-gcc | 3.60× | 3.24× | 1.80× | +| macos-clang | 3.08× | 6.75× | 3.46× | +| macos-gcc | 3.07× | 6.87× | 3.33× | +| windows-cl | 1.27× | 0.67× | 0.64× | +| windows-mingw | 1.32× | 0.52× | 0.41× | + + +## Directions so far + +Local Mac plus `linux-gcc`, `linux-clang`, `macos-gcc`, `macos-clang`, `windows-cl`, and `windows-mingw`. + +* **Anchors match** on every row of every run. +* **Early `strnicmp` favours `stlsoft_C_strnicmp`** on all seven runs, about 1.7–2.8×. +* **A 45-byte compare splits by C library.** Linux `strncasecmp` is about 9–11× faster. `windows-cl` `_strnicmp` is about 1.1–1.2× faster. The local Mac, both macOS cells, and `windows-mingw` favour `stlsoft_C_strnicmp` by about 1.1–1.4×. +* **`stlsoft_C_strnchr` stays close to `memchr`.** Most rows are within about 12%. The larger gaps are the misses on `windows-cl` (about 1.4× slower) and `windows-mingw` (about 1.2× slower). +* **`stlsoft_C_strnrchr` tracks `local_strnrchr`.** Linux Clang's short walk is the outlier: the local scan is about 1.4× slower there. The macOS long walks differ by up to about 12%. +* **`strnpbrkn` against `strpbrk` depends on the host.** The local Mac, both macOS cells, and `windows-mingw` favour `stlsoft_C_strnpbrkn` on every scenario. On the Apple cells the long scans are about 3.9–5.7×. On MinGW they are about 1.6×. Both Linux cells favour `stlsoft_C_strnpbrkn` on the early hit and favour `strpbrk` on the long scan. `windows-cl` favours `strpbrk` on all three. +* **Early `strnstrn` favours `stlsoft_C_strnstrn`** on all seven runs, about 1.3–3.6×. Late needle and miss favour it on the Mac, both macOS cells, and both Linux cells. They favour `strstr` on both Windows cells: about 1.5× on `windows-cl`, and about 1.9–2.5× on `windows-mingw`. + + +## Not yet done + +* Record compiler banners for each cell, and the local `CMAKE_BUILD_TYPE`. The `macos-gcc` log does not say whether that job's `gcc` is GNU or Apple Clang. +* Write the settled performance claim from the seven runs above, once those banners are known. + + + +