mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Moved a commented out test for DynamicPrintConfig serialization
/ deserialization into a living unit test.
This commit is contained in:
		
							parent
							
								
									60d8a7b301
								
							
						
					
					
						commit
						6c37955d75
					
				
					 2 changed files with 35 additions and 40 deletions
				
			
		| 
						 | 
				
			
			@ -3,6 +3,11 @@
 | 
			
		|||
#include "libslic3r/PrintConfig.hpp"
 | 
			
		||||
#include "libslic3r/LocalesUtils.hpp"
 | 
			
		||||
 | 
			
		||||
#include <cereal/types/polymorphic.hpp>
 | 
			
		||||
#include <cereal/types/string.hpp> 
 | 
			
		||||
#include <cereal/types/vector.hpp> 
 | 
			
		||||
#include <cereal/archives/binary.hpp>
 | 
			
		||||
 | 
			
		||||
using namespace Slic3r;
 | 
			
		||||
 | 
			
		||||
SCENARIO("Generic config validation performs as expected.", "[Config]") {
 | 
			
		||||
| 
						 | 
				
			
			@ -202,3 +207,33 @@ SCENARIO("Config ini load/save interface", "[Config]") {
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SCENARIO("DynamicPrintConfig serialization", "[Config]") {
 | 
			
		||||
    WHEN("DynamicPrintConfig is serialized and deserialized") {
 | 
			
		||||
        FullPrintConfig full_print_config;
 | 
			
		||||
        DynamicPrintConfig cfg;
 | 
			
		||||
        cfg.apply(full_print_config, false);
 | 
			
		||||
 | 
			
		||||
        std::string serialized;
 | 
			
		||||
        try {
 | 
			
		||||
            std::ostringstream ss;
 | 
			
		||||
            cereal::BinaryOutputArchive oarchive(ss);
 | 
			
		||||
            oarchive(cfg);
 | 
			
		||||
            serialized = ss.str();
 | 
			
		||||
        } catch (std::runtime_error e) {
 | 
			
		||||
            e.what();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        THEN("Config object contains ini file options.") {
 | 
			
		||||
            DynamicPrintConfig cfg2;
 | 
			
		||||
            try {
 | 
			
		||||
                std::stringstream ss(serialized);
 | 
			
		||||
                cereal::BinaryInputArchive iarchive(ss);
 | 
			
		||||
                iarchive(cfg2);
 | 
			
		||||
            } catch (std::runtime_error e) {
 | 
			
		||||
                e.what();
 | 
			
		||||
            }
 | 
			
		||||
            REQUIRE(cfg == cfg2);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue