def test_check_digits_with_custom_alphabet_and_sign( self, number, base, expected): """ Checks with custom alphabet and sign """ alphabet = ("Z", "!", "T", "#", "F", "%", "S", "&", "E", "(", "0") converted = positional.encode(number, base, alphabet=alphabet, sign_literal="@") self.assertEqual(converted, expected) self.assertEqual( positional.decode(converted, base, alphabet=alphabet, sign_literal="@"), number, )
def test_check_incorrect_base(self, base): """ Check converting with wrong base """ with self.assertRaises(exceptions.WrongArgumentValueError): positional.encode(42, base)
def test_check_digits_with_wrong_alphabet(self, _, alpha): """ Alphabet is not correct """ with self.assertRaises(exceptions.WrongArgumentValueError): positional.encode(42, 10, alphabet=alpha)
def test_check_all_default_bases_positional(self, number, base): """ Auto check of encoding and decoding """ converted = positional.encode(number, base) self.assertEqual(positional.decode(converted, base), number)
def test_check_base_numbers_to_positional(self, number, base, expected): """ Manual check if converting is correction """ result = positional.encode(number, base) self.assertEqual(result, expected)
def test_wrong_argument_for_encoding(self): """ Check negative case with wrong type encoding number """ with self.assertRaises(exceptions.WrongArgumentTypeError): positional.encode(4.5, 10)
def next(num): symbols = nsp.encode(num,systemBase) symbols += ''.join(['0' for i in range(symbolsCount - symbols.__len__())]) return nsp.decode(''.join(sorted(symbols, reverse = True)), systemBase) - nsp.decode(''.join(sorted(symbols)), systemBase)
def enc(num): symbols = nsp.encode(num,systemBase) symbols = ''.join(['0' for i in range(symbolsCount - symbols.__len__())]) + symbols return symbols