Restructure into umbrella modules (~55 -> 16 targets)
Headers move, CMake targets merge, C++ namespaces stay unchanged: - Core: Scope, Lazy, Counted, Flags, Hash, Bits, Uuid, TypeList, TypeMap, Variant - Functional: Pipeline, Either, Result, Retry - Containers: Ring, Pool, PriorityQueue, LRU, Trie, Graph, DisjointSet, Bitset, Interval - Math: +Matrix, Numeric, Random, Histogram - Text: Str, Format, Tokenizer, Diff, Encoding, Semver - Data: Json, Csv, Ini - Async: Coro, Concurrency, EventBus, Observable - Time: +Bench - Log: Log facade + Logging framework (facade now header-only, breaking the Stacktrace<->Log link cycle the merge would have created) - System: FileSystem + Process - Configuration: +Argparse - Unchanged: Stacktrace, Plugin, StateMachine, Testing, TestingMock, Detail Module system fixes: - OPTIONAL_DEPS resolution deferred to void_finalize_modules() so it no longer depends on the alphabetical discovery order of src/ subdirs (Testing -> Text would have been silently dropped). - Every header-only module now has a tracked module.cmake; previously the empty src/<Name> marker dirs were untracked, so a fresh clone would have silently skipped those modules. - VOID_HAS_LOGGING/CONCURRENCY/STR consumers renamed to LOG/ASYNC/TEXT. Tests move to tests/standalone/<Umbrella>/<Feature>.cpp (Result suite files prefixed: ResultBasic etc.). Test count verified identical (831) before and after. README/CLAUDE.md module tables updated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
da2e93c405
commit
28b94883fd
156 files changed
+278
-220
No files matched your search
@@ -0,0 +1,108 @@
|
||||
#include <Void/Data/Csv.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// ── parse ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test csv_parse_simple()
|
||||
{
|
||||
const auto t = Void::Csv::parse("a,b,c\n1,2,3\n");
|
||||
Void::Testing::expect_eq(t.size(), std::size_t{2});
|
||||
Void::Testing::expect_eq(t[0][0], std::string{"a"});
|
||||
Void::Testing::expect_eq(t[1][2], std::string{"3"});
|
||||
}
|
||||
|
||||
Void::Testing::Test csv_parse_quoted_field()
|
||||
{
|
||||
const auto t = Void::Csv::parse("\"hello, world\",42\n");
|
||||
Void::Testing::expect_eq(t[0][0], std::string{"hello, world"});
|
||||
Void::Testing::expect_eq(t[0][1], std::string{"42"});
|
||||
}
|
||||
|
||||
Void::Testing::Test csv_parse_doubled_quote()
|
||||
{
|
||||
const auto t = Void::Csv::parse("\"say \"\"hi\"\"\"\n");
|
||||
Void::Testing::expect_eq(t[0][0], std::string{"say \"hi\""});
|
||||
}
|
||||
|
||||
Void::Testing::Test csv_parse_empty_fields()
|
||||
{
|
||||
const auto t = Void::Csv::parse(",b,\n");
|
||||
Void::Testing::expect_eq(t[0].size(), std::size_t{3});
|
||||
Void::Testing::expect(t[0][0].empty());
|
||||
Void::Testing::expect(t[0][2].empty());
|
||||
}
|
||||
|
||||
Void::Testing::Test csv_parse_custom_delimiter()
|
||||
{
|
||||
const auto t = Void::Csv::parse("a;b;c\n", ';');
|
||||
Void::Testing::expect_eq(t[0].size(), std::size_t{3});
|
||||
Void::Testing::expect_eq(t[0][1], std::string{"b"});
|
||||
}
|
||||
|
||||
Void::Testing::Test csv_parse_crlf()
|
||||
{
|
||||
const auto t = Void::Csv::parse("a,b\r\n1,2\r\n");
|
||||
Void::Testing::expect_eq(t.size(), std::size_t{2});
|
||||
}
|
||||
|
||||
Void::Testing::Test csv_parse_empty_input()
|
||||
{
|
||||
const auto t = Void::Csv::parse("");
|
||||
Void::Testing::expect(t.empty());
|
||||
}
|
||||
|
||||
// ── serialize ─────────────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test csv_serialize_simple()
|
||||
{
|
||||
const Void::Csv::Table t = {{"a","b","c"},{"1","2","3"}};
|
||||
const auto s = Void::Csv::serialize(t);
|
||||
Void::Testing::expect(s.find("a,b,c") != std::string::npos);
|
||||
Void::Testing::expect(s.find("1,2,3") != std::string::npos);
|
||||
}
|
||||
|
||||
Void::Testing::Test csv_serialize_quotes_commas()
|
||||
{
|
||||
const Void::Csv::Table t = {{"hello, world"}};
|
||||
const auto s = Void::Csv::serialize(t);
|
||||
Void::Testing::expect(s.find('"') != std::string::npos);
|
||||
}
|
||||
|
||||
Void::Testing::Test csv_round_trip()
|
||||
{
|
||||
const Void::Csv::Table original = {
|
||||
{"Name","Score"},{"Alice","100"},{"Bob","90"}};
|
||||
const auto serialized = Void::Csv::serialize(original);
|
||||
const auto parsed = Void::Csv::parse(serialized);
|
||||
Void::Testing::expect_eq(parsed.size(), original.size());
|
||||
Void::Testing::expect_eq(parsed[0][0], original[0][0]);
|
||||
}
|
||||
|
||||
// ── parse_with_header ─────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test csv_with_header_get_column()
|
||||
{
|
||||
const auto csv = Void::Csv::parse_with_header("Name,Score\nAlice,100\n");
|
||||
Void::Testing::expect(csv.has_value());
|
||||
const auto score = csv->get(csv->rows[0], "Score");
|
||||
Void::Testing::expect(score.has_value());
|
||||
Void::Testing::expect_eq(*score, std::string_view{"100"});
|
||||
}
|
||||
|
||||
Void::Testing::Test csv_with_header_unknown_col()
|
||||
{
|
||||
const auto csv = Void::Csv::parse_with_header("Name\nAlice\n");
|
||||
Void::Testing::expect(csv.has_value());
|
||||
Void::Testing::expect(!csv->get(csv->rows[0], "Missing").has_value());
|
||||
}
|
||||
|
||||
Void::Testing::Test csv_with_header_col_index()
|
||||
{
|
||||
const auto csv = Void::Csv::parse_with_header("A,B,C\n1,2,3\n");
|
||||
Void::Testing::expect(csv.has_value());
|
||||
Void::Testing::expect_eq(*csv->col_index("B"), std::size_t{1});
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
#include <Void/Data/Ini.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
static constexpr const char* SAMPLE = R"(
|
||||
; comment
|
||||
[database]
|
||||
host = localhost
|
||||
port = 5432
|
||||
name = "my db"
|
||||
|
||||
[server]
|
||||
# another comment
|
||||
host = 0.0.0.0
|
||||
port = 8080
|
||||
)";
|
||||
|
||||
// ── parse ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test ini_parse_sections()
|
||||
{
|
||||
auto f = Void::Ini::IniFile::from_string(SAMPLE);
|
||||
Void::Testing::expect(f.has_section("database"));
|
||||
Void::Testing::expect(f.has_section("server"));
|
||||
}
|
||||
|
||||
Void::Testing::Test ini_parse_values()
|
||||
{
|
||||
auto f = Void::Ini::IniFile::from_string(SAMPLE);
|
||||
const auto host = f.get("database", "host");
|
||||
Void::Testing::expect(host.has_value());
|
||||
Void::Testing::expect_eq(*host, std::string{"localhost"});
|
||||
}
|
||||
|
||||
Void::Testing::Test ini_parse_quoted_value()
|
||||
{
|
||||
auto f = Void::Ini::IniFile::from_string(SAMPLE);
|
||||
const auto name = f.get("database", "name");
|
||||
Void::Testing::expect(name.has_value());
|
||||
Void::Testing::expect_eq(*name, std::string{"my db"});
|
||||
}
|
||||
|
||||
Void::Testing::Test ini_missing_key_returns_nullopt()
|
||||
{
|
||||
auto f = Void::Ini::IniFile::from_string(SAMPLE);
|
||||
Void::Testing::expect(!f.get("database", "password").has_value());
|
||||
}
|
||||
|
||||
Void::Testing::Test ini_missing_section_returns_nullopt()
|
||||
{
|
||||
auto f = Void::Ini::IniFile::from_string(SAMPLE);
|
||||
Void::Testing::expect(!f.get("auth", "token").has_value());
|
||||
}
|
||||
|
||||
Void::Testing::Test ini_get_or_fallback()
|
||||
{
|
||||
auto f = Void::Ini::IniFile::from_string(SAMPLE);
|
||||
Void::Testing::expect_eq(f.get_or("database", "timeout", "30"), std::string{"30"});
|
||||
}
|
||||
|
||||
Void::Testing::Test ini_has_key()
|
||||
{
|
||||
auto f = Void::Ini::IniFile::from_string(SAMPLE);
|
||||
Void::Testing::expect(f.has_key("server", "port"));
|
||||
Void::Testing::expect(!f.has_key("server", "ssl"));
|
||||
}
|
||||
|
||||
// ── set / serialize ───────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test ini_set_and_get()
|
||||
{
|
||||
Void::Ini::IniFile f;
|
||||
f.set("app", "version", "1.0");
|
||||
const auto v = f.get("app", "version");
|
||||
Void::Testing::expect(v.has_value());
|
||||
Void::Testing::expect_eq(*v, std::string{"1.0"});
|
||||
}
|
||||
|
||||
Void::Testing::Test ini_serialize_round_trip()
|
||||
{
|
||||
Void::Ini::IniFile f;
|
||||
f.set("section", "key", "value");
|
||||
const auto serialized = f.serialize();
|
||||
auto f2 = Void::Ini::IniFile::from_string(serialized);
|
||||
const auto v = f2.get("section", "key");
|
||||
Void::Testing::expect(v.has_value());
|
||||
Void::Testing::expect_eq(*v, std::string{"value"});
|
||||
}
|
||||
|
||||
// ── error handling ────────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test ini_unclosed_section_is_error()
|
||||
{
|
||||
Void::Ini::IniFile f;
|
||||
const auto err = Void::Ini::IniFile::parse(f, "[unclosed");
|
||||
Void::Testing::expect(err.has_value());
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
#include <Void/Data/Json.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace Void::Json;
|
||||
|
||||
// ── parse: primitives ─────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test json_parse_null()
|
||||
{
|
||||
const auto v = parse("null");
|
||||
Void::Testing::expect(v.has_value());
|
||||
Void::Testing::expect(v->is_null());
|
||||
}
|
||||
|
||||
Void::Testing::Test json_parse_true()
|
||||
{
|
||||
const auto v = parse("true");
|
||||
Void::Testing::expect(v.has_value());
|
||||
Void::Testing::expect(v->is_bool());
|
||||
Void::Testing::expect(v->as_bool());
|
||||
}
|
||||
|
||||
Void::Testing::Test json_parse_false()
|
||||
{
|
||||
const auto v = parse("false");
|
||||
Void::Testing::expect(v.has_value() && v->is_bool() && !v->as_bool());
|
||||
}
|
||||
|
||||
Void::Testing::Test json_parse_integer()
|
||||
{
|
||||
const auto v = parse("42");
|
||||
Void::Testing::expect(v.has_value() && v->is_number());
|
||||
Void::Testing::expect_eq(v->as_int(), std::int64_t{42});
|
||||
}
|
||||
|
||||
Void::Testing::Test json_parse_negative()
|
||||
{
|
||||
const auto v = parse("-7");
|
||||
Void::Testing::expect(v.has_value());
|
||||
Void::Testing::expect_eq(v->as_int(), std::int64_t{-7});
|
||||
}
|
||||
|
||||
Void::Testing::Test json_parse_float()
|
||||
{
|
||||
const auto v = parse("3.14");
|
||||
Void::Testing::expect(v.has_value() && v->is_number());
|
||||
Void::Testing::expect(v->as_number() > 3.13 && v->as_number() < 3.15);
|
||||
}
|
||||
|
||||
Void::Testing::Test json_parse_exponent()
|
||||
{
|
||||
const auto v = parse("1.5e2");
|
||||
Void::Testing::expect(v.has_value());
|
||||
Void::Testing::expect_eq(v->as_int(), std::int64_t{150});
|
||||
}
|
||||
|
||||
// ── parse: strings ────────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test json_parse_string_simple()
|
||||
{
|
||||
const auto v = parse(R"("hello")");
|
||||
Void::Testing::expect(v.has_value() && v->is_string());
|
||||
Void::Testing::expect_eq(v->as_string(), std::string{"hello"});
|
||||
}
|
||||
|
||||
Void::Testing::Test json_parse_string_escapes()
|
||||
{
|
||||
const auto v = parse(R"("line1\nline2")");
|
||||
Void::Testing::expect(v.has_value());
|
||||
Void::Testing::expect_eq(v->as_string(), std::string{"line1\nline2"});
|
||||
}
|
||||
|
||||
Void::Testing::Test json_parse_string_unicode()
|
||||
{
|
||||
const auto v = parse(R"("A")"); // 'A'
|
||||
Void::Testing::expect(v.has_value());
|
||||
Void::Testing::expect_eq(v->as_string(), std::string{"A"});
|
||||
}
|
||||
|
||||
Void::Testing::Test json_parse_string_empty()
|
||||
{
|
||||
const auto v = parse(R"("")");
|
||||
Void::Testing::expect(v.has_value() && v->as_string().empty());
|
||||
}
|
||||
|
||||
// ── parse: arrays ─────────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test json_parse_array_empty()
|
||||
{
|
||||
const auto v = parse("[]");
|
||||
Void::Testing::expect(v.has_value() && v->is_array() && v->empty());
|
||||
}
|
||||
|
||||
Void::Testing::Test json_parse_array_ints()
|
||||
{
|
||||
const auto v = parse("[1, 2, 3]");
|
||||
Void::Testing::expect(v.has_value() && v->is_array());
|
||||
Void::Testing::expect_eq(v->size(), std::size_t{3});
|
||||
Void::Testing::expect_eq((*v)[0].as_int(), std::int64_t{1});
|
||||
Void::Testing::expect_eq((*v)[2].as_int(), std::int64_t{3});
|
||||
}
|
||||
|
||||
Void::Testing::Test json_parse_array_mixed()
|
||||
{
|
||||
const auto v = parse(R"([null, true, "hi", 1.5])");
|
||||
Void::Testing::expect(v.has_value() && v->size() == 4);
|
||||
Void::Testing::expect((*v)[0].is_null());
|
||||
Void::Testing::expect((*v)[1].is_bool());
|
||||
Void::Testing::expect((*v)[2].is_string());
|
||||
Void::Testing::expect((*v)[3].is_number());
|
||||
}
|
||||
|
||||
Void::Testing::Test json_parse_array_nested()
|
||||
{
|
||||
const auto v = parse("[[1,2],[3,4]]");
|
||||
Void::Testing::expect(v.has_value() && v->size() == 2);
|
||||
Void::Testing::expect_eq((*v)[1][0].as_int(), std::int64_t{3});
|
||||
}
|
||||
|
||||
// ── parse: objects ────────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test json_parse_object_empty()
|
||||
{
|
||||
const auto v = parse("{}");
|
||||
Void::Testing::expect(v.has_value() && v->is_object() && v->empty());
|
||||
}
|
||||
|
||||
Void::Testing::Test json_parse_object_simple()
|
||||
{
|
||||
const auto v = parse(R"({"name":"Alice","age":30})");
|
||||
Void::Testing::expect(v.has_value() && v->is_object());
|
||||
Void::Testing::expect_eq((*v)["name"].as_string(), std::string{"Alice"});
|
||||
Void::Testing::expect_eq((*v)["age"].as_int(), std::int64_t{30});
|
||||
}
|
||||
|
||||
Void::Testing::Test json_parse_object_nested()
|
||||
{
|
||||
const auto v = parse(R"({"a":{"b":{"c":42}}})");
|
||||
Void::Testing::expect(v.has_value());
|
||||
Void::Testing::expect_eq((*v)["a"]["b"]["c"].as_int(), std::int64_t{42});
|
||||
}
|
||||
|
||||
Void::Testing::Test json_parse_whitespace()
|
||||
{
|
||||
const auto v = parse(" {\n \"x\" : 1\n} ");
|
||||
Void::Testing::expect(v.has_value() && v->is_object());
|
||||
}
|
||||
|
||||
// ── parse: errors ─────────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test json_parse_invalid_returns_error()
|
||||
{
|
||||
Void::Testing::expect(!parse("not json").has_value());
|
||||
Void::Testing::expect(!parse("[1,2,").has_value());
|
||||
Void::Testing::expect(!parse(R"({"key"})").has_value());
|
||||
}
|
||||
|
||||
Void::Testing::Test json_parse_trailing_chars_error()
|
||||
{
|
||||
Void::Testing::expect(!parse("1 2").has_value());
|
||||
}
|
||||
|
||||
// ── serialize ─────────────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test json_serialize_null()
|
||||
{
|
||||
Void::Testing::expect_eq(serialize(Value{}), std::string{"null"});
|
||||
}
|
||||
|
||||
Void::Testing::Test json_serialize_primitives()
|
||||
{
|
||||
Void::Testing::expect_eq(serialize(Value{true}), std::string{"true"});
|
||||
Void::Testing::expect_eq(serialize(Value{false}), std::string{"false"});
|
||||
Void::Testing::expect_eq(serialize(Value{42}), std::string{"42"});
|
||||
Void::Testing::expect_eq(serialize(Value{"hi"}), std::string{R"("hi")"});
|
||||
}
|
||||
|
||||
Void::Testing::Test json_serialize_special_chars()
|
||||
{
|
||||
const auto s = serialize(Value{"line\nnewline"});
|
||||
Void::Testing::expect(s.find("\\n") != std::string::npos);
|
||||
}
|
||||
|
||||
Void::Testing::Test json_serialize_array()
|
||||
{
|
||||
const auto v = Value{Value::Array_t{Value{1}, Value{2}, Value{3}}};
|
||||
const auto s = serialize(v);
|
||||
Void::Testing::expect_eq(s, std::string{"[1,2,3]"});
|
||||
}
|
||||
|
||||
Void::Testing::Test json_serialize_object()
|
||||
{
|
||||
Value::Object_t obj;
|
||||
obj.emplace_back("a", Value{1});
|
||||
const auto s = serialize(Value{std::move(obj)});
|
||||
Void::Testing::expect(s.find("\"a\"") != std::string::npos);
|
||||
Void::Testing::expect(s.find(":1") != std::string::npos);
|
||||
}
|
||||
|
||||
Void::Testing::Test json_round_trip()
|
||||
{
|
||||
const std::string src = R"({"name":"Bob","scores":[1,2,3],"active":true})";
|
||||
const auto v = parse(src);
|
||||
Void::Testing::expect(v.has_value());
|
||||
const auto out = serialize(*v);
|
||||
const auto v2 = parse(out);
|
||||
Void::Testing::expect(v2.has_value());
|
||||
Void::Testing::expect_eq((*v2)["name"].as_string(), std::string{"Bob"});
|
||||
}
|
||||
|
||||
// ── accessor API ──────────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test json_find_returns_nullptr_for_missing()
|
||||
{
|
||||
const auto v = parse(R"({"x":1})");
|
||||
Void::Testing::expect(v->find("y") == nullptr);
|
||||
Void::Testing::expect(v->find("x") != nullptr);
|
||||
}
|
||||
|
||||
Void::Testing::Test json_optional_getters()
|
||||
{
|
||||
const auto v = parse("42");
|
||||
Void::Testing::expect(v->get_number().has_value());
|
||||
Void::Testing::expect(!v->get_bool().has_value());
|
||||
Void::Testing::expect(!v->get_string().has_value());
|
||||
}
|
||||
|
||||
Void::Testing::Test json_copy_deep()
|
||||
{
|
||||
const auto v1 = parse(R"([1,2,3])");
|
||||
Void::Testing::expect(v1.has_value());
|
||||
Value v2 = *v1;
|
||||
Void::Testing::expect_eq(v2.size(), std::size_t{3});
|
||||
}
|
||||
Reference in new issue
Block a user