Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #6701 from EOSIO/fix_signed_int
Browse files Browse the repository at this point in the history
fix signed_int pack/unpack
  • Loading branch information
heifner committed Feb 6, 2019
2 parents 28e6c95 + 1e431cf commit ffb1662
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libraries/fc
Submodule fc updated 1 files
+3 −4 include/fc/io/raw.hpp
29 changes: 29 additions & 0 deletions unittests/misc_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ BOOST_AUTO_TEST_CASE(transaction_test) { try {
uint32_t pack_size = fc::raw::pack_size( pkt );
vector<char> buf(pack_size);
fc::datastream<char*> ds(buf.data(), pack_size);

fc::raw::pack( ds, pkt );
// unpack
ds.seekp(0);
Expand Down Expand Up @@ -664,6 +665,34 @@ BOOST_AUTO_TEST_CASE(transaction_test) { try {
} FC_LOG_AND_RETHROW() }


BOOST_AUTO_TEST_CASE(signed_int_test) { try {
char buf[32];
fc::datastream<char*> ds(buf,32);
signed_int a(47), b((1<<30)+2), c(-47), d(-(1<<30)-2); //small +, big +, small -, big -
signed_int ee;
fc::raw::pack(ds,a);
ds.seekp(0);
fc::raw::unpack(ds,ee);
ds.seekp(0);
BOOST_CHECK_EQUAL(a,ee);
fc::raw::pack(ds,b);
ds.seekp(0);
fc::raw::unpack(ds,ee);
ds.seekp(0);
BOOST_CHECK_EQUAL(b,ee);
fc::raw::pack(ds,c);
ds.seekp(0);
fc::raw::unpack(ds,ee);
ds.seekp(0);
BOOST_CHECK_EQUAL(c,ee);
fc::raw::pack(ds,d);
ds.seekp(0);
fc::raw::unpack(ds,ee);
ds.seekp(0);
BOOST_CHECK_EQUAL(d,ee);

} FC_LOG_AND_RETHROW() }

BOOST_AUTO_TEST_CASE(transaction_metadata_test) { try {

testing::TESTER test;
Expand Down

0 comments on commit ffb1662

Please sign in to comment.