stl_containers.py 1.17 KB
Newer Older
John Parent's avatar
John Parent committed
1
2
3
4
5
6
7
8
9
10
import os, sys
import unittest

sys.path.append(os.getcwd())

from stl_container import (
    VectorInt,
    VectorDouble,
    Int2String,
    Int2Double,
John Parent's avatar
John Parent committed
11
    VectoVec,
John Parent's avatar
John Parent committed
12
13
14
15
)


class TestStlBinders(unittest.TestCase):
John Parent's avatar
John Parent committed
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
50
51
52
53
54
    def test_vectorInt(self):
        vi = VectorInt()
        vi.append(1)
        vi.append(2)
        sum_ = 0
        for x in vi:
            sum_ += x
        self.assertEqual(sum_, 3)
        method_list = [
            "pop",
            "remove",
            "insert",
            "extend",
            "count",
            "clear",
            "append",
        ]
        for method in method_list:
            self.assertIn(method, dir(VectorInt))

    def test_VectorDouble(self):
        vd = VectorDouble()
        vd.push_back(1)
        vd.push_back(2)
        self.assertEqual(vd.size(), 2)
        self.assertEqual(vd.at(1), 2)
        vd.assign(10, 1)
        for x in range(10):
            self.assertEqual(vd[x], 1)

    def test_Int2String(self):
        i2s = Int2String()

    def test_Int2Double(self):
        i2d = Int2Double()
        i2d[1] = 2.2

    def test_VectoVec(self):
        v2v = VectoVec()
John Parent's avatar
John Parent committed
55
56
57
58


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