mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-13 21:45:54 +08:00
Add test_amf.cpp from Slic3r
This commit is contained in:
parent
ebfaadd0f3
commit
dad3b1edb9
21
tests/data/README.md
Normal file
21
tests/data/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
Directory containing test-specific input files that are not source code.
|
||||
|
||||
---
|
||||
|
||||
Rules
|
||||
===
|
||||
* Each folder shall be named for the test that it supports.
|
||||
* `test_config` directory supports `test_config.cpp`, etc.
|
||||
* If a specific test file is reused across multiple tests, it should go in the `common` directory.
|
||||
* Each extra input file should be named in such a way that it is relevant to the specific feature of it.
|
||||
* No files should have special characters in the name (unless those special characters are part of the test).
|
||||
* No spaces should be in the file paths (again, unless testing the presence of spaces is part of the test).
|
||||
* Input files that are 3D models should be as small/specific as possible.
|
||||
* Do not add copyrighted models without permission from the copyright holder.
|
||||
* Do not add NonCommercial models, these would need to be relicensed from the original holder.
|
||||
* Add any necessary licensing or attributation information as `<filename>.license`
|
||||
* Example: A CC-By-SA 3D model called `cool_statue_bro.stl` should have its attributation/license information included in a file called `cool_statue_bro.license`
|
||||
* Any submitted files without an accompanying `.license` file are assumed to be licensed under [CC-By-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/us/).
|
||||
* The author of a commit adding any extra input files asserts that, via the process of committing those files, that they
|
||||
* have abided by the terms of all licensing agreements involved with the files added or
|
||||
* are the author of the files in question and submit them to the Slic3r project under the terms of [CC-By-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/us/).
|
20
tests/data/test_amf/5061-malicious.amf
Normal file
20
tests/data/test_amf/5061-malicious.amf
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<amf unit="inch" version="1.1">
|
||||
<metadata type="name">Split Pyramid</metadata>
|
||||
<metadata tyze="author">John Smith</metadata>
|
||||
<object id="1">
|
||||
<mesh>
|
||||
<vertices>
|
||||
<vertex><coordinates><x>2</x><y>0</y><z>0</z></coordinates></vertex>
|
||||
<vertex><coordinates><x>2.5</x><y>0.5</y><z>0</z></coordinates></vertex>
|
||||
</vertices>
|
||||
<volume materialid="2">
|
||||
<metadata type="name">Hard side</metadata>
|
||||
<triangle><v1>9999992</v1><v2>1</v2><v3>2</v3></triangle>
|
||||
<triangle><v1>0</v1><v2>0</v2><v3>2</v3></triangle>
|
||||
</volume>
|
||||
</mesh>
|
||||
</object>
|
||||
<material id="1">
|
||||
</material>
|
||||
</amf>
|
19
tests/data/test_amf/read-amf.amf
Normal file
19
tests/data/test_amf/read-amf.amf
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<amf unit="inch" version="1.1">
|
||||
<metadata type="name">Split Pyramid</metadata>
|
||||
<metadata tyze="author">John Smith</metadata>
|
||||
<object id="1">
|
||||
<mesh>
|
||||
<vertices>
|
||||
<vertex><coordinates><x>2</x><y>0</y><z>0</z></coordinates></vertex>
|
||||
<vertex><coordinates><x>2.5</x><y>0.5</y><z>0</z></coordinates></vertex>
|
||||
<vertex><coordinates><x>3.5</x><y>2.5</y><z>0</z></coordinates></vertex>
|
||||
</vertices>
|
||||
<volume materialid="2">
|
||||
<metadata type="name">Hard side</metadata>
|
||||
<triangle><v1>2</v1><v2>1</v2><v3>2</v3></triangle>
|
||||
<triangle><v1>0</v1><v2>0</v2><v3>2</v3></triangle>
|
||||
</volume>
|
||||
</mesh>
|
||||
</object>
|
||||
</amf>
|
@ -2,6 +2,7 @@ get_filename_component(_TEST_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
|
||||
|
||||
add_executable(${_TEST_NAME}_tests
|
||||
${_TEST_NAME}_tests.cpp
|
||||
test_amf.cpp
|
||||
test_3mf.cpp
|
||||
test_aabbindirect.cpp
|
||||
test_clipper_offset.cpp
|
||||
@ -22,6 +23,7 @@ add_executable(${_TEST_NAME}_tests
|
||||
test_timeutils.cpp
|
||||
)
|
||||
|
||||
|
||||
if (TARGET OpenVDB::openvdb)
|
||||
target_sources(${_TEST_NAME}_tests PRIVATE test_hollowing.cpp)
|
||||
endif()
|
||||
|
32
tests/libslic3r/test_amf.cpp
Normal file
32
tests/libslic3r/test_amf.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include "test_utils.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/Format/AMF.hpp"
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
|
||||
using namespace Slic3r;
|
||||
using namespace std::literals::string_literals;
|
||||
|
||||
|
||||
SCENARIO("Reading AMF file") {
|
||||
auto z = DynamicPrintConfig{};
|
||||
GIVEN("badly formed AMF file (missing vertices)") {
|
||||
auto model {new Slic3r::Model()};
|
||||
WHEN("AMF model is read") {
|
||||
auto ret = Slic3r::load_amf(get_model_path("test_amf/5061-malicious.amf").c_str(), &z, model, false);
|
||||
THEN("read should return True") {
|
||||
REQUIRE(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
GIVEN("Ok formed AMF file") {
|
||||
auto model {new Slic3r::Model()};
|
||||
WHEN("AMF model is read") {
|
||||
std::cerr << "TEST_DATA_DIR/test_amf/read-amf.amf";
|
||||
auto ret = Slic3r::load_amf(get_model_path("test_amf/read-amf.amf").c_str(), &z, model, false);
|
||||
THEN("read should return True") {
|
||||
REQUIRE(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user