This commit is contained in:
deeaitch committed 2026-10-06 17:14:50 -04:00
1 parent e5d818d9b2
commit a533d9aa00
13 files changed
+527 -12

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
// Standalone C++17 test: no Qt required.
#include "dbc_tree_builder.h"
#include <stdexcept>
#include <type_traits>
static void Check(bool condition) {
if (!condition) throw std::runtime_error("Tree navigation test failed");
}
int main() {
static_assert(!std::is_move_constructible<TreeNode>::value, "Node addresses must be stable");
DbcDatabase database;
FrameInfo frame;
SignalInfo signal;
frame.signals.push_back(signal);
frame.signals.push_back(signal);
database.frames.push_back(frame);
database.frames.push_back(frame);
auto root = DbcTreeBuilder().Build(database);
Check(root->GetParent() == nullptr && root->GetRow() == 0);
root->AddChild(nullptr);
Check(root->GetChildCount() == 2 && !root->GetChild(2));
for (std::size_t row = 0; row < root->GetChildCount(); ++row) {
const TreeNode *child = root->GetChild(row);
Check(child->GetParent() == root.get() && child->GetRow() == row);
for (std::size_t position = 0; position < child->GetChildCount(); ++position) {
const TreeNode *leaf = child->GetChild(position);
Check(leaf->GetParent() == child && leaf->GetRow() == position);
}
}
auto transferred = std::move(root);
Check(transferred->GetChild(0)->GetParent() == transferred.get());
}