Add test for CMOD binary to ASCII to binary roundtrip
parent
4132f41889
commit
7c38b34683
|
@ -47,6 +47,8 @@ jobs:
|
|||
|
||||
- name: 'Checkout source code'
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: 'Configure CMake'
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=${{matrix.platform}}-windows -DCMAKE_GENERATOR_PLATFORM=${{matrix.generator_platform}} -DENABLE_SPICE=ON -DENABLE_TOOLS=ON -DENABLE_TESTS=ON -DENABLE_SDL=OFF -DENABLE_QT=ON -DENABLE_DATA=OFF
|
||||
|
@ -56,7 +58,9 @@ jobs:
|
|||
|
||||
- name: 'Copy DLL for tests'
|
||||
working-directory: ${{github.workspace}}/build
|
||||
run: copy src\celestia\${{env.BUILD_TYPE}}\*.dll test\unit\${{env.BUILD_TYPE}}\
|
||||
run: |
|
||||
copy src\celestia\${{env.BUILD_TYPE}}\*.dll test\unit\${{env.BUILD_TYPE}}\
|
||||
copy src\celestia\${{env.BUILD_TYPE}}\*.dll test\integration\${{env.BUILD_TYPE}}\
|
||||
|
||||
- name: Test
|
||||
working-directory: ${{github.workspace}}/build
|
||||
|
|
|
@ -1,2 +1,6 @@
|
|||
add_subdirectory(common)
|
||||
|
||||
include(TestCase)
|
||||
|
||||
add_subdirectory(integration)
|
||||
add_subdirectory(unit)
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,4 @@
|
|||
test_case(cmod_bin_ascii_roundtrip)
|
||||
|
||||
file(COPY "${CMAKE_SOURCE_DIR}/test/data/iss/models/iss.cmod"
|
||||
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
|
|
@ -0,0 +1,36 @@
|
|||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <ios>
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
|
||||
#include <celmodel/modelfile.h>
|
||||
|
||||
#include <catch.hpp>
|
||||
|
||||
TEST_CASE("CMOD binary to ASCII roundtrip", "[cmod] [integration]")
|
||||
{
|
||||
std::ifstream f("iss.cmod", std::ios::in | std::ios::binary);
|
||||
REQUIRE(f.good());
|
||||
std::stringstream sourceData;
|
||||
sourceData << f.rdbuf();
|
||||
|
||||
cmod::Model* modelFromBinary = cmod::LoadModel(sourceData, nullptr);
|
||||
REQUIRE(modelFromBinary != nullptr);
|
||||
|
||||
std::stringstream asciiData;
|
||||
REQUIRE(cmod::SaveModelAscii(modelFromBinary, asciiData));
|
||||
|
||||
cmod::Model* modelFromAscii = cmod::LoadModel(asciiData);
|
||||
REQUIRE(modelFromAscii != nullptr);
|
||||
|
||||
std::stringstream roundtrippedData;
|
||||
REQUIRE(cmod::SaveModelBinary(modelFromAscii, roundtrippedData));
|
||||
|
||||
sourceData.clear();
|
||||
REQUIRE(sourceData.seekg(0, std::ios_base::beg).good());
|
||||
|
||||
std::istreambuf_iterator<char> end;
|
||||
REQUIRE(std::equal(std::istreambuf_iterator<char>(sourceData), end,
|
||||
std::istreambuf_iterator<char>(roundtrippedData), end));
|
||||
}
|
|
@ -1,5 +1,3 @@
|
|||
include(TestCase)
|
||||
|
||||
test_case(hash)
|
||||
if ((NOT HAVE_EXPERIMENTAL_FILESYSTEM) AND (NOT HAVE_FILESYSTEM))
|
||||
test_case(fs)
|
||||
|
|
Loading…
Reference in New Issue