- Add 12 new test files: render/viewport_layout, render/section_view, boolean/polygon_offset, core/icp, core/voronoi, core/material_library, spatial/incremental_bvh, spatial/kd_tree, curves/bezier_surface, capi/capi_extended, and expand mesh/halfedge + mesh/delaunay - Fix 30+ compilation errors: missing includes, undefined symbols, circular dependencies, namespace issues, API mismatches - Implement missing functions: point_to_plane_icp, colored_icp, scale_aware_registration, polygon_offset_arc, multi_contour_offset, offset_quality_check, validate_style, available_standards, add_vertex_unique, angle_distribution - Fix infinite recursion in MaterialDatabase constructor - Fix polygon_offset normal direction (inward -> outward) - Fix viewport_bounds out-of-bounds handling - Add linker group flags for static library circular dependencies - 87% test pass rate (4479 tests, 592 pre-existing failures)
101 lines
2.6 KiB
C++
101 lines
2.6 KiB
C++
#include <gtest/gtest.h>
|
|
|
|
extern "C" {
|
|
#include "vde/capi/vde_capi.h"
|
|
}
|
|
|
|
#include <cstring>
|
|
|
|
// ═══════════════════════════════════════════════════════════
|
|
// C API 扩展测试 — 句柄生命周期与 null 安全
|
|
// ═══════════════════════════════════════════════════════════
|
|
|
|
TEST(CApiExtendedTest, CreateDestroyContext) {
|
|
VdeHandle ctx = vde_create();
|
|
ASSERT_NE(ctx, nullptr);
|
|
vde_destroy(ctx);
|
|
// vde_destroy 后不应 crash
|
|
}
|
|
|
|
TEST(CApiExtendedTest, VersionString) {
|
|
const char* ver = vde_version();
|
|
ASSERT_NE(ver, nullptr);
|
|
EXPECT_GT(strlen(ver), 0u);
|
|
}
|
|
|
|
TEST(CApiExtendedTest, LastErrorEmpty) {
|
|
VdeHandle ctx = vde_create();
|
|
const char* err = vde_last_error(ctx);
|
|
// 刚创建时应为 null 或空字符串
|
|
if (err != nullptr) {
|
|
EXPECT_EQ(strlen(err), 0u);
|
|
}
|
|
vde_destroy(ctx);
|
|
}
|
|
|
|
TEST(CApiExtendedTest, CreateBodyBox) {
|
|
VdeHandle ctx = vde_create();
|
|
VdeBodyHandle body = vde_body_create_box(ctx, 1.0, 2.0, 3.0);
|
|
ASSERT_NE(body, nullptr);
|
|
vde_body_free(body);
|
|
vde_destroy(ctx);
|
|
}
|
|
|
|
TEST(CApiExtendedTest, CreateBodyCylinder) {
|
|
VdeHandle ctx = vde_create();
|
|
VdeBodyHandle body = vde_body_create_cylinder(ctx, 1.0, 3.0, 32);
|
|
ASSERT_NE(body, nullptr);
|
|
vde_body_free(body);
|
|
vde_destroy(ctx);
|
|
}
|
|
|
|
TEST(CApiExtendedTest, CreateBodySphere) {
|
|
VdeHandle ctx = vde_create();
|
|
VdeBodyHandle body = vde_body_create_sphere(ctx, 1.0, 32, 32);
|
|
ASSERT_NE(body, nullptr);
|
|
vde_body_free(body);
|
|
vde_destroy(ctx);
|
|
}
|
|
|
|
TEST(CApiExtendedTest, FreeBodyNullSafe) {
|
|
vde_body_free(nullptr);
|
|
SUCCEED();
|
|
}
|
|
|
|
TEST(CApiExtendedTest, FreeMeshNullSafe) {
|
|
vde_mesh_free(nullptr);
|
|
SUCCEED();
|
|
}
|
|
|
|
TEST(CApiExtendedTest, FreeCurveNullSafe) {
|
|
vde_curve_free(nullptr);
|
|
SUCCEED();
|
|
}
|
|
|
|
TEST(CApiExtendedTest, FreeSolverNullSafe) {
|
|
vde_solver_free(nullptr);
|
|
SUCCEED();
|
|
}
|
|
|
|
TEST(CApiExtendedTest, CreateSolver) {
|
|
VdeSolverHandle solver = vde_solver_create();
|
|
ASSERT_NE(solver, nullptr);
|
|
vde_solver_free(solver);
|
|
}
|
|
|
|
TEST(CApiExtendedTest, CreateCurveBezier) {
|
|
VdeHandle ctx = vde_create();
|
|
// 4 个控制点 → 3 次 Bézier 曲线
|
|
double cp[] = {
|
|
0.0, 0.0, 0.0,
|
|
1.0, 2.0, 0.0,
|
|
3.0, 2.0, 0.0,
|
|
4.0, 0.0, 0.0
|
|
};
|
|
VdeCurveHandle curve = vde_curve_create_bezier(ctx, cp, 4, 3);
|
|
ASSERT_NE(curve, nullptr);
|
|
EXPECT_EQ(vde_curve_degree(curve), 3);
|
|
vde_curve_free(curve);
|
|
vde_destroy(ctx);
|
|
}
|