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)
64 lines
1.6 KiB
C++
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');
|
|
}
|