Skip to content

Commit

Permalink
write_bytes() tests
Browse files Browse the repository at this point in the history
  • Loading branch information
madMAx43v3r committed Oct 29, 2024
1 parent d7e4cc6 commit 5596ba9
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/mmx_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <mmx/uint128.hpp>
#include <mmx/fixed128.hpp>
#include <mmx/tree_hash.h>
#include <mmx/write_bytes.h>
#include <mmx/utils.h>

#include <mmx/ChainParams.hxx>
Expand Down Expand Up @@ -233,6 +234,47 @@ int main(int argc, char** argv)
}
VNX_TEST_END()

VNX_TEST_BEGIN("write_bytes()")
{
{
const bool value = true;
std::vector<uint8_t> tmp;
vnx::VectorOutputStream stream(&tmp);
vnx::OutputBuffer out(&stream);
write_bytes(out, value);
out.flush();
vnx::test::expect(tmp.size(), 1u);
}
{
const vnx::Variant value(true);
std::vector<uint8_t> tmp;
vnx::VectorOutputStream stream(&tmp);
vnx::OutputBuffer out(&stream);
write_bytes(out, value);
out.flush();
vnx::test::expect(tmp.size(), 1u);
}
{
const vnx::Variant value(1337);
std::vector<uint8_t> tmp;
vnx::VectorOutputStream stream(&tmp);
vnx::OutputBuffer out(&stream);
write_bytes(out, value);
out.flush();
vnx::test::expect(tmp.size(), 8u);
}
{
const vnx::Variant value(-1337);
std::vector<uint8_t> tmp;
vnx::VectorOutputStream stream(&tmp);
vnx::OutputBuffer out(&stream);
write_bytes(out, value);
out.flush();
vnx::test::expect(tmp.size(), 8u);
}
}
VNX_TEST_END()

return vnx::test::done();
}

Expand Down

0 comments on commit 5596ba9

Please sign in to comment.