Files

35 lines
1.5 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// P4 module-packages CI:vde-pdm 消费者 smoke(材料/型材/BOM)
#include "vde_pdm/bom_table.h"
#include "vde_pdm/material_library.h"
#include "vde_pdm/structural_profile_catalog.h"
#include <chrono>
#include <cstdio>
#include "vde/fs_compat.h"
#include <string>
int main() {
vde::pdm::init_native_material_db();
const size_t materials = vde::pdm::MaterialDatabase::instance().count();
vde::pdm::MaterialSearchQuery query;
query.category = "metal";
const auto metals = vde::pdm::material_search(query);
const auto profiles = vde::pdm::profile_library::all_profiles();
vde::pdm::BomTable bom;
bom.title = "module-packages-ci";
vde::pdm::BomItem item;
item.part_number = "P-001";
item.quantity = 2;
bom.items.push_back(item);
const auto csv_path = vde::fs::temp_directory_path() /
("vde_pdm_bom_" +
std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()) +
".csv");
const bool csv_ok = vde::pdm::bom_export_csv(bom, csv_path.string());
std::error_code remove_ec;
vde::fs::remove(csv_path, remove_ec);
const bool ok = materials > 0 && !metals.empty() && !profiles.empty() && csv_ok &&
bom.total_quantity() == 2;
std::printf("PDM_CONSUMER_%s materials=%zu metals=%zu profiles=%zu\n",
ok ? "PASS" : "FAIL", materials, metals.size(), profiles.size());
return ok ? 0 : 1;
}