Files
ViewDesignEngine/tests/core/test_version.cpp
T
hm a29df07652 feat(brep): CBRA hardening — trim-domain cut events, coincident-face merge, assembly cleanup (1.0.434)
- CB1 (WP-C): build_cut_graph now clips intersection branches to the intersection of both faces' trim domains; exact curves use a signed intrusion field plus 60-step bisection and closed-form fractional-parameter evaluation, giving machine-precision boundary events (oblique residual 1.4e-15, 20 endpoints cluster into 12 pairs, identical across face pairs); degenerate/zero-length run guards added
- CB2 (WP-D): coincident-rim filtering (coaxial caps 98->1 fragment), pinch splitting (oblique quarter patches 2->3 fragments), junction merge, insert_point_on_loop tolerance and split_fragment_by_open index fixes (root cause of box zero-length cut edges)
- CB3: analytic coincident-face explanation for ON fragments (coincident_overlap, total_on_explained; ok semantics extension documented in report 495 section 7)
- CB4 (WP-E): degenerate/duplicate edge cleanup with non-manifold guard and zero-rebuild fast path, canonical near-duplicate event merging, edge reversed flag fix, assemble/validate dangling parity; pinned tests promoted to hard pass assertions (oblique pinned as topologically green but volume/membership failing)
- results: box_cyl union/diff valid/wt 1.0/dangling 0 with V=1125.663706/874.336294; coaxial union single shell valid/wt 1.0/dangling 0 V=188.495559 (analytic); oblique union topologically green (dangling 0, wt 1.0) but analytic volume 210.30 vs true 198.38 -- root cause traced to measure::exact_planar_measure Green path vs stored trim/pcurve inconsistency (planar cap area 13.73 > full circle 12.57); per-face stored-trim integral 198.39 matches Monte-Carlo truth, measure-side fix is the next work package
- tests: CBRA ctest (slow integration enabled) 61/61 pass; registered 8918
- version 1.0.434; reports 494/495/496
2026-11-15 10:28:28 +08:00

143 lines
5.7 KiB
C++

/**
* @file test_version.cpp
* @brief ViewDesignEngine 版本信息单元测试
*/
#include <gtest/gtest.h>
#include "vde/core/version.h"
#include <string>
using namespace vde::core;
// ═══════════════════════════════════════════════════════════════
// 编译时版本宏测试
// ═══════════════════════════════════════════════════════════════
TEST(VersionMacro, MajorVersion) {
EXPECT_EQ(VDE_VERSION_MAJOR, 1);
}
TEST(VersionMacro, MinorVersion) {
EXPECT_EQ(VDE_VERSION_MINOR, 0);
}
TEST(VersionMacro, PatchVersion) {
EXPECT_EQ(VDE_VERSION_PATCH, 434);
}
TEST(VersionMacro, VersionString) {
EXPECT_STREQ(VDE_VERSION_STRING, "1.0.434");
}
TEST(VersionMacro, VersionNum) {
EXPECT_EQ(VDE_VERSION_NUM, 10434); // 1*10000 + 0*100 + 434
}
// 版本口径一致性:字符串 / 整型校验值 / 分量必须互相对齐(防止再次出现
// 1.0.1 vs CHANGELOG 1.0.20 的漂移)。
TEST(VersionMacro, ComponentsAgreeWithStringAndNum) {
EXPECT_EQ(VDE_VERSION_NUM,
VDE_VERSION_CODE(VDE_VERSION_MAJOR, VDE_VERSION_MINOR,
VDE_VERSION_PATCH));
std::string expected = std::to_string(VDE_VERSION_MAJOR) + "." +
std::to_string(VDE_VERSION_MINOR) + "." +
std::to_string(VDE_VERSION_PATCH);
EXPECT_EQ(expected, VDE_VERSION_STRING);
}
TEST(VersionMacro, VersionCodeFunction) {
EXPECT_EQ(VDE_VERSION_CODE(2, 3, 4), 20304);
EXPECT_EQ(VDE_VERSION_CODE(0, 0, 1), 1);
EXPECT_EQ(VDE_VERSION_CODE(10, 20, 30), 102030);
}
// ═══════════════════════════════════════════════════════════════
// 构建信息测试
// ═══════════════════════════════════════════════════════════════
TEST(BuildInfo, BuildTypeDefined) {
EXPECT_TRUE(std::string(VDE_BUILD_TYPE).size() > 0);
}
TEST(BuildInfo, CompilerInfoDefined) {
EXPECT_TRUE(std::string(VDE_COMPILER_INFO).size() > 0);
}
TEST(BuildInfo, CppStandardString) {
std::string cpp = VDE_CPP_STANDARD_STRING;
EXPECT_TRUE(cpp == "C++20" || cpp == "C++17" || cpp == "C++14" ||
cpp == "C++11" || cpp == "C++03");
// 项目要求 C++20
EXPECT_EQ(cpp, "C++20");
}
// ═══════════════════════════════════════════════════════════════
// VersionInfo 结构体测试
// ═══════════════════════════════════════════════════════════════
TEST(VersionInfo, DefaultConstruction) {
VersionInfo info = vde_version();
EXPECT_EQ(info.major, 1);
EXPECT_EQ(info.minor, 0);
EXPECT_EQ(info.patch, 434);
EXPECT_EQ(info.version_string, "1.0.434");
EXPECT_FALSE(info.build_type.empty());
EXPECT_FALSE(info.compiler_info.empty());
EXPECT_EQ(info.cpp_standard, "C++20");
}
TEST(VersionInfo, BuildTimestamp) {
VersionInfo info = vde_version();
// 时间戳可能为 unknown 或 ISO 8601 格式
EXPECT_FALSE(info.build_timestamp.empty());
}
// ═══════════════════════════════════════════════════════════════
// vde_version_string 测试
// ═══════════════════════════════════════════════════════════════
TEST(VersionString, Format) {
std::string vs = vde_version_string();
// 格式:ViewDesignEngine v1.0.434 (C++20, GCC x.x)
EXPECT_TRUE(vs.find("ViewDesignEngine v1.0.434") != std::string::npos);
EXPECT_TRUE(vs.find("C++20") != std::string::npos);
EXPECT_TRUE(vs.find("(") != std::string::npos);
EXPECT_TRUE(vs.find(")") != std::string::npos);
}
TEST(VersionString, NonEmpty) {
EXPECT_FALSE(vde_version_string().empty());
EXPECT_GT(vde_version_string().size(), 20u);
}
// ═══════════════════════════════════════════════════════════════
// vde_version_compare 测试
// ═══════════════════════════════════════════════════════════════
TEST(VersionCompare, Equality) {
EXPECT_EQ(vde_version_compare(1, 0, 1, 1, 0, 1), 0);
EXPECT_EQ(vde_version_compare(2, 0, 0, 2, 0, 0), 0);
}
TEST(VersionCompare, Less) {
EXPECT_LT(vde_version_compare(1, 0, 0, 1, 0, 1), 0);
EXPECT_LT(vde_version_compare(1, 0, 0, 2, 0, 0), 0);
EXPECT_LT(vde_version_compare(1, 9, 9, 2, 0, 0), 0);
}
TEST(VersionCompare, Greater) {
EXPECT_GT(vde_version_compare(2, 0, 0, 1, 0, 0), 0);
EXPECT_GT(vde_version_compare(1, 0, 2, 1, 0, 1), 0);
EXPECT_GT(vde_version_compare(1, 1, 0, 1, 0, 99), 0);
}
TEST(VersionCompare, Transitivity) {
// 1.0.0 < 1.0.1 < 1.1.0 < 2.0.0
int cmp1 = vde_version_compare(1, 0, 0, 1, 0, 1);
int cmp2 = vde_version_compare(1, 0, 1, 1, 1, 0);
int cmp3 = vde_version_compare(1, 1, 0, 2, 0, 0);
EXPECT_LT(cmp1, 0);
EXPECT_LT(cmp2, 0);
EXPECT_LT(cmp3, 0);
}