|
|
@ -8,6 +8,7 @@ |
|
|
|
#include "gp/allocator/dummy.hpp"
|
|
|
|
#include "gp/algorithm/repeat.hpp"
|
|
|
|
#include "gp/algorithm/rotate.hpp"
|
|
|
|
#include "gp/algorithm/move.hpp"
|
|
|
|
#include "gp/ring_list.hpp"
|
|
|
|
#include <thread>
|
|
|
|
#include <chrono>
|
|
|
@ -553,11 +554,108 @@ struct indexed_array_test : public test_scaffold { |
|
|
|
|
|
|
|
{ |
|
|
|
// TODO: write a concrete implementation and test it
|
|
|
|
// gp::vfs fs;
|
|
|
|
} |
|
|
|
} |
|
|
|
return res; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
append_test dummy_khxurgsd3(new indexed_array_test{}); |
|
|
|
append_test dummy_khxurgsd3(new indexed_array_test{}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct move_uninitialized_test : public test_scaffold { |
|
|
|
move_uninitialized_test() { |
|
|
|
name = __FILE__ ":8"; |
|
|
|
} |
|
|
|
|
|
|
|
struct tester { |
|
|
|
size_t* const incremented; |
|
|
|
|
|
|
|
tester(size_t* ptr) |
|
|
|
: incremented(ptr) |
|
|
|
{} |
|
|
|
|
|
|
|
tester(tester&& oth) |
|
|
|
: incremented(oth.incremented) |
|
|
|
{ |
|
|
|
++*incremented; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
virtual int run() { |
|
|
|
int res = 0; |
|
|
|
{ |
|
|
|
size_t counter; |
|
|
|
using src_t = gp::array<tester, 16>; |
|
|
|
src_t *source = reinterpret_cast<src_t*>(malloc(sizeof(src_t))); |
|
|
|
gp::array<char, sizeof(tester)*16> buffer; |
|
|
|
for(auto& a : *source) { |
|
|
|
new(&a) tester(&counter); |
|
|
|
} |
|
|
|
gp::move_uninitialized(*source, buffer.as_buffer().cast<tester>()); |
|
|
|
free(source); |
|
|
|
} |
|
|
|
return res; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
append_test dummy_hkfyr5f5(new move_uninitialized_test{}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct clamp_test : public test_scaffold { |
|
|
|
clamp_test() { |
|
|
|
name = __FILE__ ":9"; |
|
|
|
} |
|
|
|
|
|
|
|
virtual int run() { |
|
|
|
int res = 0; |
|
|
|
{ |
|
|
|
res += gp::clamp<float>(0.0, -1.0, 1.0); |
|
|
|
res += gp::clamp<float>(-1.0, 1.0, 0.0); |
|
|
|
res += gp::max(-1, -2, 0, -3); |
|
|
|
} |
|
|
|
return res; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
append_test dummy_gsdh25f5(new clamp_test{}); |
|
|
|
|
|
|
|
struct buffer_test : public test_scaffold { |
|
|
|
buffer_test() { |
|
|
|
name = __FILE__ ":10"; |
|
|
|
} |
|
|
|
|
|
|
|
virtual int run() { |
|
|
|
int res = 0; |
|
|
|
{ |
|
|
|
gp::array<char, 24> data; |
|
|
|
gp::array<char, 24> data_e; |
|
|
|
gp::buffer<char> handle = data.as_buffer(); |
|
|
|
handle[12] = '&'; |
|
|
|
gp_config::assertion(*(handle.begin()+12) == '&', "Could not assign to the buffer"); |
|
|
|
res += 1; |
|
|
|
try { |
|
|
|
handle[24] = 16; |
|
|
|
res += 1; |
|
|
|
handle[-1] = 16; |
|
|
|
res += 1; |
|
|
|
handle[1024] = 16; |
|
|
|
} catch (...) { |
|
|
|
res -= 1; |
|
|
|
} |
|
|
|
res += 1; |
|
|
|
try { |
|
|
|
auto cast = handle.cast<gp::array<char, 32>>(); |
|
|
|
} catch (...) { |
|
|
|
res -= 1; |
|
|
|
} |
|
|
|
auto cast = handle.template cast<gp::array<char, 6>>().template cast<gp::array<char, 4>>(); |
|
|
|
gp_config::assertion(false == (data == data_e), "Different arrays should return false here"); |
|
|
|
} |
|
|
|
return res; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
append_test dummy_gs87ytf5f5(new buffer_test{}); |