forked from EOSIO/eos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_real.cpp
51 lines (40 loc) · 1.27 KB
/
test_real.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <eoslib/real.hpp>
#include <eoslib/eos.hpp>
#include "test_api.hpp"
using namespace eosio;
unsigned int test_real::create_instances() {
real lhs1(5);
WASM_ASSERT(lhs1.value() == 5, "real instance value is wrong");
return WASM_TEST_PASS;
}
unsigned int test_real::test_division() {
real lhs1(5);
real rhs1(10);
real result1 = lhs1 / rhs1;
uint64_t a = double_div(i64_to_double(5), i64_to_double(10));
WASM_ASSERT(a == result1.value(), "real division result is wrong");
return WASM_TEST_PASS;
}
unsigned int test_real::test_multiplication() {
real lhs1(5);
real rhs1(10);
real result1 = lhs1 * rhs1;
uint64_t res = double_mult( 5, 10 );
WASM_ASSERT(res == result1.value(), "real multiplication result is wrong");
return WASM_TEST_PASS;
}
unsigned int test_real::test_addition()
{
real lhs1(5);
real rhs1(10);
real result1 = lhs1 / rhs1;
uint64_t a = double_div(i64_to_double(5), i64_to_double(10));
real lhs2(5);
real rhs2(2);
real result2 = lhs2 / rhs2;
uint64_t b = double_div(i64_to_double(5), i64_to_double(2));
real sum = result1+result2;
uint64_t c = double_add( a, b );
WASM_ASSERT(sum.value() == c, "real addition operation result is wrong");
return WASM_TEST_PASS;
}