17 from __future__
import print_function
20 VERSION =
'cnat32table --- 2010 March 16'
33 """Tableau compact de naturels stocké sur n_1, n_2, ..., n_k bits
34 (séquence de Cnat32array)
36 Pre: n_1, n_2, ..., n_k: 1 <= naturels <= 32"""
40 """Renvoie un tableau compact de naturels
41 sur sizes[0], sizes[1], ... sizes[k] bits.
42 Si items == None alors renvoie un tableau vide
44 Pre: sizes: séquence de 1 <= naturels <= 32
55 raise NotImplementedError
60 """Renvoie le nombre d'éléments du tableau
70 """Si le tableau est vide alors renvoie 'Cnat32table()'
71 sinon renvoie 'Cnat32table(size, Cnat32array...)'
76 return (
'Cnat32table()' if self.
len == 0
77 else 'Cnat32table({0}, {1!r})'.format(self.size, [n
for n
in self.
l]))
84 if __name__ ==
'__main__':
91 debug.test_begin(VERSION, __debug__)
93 print(
'Cnat32table()...', end=
''); sys.stdout.flush()
94 for k
in range(1, 33):
96 assert t.len == 0 ==
len(t) == 0, (t.len,
len(t))
97 assert isinstance(t.l, list), type(t.l)
98 assert len(t.l) == 0,
len(t.l)
99 assert repr(t) ==
'Cnat32table()'
102 assert t.len == 0 ==
len(t) == 0, (t.len,
len(t))
103 assert isinstance(t.l, list), type(t.l)
104 assert len(t.l) == 1,
len(t.l)
105 assert len(t.l[0]) == 0,
len(t.l[0])
106 assert repr(t) ==
'Cnat32table()'
108 print(
'ok'); sys.stdout.flush()
110 print(
'Cnat32table.__getitem__()...', end=
''); sys.stdout.flush()
112 print(
'ok'); sys.stdout.flush()
115 print(
'Cnat32table.__len__()...', end=
''); sys.stdout.flush()
117 print(
'ok'); sys.stdout.flush()
120 print(
'Cnat32table.__repr__()...', end=
''); sys.stdout.flush()
122 print(
'ok'); sys.stdout.flush()
125 print(
'Cnat32table.__setitem__()...', end=
''); sys.stdout.flush()
127 print(
'ok'); sys.stdout.flush()