GitLab will be upgraded to the 12.10.14-ce.0 on 28 Sept 2020 at 2.00pm (AEDT) to 2.30pm (AEDT). During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to us at N110 (b) CSIT building.

test_binops.py 990 Bytes
Newer Older
John Zhang's avatar
John Zhang committed
1
from util import fncptr_from_c_script
2

John Zhang's avatar
John Zhang committed
3
def test_add():
John Zhang's avatar
John Zhang committed
4
    fn, _ = fncptr_from_c_script("test_add.c", "test_fnc")
5 6 7
    assert fn() == 9

def test_sub():
John Zhang's avatar
John Zhang committed
8
    fn, _ = fncptr_from_c_script("test_sub.c", "test_fnc")
9 10 11
    assert fn() == 11

def test_mul():
John Zhang's avatar
John Zhang committed
12
    fn, _ = fncptr_from_c_script("test_mul.c", "test_fnc")
13 14 15
    assert fn() == 0xf6

def test_sdiv():
John Zhang's avatar
John Zhang committed
16
    fn, _ = fncptr_from_c_script("test_sdiv.c", "test_fnc")
17 18 19
    assert fn() == 0xf4

def test_urem():
John Zhang's avatar
John Zhang committed
20
    fn, _ = fncptr_from_c_script("test_urem.c", "test_fnc")
21 22 23
    assert fn() == 5

def test_shl():
John Zhang's avatar
John Zhang committed
24
    fn, _ = fncptr_from_c_script("test_shl.c", "test_fnc")
25 26 27
    assert fn() == 0x7e707560c92d5400

def test_lshr():
John Zhang's avatar
John Zhang committed
28
    fn, _ = fncptr_from_c_script("test_lshr.c", "test_fnc")
29 30 31
    assert fn() == 0x2367e707560c92

def test_and():
John Zhang's avatar
John Zhang committed
32
    fn, _ = fncptr_from_c_script("test_and.c", "test_fnc")
33 34 35
    assert fn() == 0x8588901c10004b14

def test_xor():
John Zhang's avatar
John Zhang committed
36
    fn, _ = fncptr_from_c_script("test_xor.c", "test_fnc")
37
    assert fn() == 0x58376ec3e83fa0e1