-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request EOSIO#402 from EOSIO/fix_signed_int
fix issue EOSIO#400 extract signed_int from datastream
- Loading branch information
Showing
4 changed files
with
34 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <eosiolib/eosio.hpp> | ||
#include <eosio/native/tester.hpp> | ||
|
||
using namespace eosio::native; | ||
using namespace eosio; | ||
|
||
EOSIO_TEST_BEGIN(signed_int_test) //test datastream insert/extract signed_int | ||
//silence_output(true); | ||
|
||
char buffer[32]; | ||
datastream ds(buffer,32); | ||
signed_int a(44), b((1<<30)+2), c(-35), d(-(1<<30)-2); //small +, small -, large +, large - | ||
ds << a << b << c << d; | ||
ds.seekp(0); | ||
signed_int aa, bb, cc, dd; | ||
ds >> aa >> bb >> cc >> dd; | ||
char* errmess= "signed_int datastream extract fails"; | ||
check(a.value==aa.value,errmess); | ||
check(b.value==bb.value,errmess); | ||
check(c.value==cc.value,errmess); | ||
check(d.value==dd.value,errmess); | ||
silence_output(false); | ||
EOSIO_TEST_END | ||
|
||
int main(int argc, char** argv) { | ||
EOSIO_TEST(signed_int_test); | ||
return has_failed(); | ||
} |