/** * @file test_layer_standards.cpp * @brief VDE-366:专业过滤 + DWT 模板导出 */ #include #include "vde_drafting/layer_standards.h" #include #include #include #include using namespace vde::drafting::layer; // ── filter_by_discipline ── TEST(LayerStandardsTest, FilterByDiscipline_ISO_Architecture) { const auto arch = filter_by_discipline(LayerStandardId::ISO_13567, "A-"); EXPECT_FALSE(arch.empty()); bool has_wall = false; for (const auto& l : arch) { EXPECT_EQ(l.name.rfind("A-", 0), 0u) << l.name; // 全部以 A- 开头 if (l.name == "A-WALL-M") has_wall = true; } EXPECT_TRUE(has_wall); // 结构层不应出现 for (const auto& l : arch) EXPECT_NE(l.name.rfind("S-", 0), 0u); } TEST(LayerStandardsTest, FilterByDiscipline_GB_Structural) { const auto st = filter_by_discipline(LayerStandardId::GB_T_18229, "结"); EXPECT_FALSE(st.empty()); for (const auto& l : st) EXPECT_EQ(l.name.rfind("结", 0), 0u) << l.name; } TEST(LayerStandardsTest, FilterByDiscipline_EmptyPrefixReturnsAll) { const auto all = filter_by_discipline(LayerStandardId::AIA_NCS, ""); EXPECT_EQ(all.size(), load_standard(LayerStandardId::AIA_NCS).layers.size()); } // ── export_dwt ── TEST(LayerStandardsTest, ExportDwt_WritesLayerTable) { const std::string path = std::string(VDE_TEST_TEMP_DIR) + "/vde366_layers.dwt"; ASSERT_TRUE(export_dwt(LayerStandardId::ISO_13567, path)); std::ifstream in(path); ASSERT_TRUE(in.good()); std::stringstream ss; ss << in.rdbuf(); const std::string content = ss.str(); EXPECT_NE(content.find("LAYER"), std::string::npos); EXPECT_NE(content.find("A-WALL-M"), std::string::npos); EXPECT_NE(content.find("S-COLS-M"), std::string::npos); EXPECT_NE(content.find("EOF"), std::string::npos); std::remove(path.c_str()); } TEST(LayerStandardsTest, ExportDwt_InvalidPathFails) { // 不存在的目录 → 打开失败 EXPECT_FALSE(export_dwt(LayerStandardId::AIA_NCS, "no_such_dir_xyz/sub/vde366.dwt")); }