Files
茂之钳 4eb4f00c57
Build & Test / build-and-test (push) Has been cancelled
VDE Build & Test / build-and-test (push) Has been cancelled
Build & Test / python-bindings (push) Has been cancelled
test: max coverage — 10 new + 11 expanded test files, 140+ cases
New tests: plane/line/topology_compression/serializer/memory_pool/
  interval/format_utils/sat/ray_intersect/tri_intersect
Expanded: quality_feedback/gdt/validate/interference/motion/
  explode/convex_hull/distance/polygon/transaction/sdf

Total test files: 162 → 172 (+10)
2026-08-02 16:32:36 +08:00

64 lines
1.6 KiB
C++

#include <gtest/gtest.h>
#include "vde/foundation/format_utils.h"
#include "vde/core/point.h"
using namespace vde::foundation;
using namespace vde::core;
TEST(FormatUtilsTest, FmtDouble_NormalValue) {
auto s = fmt_double(3.14159265358979);
EXPECT_FALSE(s.empty());
EXPECT_NE(s.find('e'), std::string::npos);
}
TEST(FormatUtilsTest, FmtDouble_NaN) {
auto s = fmt_double(std::nan(""));
EXPECT_EQ(s, "0.0");
}
TEST(FormatUtilsTest, FmtDouble_Infinity) {
auto s_pos = fmt_double(std::numeric_limits<double>::infinity());
EXPECT_FALSE(s_pos.empty());
auto s_neg = fmt_double(-std::numeric_limits<double>::infinity());
EXPECT_FALSE(s_neg.empty());
}
TEST(FormatUtilsTest, FmtIgesReal) {
auto s = fmt_iges_real(3.14159265358979);
EXPECT_NE(s.find('D'), std::string::npos);
EXPECT_FALSE(s.empty());
}
TEST(FormatUtilsTest, FmtPoint) {
Point3D p(1.0, 2.5, -3.14);
auto s = fmt_point(p);
EXPECT_FALSE(s.empty());
EXPECT_NE(s.find(','), std::string::npos);
}
TEST(FormatUtilsTest, FmtPoint_UseD) {
Point3D p(0, 0, 0);
auto s = fmt_point(p, true);
EXPECT_NE(s.find('D'), std::string::npos);
}
TEST(FormatUtilsTest, Pad72) {
auto s = pad72("hello");
EXPECT_EQ(s.size(), 72u);
EXPECT_EQ(s[0], 'h');
EXPECT_EQ(s[71], ' ');
}
TEST(FormatUtilsTest, Pad72_Truncate) {
std::string long_str(100, 'x');
auto s = pad72(long_str);
EXPECT_EQ(s.size(), 72u);
}
TEST(FormatUtilsTest, FormatIgesLine) {
auto line = format_iges_line("110,1.0,2.0,3.0;", 'P', 1);
EXPECT_NE(line.find("P0000001"), std::string::npos);
EXPECT_EQ(line.back(), '\n');
}