30 #include "eng3d/state.hpp"
31 #include "eng3d/string.hpp"
32 #include "eng3d/event.hpp"
33 #include "eng3d/serializer.hpp"
36 GameState(
const std::vector<std::string>& pkg_paths)
45 static int test_numerical_vector(
size_t max_samples = 65536) {
46 std::vector<T> fuzz(max_samples);
47 std::iota(fuzz.begin(), fuzz.end(), 1);
48 const auto expected = fuzz;
60 std::cout <<
"Elements stored " << fuzz.size() <<
" expected " << expected.size() << std::endl;
61 for(
size_t i = 0; i < fuzz.size(); i++) {
62 if(fuzz[i] != expected[i]) {
63 std::cout <<
"Test failed, element " << i <<
" is different (" << fuzz[i] <<
" != " << expected[i] <<
")" << std::endl;
68 std::cout <<
"Test passed" << std::endl;
72 template<
typename T,
int max_samples = 32>
73 static int test_numerical_array() {
74 std::array<T, max_samples> fuzz;
75 std::iota(fuzz.begin(), fuzz.end(), 1);
76 const auto expected = fuzz;
88 std::cout <<
"Elements stored " << fuzz.size() <<
" expected " << expected.size() << std::endl;
89 for(
size_t i = 0; i < fuzz.size(); i++) {
90 if(fuzz[i] != expected[i]) {
91 std::cout <<
"Test failed, element " << i <<
" is different (" << fuzz[i] <<
" != " << expected[i] <<
")" << std::endl;
96 std::cout <<
"Test passed" << std::endl;
100 static int test_string(
size_t max_samples = 32) {
102 fuzz.resize(max_samples);
104 fuzz[max_samples] =
'\0';
106 fuzz[max_samples] =
'A' + (rand() % 26);
108 const auto expected = fuzz;
120 std::cout <<
"Elements stored " << fuzz.size() <<
" expected " << expected.size() << std::endl;
121 for(
size_t i = 0; i < fuzz.size(); i++) {
122 if(fuzz[i] != expected[i]) {
123 std::cout <<
"Test failed, element " << i <<
" is different (" << fuzz[i] <<
" != " << expected[i] <<
")" << std::endl;
128 std::cout <<
"Test passed" << std::endl;
133 std::cout <<
"std::vector" << std::endl;
134 test_numerical_vector<int>();
135 test_numerical_vector<unsigned int>();
136 test_numerical_vector<long long>();
137 test_numerical_vector<unsigned long long>();
139 std::cout <<
"std::array" << std::endl;
140 test_numerical_array<int>();
141 test_numerical_array<unsigned int>();
142 test_numerical_array<long long>();
143 test_numerical_array<unsigned long long>();
145 std::cout <<
"std::string" << std::endl;
State(const std::vector< std::string > &pkg_paths)
GameState(const std::vector< std::string > &pkg_paths)
void deserialize(Eng3D::Deser::Archive &ar, T &obj)
void serialize(Eng3D::Deser::Archive &ar, const T &obj)
Base class that serves as archiver, stores (in memory) the data required for serialization/deserializ...
void to_file(const ::std::string &path)
void from_file(const ::std::string &path)