|
|
|
#include <gp/allocator/arena.hpp>
|
|
#include <gp/array.hpp>
|
|
#include <gp/enveloppe/cbor.hpp>
|
|
#include "test_scaffold.h"
|
|
|
|
struct cbor_test : public test_scaffold {
|
|
cbor_test() {
|
|
name = __FILE__ ":1";
|
|
}
|
|
|
|
virtual int run() {
|
|
gp::array<char, 4096> store;
|
|
gp::arena alloc{&*store.begin(), store.size()};
|
|
/*gp::cbor_value data{alloc};
|
|
auto gen = data.new_object();
|
|
gen.push_back(gp::make_pair(gp::cbor_value{uint8_t(12), alloc}, gp::cbor_value{int32_t(-98), alloc}));
|
|
gen.push_back(gp::make_pair(gp::cbor_value{uint8_t(13), alloc}, gp::cbor_value{uint32_t(98), alloc}));
|
|
data = gen;*/
|
|
|
|
using some_int = gp::fixed_variant<int, unsigned int, long long>;
|
|
{
|
|
some_int a{16};
|
|
some_int b = 12u;
|
|
b = a;
|
|
gp_config::assertion(b.is_a<int>(), "b got wrong type assigned");
|
|
}
|
|
{
|
|
some_int a{16u};
|
|
some_int b = a;
|
|
gp_config::assertion(b.is_a<unsigned int>(), "b got wrong type assigned");
|
|
gp_config::assertion(b.value<unsigned int>() == 16, "b got wrong value assigned");
|
|
}
|
|
{
|
|
some_int a{16u};
|
|
some_int b = gp::move(a);
|
|
gp_config::assertion(b.is_a<unsigned int>(), "b got wrong type assigned");
|
|
gp_config::assertion(b.value<unsigned int>() == 16, "b got wrong value assigned");
|
|
}
|
|
{
|
|
some_int a{16u};
|
|
some_int b;
|
|
new(&b) some_int(a);
|
|
gp_config::assertion(b.is_a<unsigned int>(), "b got wrong type assigned");
|
|
gp_config::assertion(b.value<unsigned int>() == 16, "b got wrong value assigned");
|
|
}
|
|
{
|
|
some_int a{16u};
|
|
some_int b;
|
|
new(&b) some_int(gp::move(a));
|
|
gp_config::assertion(b.is_a<unsigned int>(), "b got wrong type assigned");
|
|
gp_config::assertion(b.value<unsigned int>() == 16, "b got wrong value assigned");
|
|
}
|
|
{
|
|
gp::vector<some_int> vec{alloc};
|
|
vec.emplace_back(12u);
|
|
vec.emplace_back(-16);
|
|
gp_config::assertion(vec[0].is_a<unsigned int>(), "vec0 got wrong type assigned");
|
|
gp_config::assertion(vec[1].is_a<int>(), "vec1 got wrong type assigned");
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
};
|
|
|
|
append_test dummy_pg5zhr8bv(new cbor_test{});
|