test_maxmin.py 861 Bytes
Newer Older
dugupeiwen's avatar
dugupeiwen committed
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
from numba.core.compiler import compile_isolated
from numba.core import types
import unittest


def domax3(a, b, c):
    return max(a, b, c)


def domin3(a, b, c):
    return min(a, b, c)


class TestMaxMin(unittest.TestCase):
    def test_max3(self):
        pyfunc = domax3
        argtys = (types.int32, types.float32, types.double)
        cres = compile_isolated(pyfunc, argtys)
        cfunc = cres.entry_point

        a = 1
        b = 2
        c = 3

        self.assertEqual(pyfunc(a, b, c), cfunc(a, b, c))

    def test_min3(self):
        pyfunc = domin3
        argtys = (types.int32, types.float32, types.double)
        cres = compile_isolated(pyfunc, argtys)
        cfunc = cres.entry_point

        a = 1
        b = 2
        c = 3

        self.assertEqual(pyfunc(a, b, c), cfunc(a, b, c))


if __name__ == '__main__':
    unittest.main()