@@ -127,6 +127,65 @@ def test_encode(
127127
128128 self .assertEqual (output_data , expected_output_data )
129129
130+ @data (
131+ (list ('abcd' ), list ('ccccc' ), '1' ),
132+ (list ('!!!!!' ), list ('abcdef' ), '#' )
133+ )
134+ @unpack
135+ def test_encode_rejects_non_unique_symbol_tables (
136+ self ,
137+ input_symbol_table ,
138+ output_symbol_table ,
139+ padding_symbol
140+ ):
141+ """
142+ When a non-unique input or output symbol table is passed to encode(),
143+ ValueError should be raised.
144+ """
145+ with self .assertRaises (ValueError ):
146+ encode (
147+ len (input_symbol_table ), input_symbol_table ,
148+ len (output_symbol_table ), output_symbol_table ,
149+ padding_symbol ,
150+ 1 , 1 ,
151+ []
152+ )
153+
154+ def test_encode_rejects_output_symbol_table_containing_padding_symbol (
155+ self
156+ ):
157+ """
158+ When the output symbol table passed to encode() contains the padding
159+ symbol, ValueError should be raised.
160+ """
161+ with self .assertRaises (ValueError ):
162+ encode (1 , ['a' ], 1 , ['b' ], 'b' , 1 , 1 , [])
163+
164+ @data (
165+ (list ('abcd' ), list ('efghijk' ), None ),
166+ (list ('1234' ), [1 , 2 , 3 , None ], '#' ),
167+ ([None , 2 , 3 , 4 ], list ('cabuges' ), '#' )
168+ )
169+ @unpack
170+ def test_encode_rejects_none_used_in_symbol_tables_and_padding (
171+ self ,
172+ input_symbol_table ,
173+ output_symbol_table ,
174+ padding_symbol
175+ ):
176+ """
177+ When any of the symbol tables or the padding symbol passed to encode()
178+ are or contain None, ValueError should be raised.
179+ """
180+ with self .assertRaises (ValueError ):
181+ encode (
182+ len (input_symbol_table ), input_symbol_table ,
183+ len (output_symbol_table ), output_symbol_table ,
184+ padding_symbol ,
185+ 1 , 1 ,
186+ []
187+ )
188+
130189 @data (
131190 # Base-64, using most common alphabet - no padding
132191 (
@@ -222,6 +281,65 @@ def test_decode(
222281
223282 self .assertEqual (output_data , expected_output_data )
224283
284+ @data (
285+ (list ('abcd' ), list ('ccccc' ), '1' ),
286+ (list ('!!!!!' ), list ('abcdef' ), '#' )
287+ )
288+ @unpack
289+ def test_decode_rejects_non_unique_symbol_tables (
290+ self ,
291+ input_symbol_table ,
292+ output_symbol_table ,
293+ padding_symbol
294+ ):
295+ """
296+ When a non-unique input or output symbol table is passed to decode(),
297+ ValueError should be raised.
298+ """
299+ with self .assertRaises (ValueError ):
300+ decode (
301+ len (input_symbol_table ), input_symbol_table ,
302+ padding_symbol ,
303+ len (output_symbol_table ), output_symbol_table ,
304+ 1 , 1 ,
305+ []
306+ )
307+
308+ def test_decode_rejects_input_symbol_table_containing_padding_symbol (
309+ self
310+ ):
311+ """
312+ When the input symbol table passed to decode() contains the padding
313+ symbol, ValueError should be raised.
314+ """
315+ with self .assertRaises (ValueError ):
316+ decode (1 , ['a' ], 'a' , 1 , ['b' ], 1 , 1 , [])
317+
318+ @data (
319+ (list ('abcd' ), list ('efghijk' ), None ),
320+ (list ('1234' ), [1 , 2 , 3 , None ], '#' ),
321+ ([None , 2 , 3 , 4 ], list ('cabuges' ), '#' )
322+ )
323+ @unpack
324+ def test_decode_rejects_none_used_in_symbol_tables_and_padding (
325+ self ,
326+ input_symbol_table ,
327+ output_symbol_table ,
328+ padding_symbol
329+ ):
330+ """
331+ When any of the symbol tables or the padding symbol passed to decode()
332+ are or contain None, ValueError should be raised.
333+ """
334+ with self .assertRaises (ValueError ):
335+ decode (
336+ len (input_symbol_table ), input_symbol_table ,
337+ padding_symbol ,
338+ len (output_symbol_table ), output_symbol_table ,
339+ 1 , 1 ,
340+ []
341+ )
342+
225343 @data (
226344 # Base-64, using most common alphabet with no padding needed
227345 (
0 commit comments