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
50
51
52
53
54
55
56
57
58
59
60
|
import cpp11_hash_tables
def swig_assert_equal(a, b):
if a != b:
raise RuntimeError(str(a) + " != " + str(b))
for x in [cpp11_hash_tables.MapIntInt({1:7}),
cpp11_hash_tables.MultiMapIntInt({1:7}),
cpp11_hash_tables.UnorderedMapIntInt({1:7}),
cpp11_hash_tables.UnorderedMultiMapIntInt({1:7})
]:
swig_assert_equal([(k, v) for k, v in x.items()], [(1, 7)])
swig_assert_equal(list(x.keys()), [1])
swig_assert_equal(list(x.values()), [7])
swig_assert_equal(list(x.items()), [(1, 7)])
swig_assert_equal([k for k in x], [1])
swig_assert_equal([i for i in x.keys()], [1])
swig_assert_equal([i for i in x.values()], [7])
swig_assert_equal([i for i in x.items()], [(1, 7)])
swig_assert_equal(x[1], 7)
swig_assert_equal(2 in x, False)
x[2] = 9
swig_assert_equal(x[2], 9)
del x[2]
swig_assert_equal(2 in x, False)
swig_assert_equal(x.empty(), False)
del x[1]
swig_assert_equal(x.empty(), True)
swig_assert_equal(1 in x, False)
for x in [cpp11_hash_tables.MultiMapIntInt({1:7}),
cpp11_hash_tables.UnorderedMultiMapIntInt({1:7})]:
x[1] = 9
swig_assert_equal(sorted([v for k, v in x.items()]), [7, 9])
swig_assert_equal(len(x), 2)
for x in [cpp11_hash_tables.SetInt([1]),
cpp11_hash_tables.MultiSetInt([1]),
cpp11_hash_tables.UnorderedSetInt([1]),
cpp11_hash_tables.UnorderedMultiSetInt([1])]:
swig_assert_equal([e for e in x], [1])
swig_assert_equal(x[0], 1)
swig_assert_equal(1 in x, True)
swig_assert_equal(2 in x, False)
x.append(2)
swig_assert_equal(2 in x, True)
x.erase(2)
swig_assert_equal(x.empty(), False)
x.erase(1)
swig_assert_equal(x.empty(), True)
for x in [cpp11_hash_tables.MultiSetInt([1]),
cpp11_hash_tables.UnorderedMultiSetInt([1])]:
x.append(1)
swig_assert_equal(x.count(1), 2)
swig_assert_equal(len(x), 2)
|