Add 20+ new modules with tests: Pipeline, Matrix, Tokenizer, ScopeGuard, Bitset, Optional, Counted, Curry, TypeMap, Bench, DisjointSet, Histogram, StopWatch, and more

Also fixes Diff/Memo/PriorityQueue from previous session: LineDiff is now
an alias for Edit<string> so count_op/apply work on line diffs; Memoized
uses std::apply instead of type-based get to handle duplicate arg types.

874/877 tests pass (3 are platform-gated plugin tests).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Sonnet 4.6 committed 2026-05-14 23:49:09 +03:00
1 parent cb4dd58500
commit 58ff7b38a0
65 files changed
+8987 -37

No files matched your search

+173
View File
@@ -0,0 +1,173 @@
#include <Void/Str/Str.hpp>
#include <Void/Testing/Assert.hpp>
#include <Void/Testing/Test.hpp>
#include <string>
#include <vector>
using namespace Void::Str;
// ── trim ──────────────────────────────────────────────────────────────────────
Void::Testing::Test str_trim_left()
{
Void::Testing::expect_eq(trim_left(" hello"), std::string_view{"hello"});
Void::Testing::expect_eq(trim_left("hello"), std::string_view{"hello"});
}
Void::Testing::Test str_trim_right()
{
Void::Testing::expect_eq(trim_right("hello "), std::string_view{"hello"});
}
Void::Testing::Test str_trim_both()
{
Void::Testing::expect_eq(trim(" hello "), std::string_view{"hello"});
Void::Testing::expect_eq(trim(""), std::string_view{""});
}
// ── case ──────────────────────────────────────────────────────────────────────
Void::Testing::Test str_to_lower()
{
Void::Testing::expect_eq(to_lower("Hello World"), std::string{"hello world"});
}
Void::Testing::Test str_to_upper()
{
Void::Testing::expect_eq(to_upper("hello"), std::string{"HELLO"});
}
// ── predicates ────────────────────────────────────────────────────────────────
Void::Testing::Test str_starts_with()
{
Void::Testing::expect(starts_with("foobar", "foo"));
Void::Testing::expect(!starts_with("foobar", "bar"));
}
Void::Testing::Test str_ends_with()
{
Void::Testing::expect(ends_with("foobar", "bar"));
Void::Testing::expect(!ends_with("foobar", "foo"));
}
Void::Testing::Test str_contains()
{
Void::Testing::expect(contains("hello world", "world"));
Void::Testing::expect(!contains("hello", "xyz"));
}
Void::Testing::Test str_is_alpha()
{
Void::Testing::expect(is_alpha("abc"));
Void::Testing::expect(!is_alpha("ab1"));
Void::Testing::expect(!is_alpha(""));
}
Void::Testing::Test str_is_digit()
{
Void::Testing::expect(is_digit("123"));
Void::Testing::expect(!is_digit("12a"));
}
Void::Testing::Test str_is_alnum()
{
Void::Testing::expect(is_alnum("abc123"));
Void::Testing::expect(!is_alnum("abc!"));
}
// ── split / join ──────────────────────────────────────────────────────────────
Void::Testing::Test str_split_basic()
{
const auto parts = split("a,b,c", ",");
Void::Testing::expect_eq(parts.size(), std::size_t{3});
Void::Testing::expect_eq(parts[0], std::string_view{"a"});
Void::Testing::expect_eq(parts[2], std::string_view{"c"});
}
Void::Testing::Test str_split_no_delim()
{
const auto parts = split("hello", ",");
Void::Testing::expect_eq(parts.size(), std::size_t{1});
Void::Testing::expect_eq(parts[0], std::string_view{"hello"});
}
Void::Testing::Test str_split_once()
{
const auto parts = split_once("key=value=extra", "=");
Void::Testing::expect_eq(parts.size(), std::size_t{2});
Void::Testing::expect_eq(parts[0], std::string_view{"key"});
Void::Testing::expect_eq(parts[1], std::string_view{"value=extra"});
}
Void::Testing::Test str_join()
{
const std::vector<std::string> v{"a", "b", "c"};
Void::Testing::expect_eq(join(v, ", "), std::string{"a, b, c"});
}
// ── replace ───────────────────────────────────────────────────────────────────
Void::Testing::Test str_replace_all()
{
Void::Testing::expect_eq(replace_all("aabaa", "aa", "x"), std::string{"xbx"});
}
Void::Testing::Test str_replace_all_no_match()
{
Void::Testing::expect_eq(replace_all("hello", "xyz", "!"), std::string{"hello"});
}
// ── repeat ────────────────────────────────────────────────────────────────────
Void::Testing::Test str_repeat()
{
Void::Testing::expect_eq(repeat("ab", 3), std::string{"ababab"});
Void::Testing::expect_eq(repeat("x", 0), std::string{""});
}
// ── count ─────────────────────────────────────────────────────────────────────
Void::Testing::Test str_count_occurrences()
{
Void::Testing::expect_eq(count("ababab", "ab"), std::size_t{3});
Void::Testing::expect_eq(count("hello", "xyz"), std::size_t{0});
}
// ── pad ───────────────────────────────────────────────────────────────────────
Void::Testing::Test str_pad_left()
{
Void::Testing::expect_eq(pad_left("hi", 5), std::string{" hi"});
Void::Testing::expect_eq(pad_left("hello", 3), std::string{"hello"});
}
Void::Testing::Test str_pad_right()
{
Void::Testing::expect_eq(pad_right("hi", 5), std::string{"hi "});
}
// ── numeric conversion ────────────────────────────────────────────────────────
Void::Testing::Test str_to_int_valid()
{
int v = 0;
Void::Testing::expect(to_int("42", v));
Void::Testing::expect_eq(v, 42);
}
Void::Testing::Test str_to_int_invalid()
{
int v = 0;
Void::Testing::expect(!to_int("abc", v));
Void::Testing::expect(!to_int("12x", v));
}
Void::Testing::Test str_to_double_valid()
{
double v = 0.0;
Void::Testing::expect(to_double("3.14", v));
Void::Testing::expect(v > 3.13 && v < 3.15);
}