make test builds and runs 32 steps; not green: misc.diff and mplex.e2e fail on real module bugs. test_main.cpp replaced by util_config_test.cpp; stale *.mk and store_test rule removed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
58 lines
3.2 KiB
C++
58 lines
3.2 KiB
C++
// Unit checks for src/util (text helpers, ansi) and src/config (consts, Config, tag resolution),
|
|
// plus the CLI help smoke. This is the surviving part of the old tests/test_main.cpp: its shell
|
|
// section is covered by tests/shell_test.cpp, its cli section by tests/cli_test.cpp, and its llm
|
|
// section exercised the placeholder llm API that the agent port removed (ChatClient("openai", ...),
|
|
// ModelHealth, Opencode, provider_info); the agent tests (agent_diff, agent_e2e) replace it.
|
|
// Plain asserts, so NDEBUG must stay off.
|
|
#undef NDEBUG
|
|
#include "../src/cli/cli.h"
|
|
#include "../src/util/ansi.h"
|
|
#include "../src/util/text.h"
|
|
#include "../src/config/config.h"
|
|
#include "../src/config/consts.h"
|
|
#include <cassert>
|
|
#include <cstdio>
|
|
#include <filesystem>
|
|
#include <map>
|
|
|
|
int main() {
|
|
detz::cli::Parser p;
|
|
const char* a0 = "detz";
|
|
auto c = p.parse(1, (char**)&a0);
|
|
assert(c.name == "--help");
|
|
assert(c.run() == 0);
|
|
// util + config
|
|
assert(detz::Consts::kTotalStepCap == 500 && detz::Consts::kAuditMaxChars == 20000);
|
|
assert(std::string(detz::kDefaultModel) == "muse");
|
|
assert(!detz::ZenFreeModels().empty() && !detz::PollinationsModels().empty());
|
|
assert(detz::Paint("x", detz::Ansi::kRed).find("x") != std::string::npos);
|
|
assert(detz::Truncate("abc", 1500, 500) == "abc");
|
|
std::string big(3000, 'a');
|
|
assert(detz::Truncate(big, 100, 100).find("chars truncated") != std::string::npos);
|
|
assert(detz::TruncMarker(5).find("5") != std::string::npos);
|
|
assert(detz::CappedText(std::string("hi")).text == "hi");
|
|
assert(detz::ChunkLines("").empty());
|
|
assert(detz::ChunkLines("a\nb").size() == 1);
|
|
assert(detz::CollapseRepeatedLines("x\nx\nx").find("repeated 2") != std::string::npos);
|
|
assert(detz::CollapseRepeatedLines("a\nb").find("repeated") == std::string::npos);
|
|
{ auto [tags, rest] = detz::SplitLeadingTags("@a @b hello"); assert(tags.size() == 2 && rest == "hello"); }
|
|
{ auto [tags, rest] = detz::SplitLeadingTags("hi"); assert(tags.empty() && rest == "hi"); }
|
|
{ auto dir = std::filesystem::temp_directory_path().string();
|
|
std::string f = dir + "/detz_m2_test.txt"; FILE* fh = std::fopen(f.c_str(), "w"); std::fputs("x", fh); std::fclose(fh);
|
|
assert(detz::ExpandFileMentions("@detz_m2_test.txt", dir).find("detz_m2_test") != std::string::npos);
|
|
assert(detz::ExpandFileMentions("see @nope-missing-xyz", dir).find("@nope") != std::string::npos);
|
|
auto cf = detz::CompleteFiles("detz_m2_test", dir); assert(!cf.empty());
|
|
assert(detz::CompleteFiles("zzz-no-match-xyz", dir).empty());
|
|
std::filesystem::remove(f); }
|
|
{ detz::Config cfg = detz::Config::FromEnv(); assert(!cfg.model.empty());
|
|
assert(!detz::SettingsCatalog().empty());
|
|
assert(!detz::SplitModels("a, b;c").empty());
|
|
auto ids = detz::KnownModelIds(cfg); assert(!ids.empty());
|
|
auto rt = detz::ResolveTag("auto", {}, ids, "/tmp"); assert(rt.first == "auto");
|
|
auto ru = detz::ResolveTag("zzz-unknown-xyz", {}, ids, "/tmp"); assert(ru.first == "unknown");
|
|
std::map<std::string,std::string> bots = {{"bob", "BotBob"}};
|
|
auto rb = detz::ResolveTag("bob", bots, ids, "/tmp"); assert(rb.first == "bot"); }
|
|
std::puts("util+config OK");
|
|
return 0;
|
|
}
|