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:
1 parent
cb4dd58500
commit
58ff7b38a0
65 files changed
+8987
-37
No files matched your search
@@ -0,0 +1,105 @@
|
||||
#include <Void/TypeMap/TypeMap.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace Void::TypeMap;
|
||||
|
||||
Void::Testing::Test typemap_put_and_get()
|
||||
{
|
||||
TypeMap m;
|
||||
m.put<int>(42);
|
||||
const auto v = m.get<int>();
|
||||
Void::Testing::expect(v.has_value());
|
||||
Void::Testing::expect_eq(*v, 42);
|
||||
}
|
||||
|
||||
Void::Testing::Test typemap_get_absent_returns_nullopt()
|
||||
{
|
||||
TypeMap m;
|
||||
Void::Testing::expect(!m.get<int>().has_value());
|
||||
}
|
||||
|
||||
Void::Testing::Test typemap_multiple_types()
|
||||
{
|
||||
TypeMap m;
|
||||
m.put<int>(1);
|
||||
m.put<double>(3.14);
|
||||
m.put<std::string>(std::string{"hello"});
|
||||
Void::Testing::expect_eq(*m.get<int>(), 1);
|
||||
Void::Testing::expect(*m.get<double>() > 3.1 && *m.get<double>() < 3.2);
|
||||
Void::Testing::expect_eq(*m.get<std::string>(), std::string{"hello"});
|
||||
}
|
||||
|
||||
Void::Testing::Test typemap_put_overwrites()
|
||||
{
|
||||
TypeMap m;
|
||||
m.put<int>(10);
|
||||
m.put<int>(20);
|
||||
Void::Testing::expect_eq(*m.get<int>(), 20);
|
||||
Void::Testing::expect_eq(m.size(), std::size_t{1});
|
||||
}
|
||||
|
||||
Void::Testing::Test typemap_contains()
|
||||
{
|
||||
TypeMap m;
|
||||
m.put<int>(1);
|
||||
Void::Testing::expect(m.contains<int>());
|
||||
Void::Testing::expect(!m.contains<double>());
|
||||
}
|
||||
|
||||
Void::Testing::Test typemap_erase()
|
||||
{
|
||||
TypeMap m;
|
||||
m.put<int>(1);
|
||||
const bool erased = m.erase<int>();
|
||||
Void::Testing::expect(erased);
|
||||
Void::Testing::expect(!m.contains<int>());
|
||||
Void::Testing::expect(!m.erase<int>()); // second erase returns false
|
||||
}
|
||||
|
||||
Void::Testing::Test typemap_get_or_throw_absent()
|
||||
{
|
||||
TypeMap m;
|
||||
bool threw = false;
|
||||
try { [[maybe_unused]] auto v = m.get_or_throw<int>(); } catch (...) { threw = true; }
|
||||
Void::Testing::expect(threw);
|
||||
}
|
||||
|
||||
Void::Testing::Test typemap_get_or_default()
|
||||
{
|
||||
TypeMap m;
|
||||
Void::Testing::expect_eq(m.get_or<int>(99), 99);
|
||||
m.put<int>(42);
|
||||
Void::Testing::expect_eq(m.get_or<int>(99), 42);
|
||||
}
|
||||
|
||||
Void::Testing::Test typemap_get_or_insert()
|
||||
{
|
||||
TypeMap m;
|
||||
int& r1 = m.get_or_insert<int>(100);
|
||||
Void::Testing::expect_eq(r1, 100);
|
||||
int& r2 = m.get_or_insert<int>(999); // should not overwrite
|
||||
Void::Testing::expect_eq(r2, 100);
|
||||
}
|
||||
|
||||
Void::Testing::Test typemap_size_and_empty()
|
||||
{
|
||||
TypeMap m;
|
||||
Void::Testing::expect(m.empty());
|
||||
Void::Testing::expect_eq(m.size(), std::size_t{0});
|
||||
m.put<int>(1);
|
||||
m.put<double>(2.0);
|
||||
Void::Testing::expect_eq(m.size(), std::size_t{2});
|
||||
Void::Testing::expect(!m.empty());
|
||||
}
|
||||
|
||||
Void::Testing::Test typemap_clear()
|
||||
{
|
||||
TypeMap m;
|
||||
m.put<int>(1);
|
||||
m.put<std::string>(std::string{"x"});
|
||||
m.clear();
|
||||
Void::Testing::expect(m.empty());
|
||||
}
|
||||
Reference in new issue
Block a user