Reorganise the tree into business vs frontend as separate directories:
src/core/{domain,imports,app} (was system/, imports/, app/)
src/frontends/tui/ (was tui/ + main.cpp)
tests/tui/ (the FTXUI-coupled helper test)
All cross-dir #include paths rewritten; same-dir includes untouched.
CMake: essim_core is the frontend-agnostic business library — links libzip,
pugixml and bsdl, NO GUI toolkit. Each frontend is a self-contained
src/frontends/<name>/ (own CMakeLists, toolkit, main.cpp) that links
essim_core, selected with -DESSIM_FRONTEND=<name> (default tui; 'none' = core +
tests only, no toolkit fetched). FTXUI moved into the tui frontend. Tests are
split: essim_tests links essim_core (no FTXUI), essim_tui_tests links essim_tui.
Verified: default tui build green (ctest 2/2); ESSIM_FRONTEND=none builds the
core + tests with FTXUI never fetched and no `essim` binary.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
71 lines
3.0 KiB
C++
71 lines
3.0 KiB
C++
#include <doctest/doctest.h>
|
|
|
|
#include "core/domain/component_kind.hpp"
|
|
#include "core/domain/parts.hpp"
|
|
|
|
#include <memory>
|
|
|
|
TEST_CASE("infer_component_kind: passives") {
|
|
CHECK(infer_component_kind("R12") == ComponentKind::Passive);
|
|
CHECK(infer_component_kind("C1") == ComponentKind::Passive);
|
|
CHECK(infer_component_kind("L4") == ComponentKind::Passive);
|
|
CHECK(infer_component_kind("FB1") == ComponentKind::Passive);
|
|
CHECK(infer_component_kind("RN2") == ComponentKind::Passive);
|
|
CHECK(infer_component_kind("F3") == ComponentKind::Passive); // fuse
|
|
}
|
|
|
|
TEST_CASE("infer_component_kind: semiconductors") {
|
|
CHECK(infer_component_kind("D1") == ComponentKind::Semiconductor);
|
|
CHECK(infer_component_kind("Q4") == ComponentKind::Semiconductor);
|
|
CHECK(infer_component_kind("LED2") == ComponentKind::Semiconductor);
|
|
}
|
|
|
|
TEST_CASE("infer_component_kind: ICs") {
|
|
CHECK(infer_component_kind("U1") == ComponentKind::IntegratedCircuit);
|
|
CHECK(infer_component_kind("U100") == ComponentKind::IntegratedCircuit);
|
|
}
|
|
|
|
TEST_CASE("infer_component_kind: connectors") {
|
|
CHECK(infer_component_kind("J1") == ComponentKind::Connector);
|
|
CHECK(infer_component_kind("P0") == ComponentKind::Connector);
|
|
CHECK(infer_component_kind("J100") == ComponentKind::Connector);
|
|
}
|
|
|
|
TEST_CASE("infer_component_kind: misc") {
|
|
CHECK(infer_component_kind("TP1") == ComponentKind::TestPoint);
|
|
CHECK(infer_component_kind("SW1") == ComponentKind::Switch);
|
|
CHECK(infer_component_kind("Y1") == ComponentKind::Crystal);
|
|
CHECK(infer_component_kind("X1") == ComponentKind::Crystal);
|
|
CHECK(infer_component_kind("MK1") == ComponentKind::Mechanical);
|
|
CHECK(infer_component_kind("HS2") == ComponentKind::Mechanical);
|
|
}
|
|
|
|
TEST_CASE("infer_component_kind: fallback") {
|
|
CHECK(infer_component_kind("") == ComponentKind::Other);
|
|
CHECK(infer_component_kind("123") == ComponentKind::Other); // no letter prefix
|
|
CHECK(infer_component_kind("ZZZ1") == ComponentKind::Other); // unknown prefix
|
|
}
|
|
|
|
TEST_CASE("infer_component_kind: case insensitive") {
|
|
CHECK(infer_component_kind("r1") == ComponentKind::Passive);
|
|
CHECK(infer_component_kind("u1") == ComponentKind::IntegratedCircuit);
|
|
}
|
|
|
|
TEST_CASE("Part ctor populates kind from name") {
|
|
auto r = std::make_unique<Part>("R12");
|
|
auto u = std::make_unique<Part>("U7");
|
|
auto j = std::make_unique<Part>("J1");
|
|
CHECK(r->kind == ComponentKind::Passive);
|
|
CHECK(u->kind == ComponentKind::IntegratedCircuit);
|
|
CHECK(j->kind == ComponentKind::Connector);
|
|
}
|
|
|
|
TEST_CASE("component_kind_from_name accepts canonical and aliases") {
|
|
ComponentKind k;
|
|
CHECK(component_kind_from_name("passive", k)); CHECK(k == ComponentKind::Passive);
|
|
CHECK(component_kind_from_name("ic", k)); CHECK(k == ComponentKind::IntegratedCircuit);
|
|
CHECK(component_kind_from_name("conn", k)); CHECK(k == ComponentKind::Connector);
|
|
CHECK(component_kind_from_name("Connector", k)); CHECK(k == ComponentKind::Connector);
|
|
CHECK(!component_kind_from_name("nonsense", k));
|
|
}
|