Example #1
0
    def test_o1_2(self):
        # Block of lines to Octal-1.
        common.request('../o1')
        input = ''.join(self.inputs)
        output = '''\
0012, 0141, 0012, 0141, 0142, 0012, 0141, 0142, 0143, 0012, 0141, 0142,
0143, 0144, 0012, 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151,
0012, 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153,
0154, 0155, 0156, 0157, 0160, 0161, 0162, 0163, 0012, 0141, 0142, 0143,
0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157,
0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172, 0171, 0172, 0101,
0102, 0103, 0012, 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151,
0152, 0153, 0154, 0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165,
0166, 0167, 0172, 0171, 0172, 0101, 0102, 0103, 0104, 0105, 0106, 0107,
0110, 0111, 0112, 0113, 0114, 0115, 0012, 0141, 0142, 0143, 0144, 0145,
0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0160, 0161,
0162, 0163, 0164, 0165, 0166, 0167, 0172, 0171, 0172, 0101, 0102, 0103,
0104, 0105, 0106, 0107, 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117,
0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, 0012, 0141, 0142, 0143,
0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157,
0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172, 0171, 0172, 0101,
0102, 0103, 0104, 0105, 0106, 0107, 0110, 0111, 0112, 0113, 0114, 0115,
0116, 0117, 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, 0130, 0131,
0132, 0060, 0061, 0062, 0063, 0064, 0065, 0066, 0012
'''
        common.validate(input, output)
Example #2
0
    def test_x1_2(self):
        # Block of lines to Hexadecimal-1.
        common.request('../x1')
        input = ''.join(self.inputs)
        output = '''\
0x0A, 0x61, 0x0A, 0x61, 0x62, 0x0A, 0x61, 0x62, 0x63, 0x0A, 0x61, 0x62,
0x63, 0x64, 0x0A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
0x0A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B,
0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x0A, 0x61, 0x62, 0x63,
0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41,
0x42, 0x43, 0x0A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75,
0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x0A, 0x61, 0x62, 0x63, 0x64, 0x65,
0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71,
0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41, 0x42, 0x43,
0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x0A, 0x61, 0x62, 0x63,
0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41,
0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
0x5A, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x0A
'''
        common.validate(input, output)
Example #3
0
    def test_d2_1(self):
        # Single lines to Decimal-2.
        common.request('../d2')
        outputs = ['''\
 10
''', '''\
24842
''', '''\
24930,  10
''', '''\
24930, 25354
''', '''\
24930, 25444,  10
''', '''\
24930, 25444, 25958, 26472, 26890
''', '''\
24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29450
''', '''\
24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29556,
30070, 30586, 31098, 16706, 17162
''', '''\
24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29556,
30070, 30586, 31098, 16706, 17220, 17734, 18248, 18762, 19276, 19722
''', '''\
24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29556,
30070, 30586, 31098, 16706, 17220, 17734, 18248, 18762, 19276, 19790,
20304, 20818, 21332, 21846, 22282
''', '''\
24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29556,
30070, 30586, 31098, 16706, 17220, 17734, 18248, 18762, 19276, 19790,
20304, 20818, 21332, 21846, 22360, 22874, 12337, 12851, 13365, 13834
''']
        for input, output in zip(self.inputs, outputs):
            common.validate(input, output)
Example #4
0
    def test_x4_1(self):
        # Single lines to Hexadecimal-4.
        common.request('../x4')
        outputs = ['''\
0x0A
''', '''\
0x610A
''', '''\
0x61620A
''', '''\
0x6162630A
''', '''\
0x61626364, 0x0A
''', '''\
0x61626364, 0x65666768, 0x690A
''', '''\
0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x7172730A
''', '''\
0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x71727374, 0x7576777A,
0x797A4142, 0x430A
''', '''\
0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x71727374, 0x7576777A,
0x797A4142, 0x43444546, 0x4748494A, 0x4B4C4D0A
''', '''\
0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x71727374, 0x7576777A,
0x797A4142, 0x43444546, 0x4748494A, 0x4B4C4D4E, 0x4F505152, 0x53545556,
0x570A
''', '''\
0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x71727374, 0x7576777A,
0x797A4142, 0x43444546, 0x4748494A, 0x4B4C4D4E, 0x4F505152, 0x53545556,
0x5758595A, 0x30313233, 0x3435360A
''']
        for input, output in zip(self.inputs, outputs):
            common.validate(input, output)
Example #5
0
    def test_o1_2(self):
        # Block of lines to Octal-1.
        common.request('../o1')
        input = ''.join(self.inputs)
        output = '''\
0012, 0141, 0012, 0141, 0142, 0012, 0141, 0142, 0143, 0012, 0141, 0142,
0143, 0144, 0012, 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151,
0012, 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153,
0154, 0155, 0156, 0157, 0160, 0161, 0162, 0163, 0012, 0141, 0142, 0143,
0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157,
0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172, 0171, 0172, 0101,
0102, 0103, 0012, 0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151,
0152, 0153, 0154, 0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165,
0166, 0167, 0172, 0171, 0172, 0101, 0102, 0103, 0104, 0105, 0106, 0107,
0110, 0111, 0112, 0113, 0114, 0115, 0012, 0141, 0142, 0143, 0144, 0145,
0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0160, 0161,
0162, 0163, 0164, 0165, 0166, 0167, 0172, 0171, 0172, 0101, 0102, 0103,
0104, 0105, 0106, 0107, 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117,
0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, 0012, 0141, 0142, 0143,
0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157,
0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172, 0171, 0172, 0101,
0102, 0103, 0104, 0105, 0106, 0107, 0110, 0111, 0112, 0113, 0114, 0115,
0116, 0117, 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, 0130, 0131,
0132, 0060, 0061, 0062, 0063, 0064, 0065, 0066, 0012
'''
        common.validate(input, output)
Example #6
0
def test_validate_message_without_attributes(validation_schema, verbose,
                                             correct_message, attribute):
    """Test the validation for improper payload."""
    del correct_message[attribute]
    # it should fail
    with pytest.raises(Invalid) as excinfo:
        validate(schema, correct_message, verbose)
Example #7
0
    def test_d4_1(self):
        # Single lines to Decimal-4.
        common.request('../d4')
        outputs = ['''\
 10
''', '''\
24842
''', '''\
 6382090
''', '''\
1633837834
''', '''\
1633837924,  10
''', '''\
1633837924, 1701209960, 26890
''', '''\
1633837924, 1701209960, 1768581996, 1835954032, 1903325962
''', '''\
1633837924, 1701209960, 1768581996, 1835954032, 1903326068,
1970698106, 2038055234, 17162
''', '''\
1633837924, 1701209960, 1768581996, 1835954032, 1903326068,
1970698106, 2038055234, 1128547654, 1195919690, 1263291658
''', '''\
1633837924, 1701209960, 1768581996, 1835954032, 1903326068,
1970698106, 2038055234, 1128547654, 1195919690, 1263291726,
1330663762, 1398035798, 22282
''', '''\
1633837924, 1701209960, 1768581996, 1835954032, 1903326068,
1970698106, 2038055234, 1128547654, 1195919690, 1263291726,
1330663762, 1398035798, 1465407834,  808530483,  875902474
''']
        for input, output in zip(self.inputs, outputs):
            common.validate(input, output)
Example #8
0
    def test_1(self):
        # Single lines to Base64.
        common.request('../64')
        output = ['''\
Cg==
''', '''\
YQo=
''', '''\
YWIK
''', '''\
YWJjCg==
''', '''\
YWJjZAo=
''', '''\
YWJjZGVmZ2hpCg==
''', '''\
YWJjZGVmZ2hpamtsbW5vcHFycwo=
''', '''\
YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd6eXpBQkMK
''', '''\
YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd6eXpBQkNERUZHSElKS0xNCg==
''', '''\
YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd6eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWVwo=
''', '''\
YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd6eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0
NTYK
'''
                  ]
        for input, output in zip(self.inputs, output):
            common.validate(input, output)
Example #9
0
    def test_x1_2(self):
        # Block of lines to Hexadecimal-1.
        common.request('../x1')
        input = ''.join(self.inputs)
        output = '''\
0x0A, 0x61, 0x0A, 0x61, 0x62, 0x0A, 0x61, 0x62, 0x63, 0x0A, 0x61, 0x62,
0x63, 0x64, 0x0A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
0x0A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B,
0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x0A, 0x61, 0x62, 0x63,
0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41,
0x42, 0x43, 0x0A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75,
0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x0A, 0x61, 0x62, 0x63, 0x64, 0x65,
0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71,
0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41, 0x42, 0x43,
0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x0A, 0x61, 0x62, 0x63,
0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A, 0x79, 0x7A, 0x41,
0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D,
0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
0x5A, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x0A
'''
        common.validate(input, output)
Example #10
0
    def test_2(self):
        # Block of lines to Base64.
        common.request('/../64')
        output = '''\
CmEKYWIKYWJjCmFiY2QKYWJjZGVmZ2hpCmFiY2RlZmdoaWprbG1ub3BxcnMKYWJjZGVmZ2hpamts
bW5vcHFyc3R1dnd6eXpBQkMKYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd6eXpBQkNERUZHSElKS0xN
CmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3enl6QUJDREVGR0hJSktMTU5PUFFSU1RVVlcKYWJjZGVm
Z2hpamtsbW5vcHFyc3R1dnd6eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NTYK
'''
        common.validate(''.join(self.inputs), output)
Example #11
0
def test_validate_message_wrong_org_id_attribute(validation_schema, verbose,
                                                 correct_message):
    """Test the validation for improper payload."""
    # check with negative integer
    correct_message["OrgID"] = -1
    # it should fail
    with pytest.raises(Invalid) as excinfo:
        validate(schema, correct_message, verbose)

    # check with string not representing number
    correct_message["OrgID"] = "foobar"
    # it should fail
    with pytest.raises(Invalid) as excinfo:
        validate(schema, correct_message, verbose)

    # check with string representing number
    correct_message["OrgID"] = "123456"
    # it should fail
    with pytest.raises(Invalid) as excinfo:
        validate(schema, correct_message, verbose)

    # check with different data type
    correct_message["OrgID"] = []
    # it should fail
    with pytest.raises(Invalid) as excinfo:
        validate(schema, correct_message, verbose)
Example #12
0
def test_validate_message_wrong_response_metadata_attribute(
        validation_schema, verbose, correct_message):
    """Test the validation for improper payload."""
    # check with string not representing number
    correct_message["ResponseMetadata"] = "foobar"
    # it should fail
    with pytest.raises(Invalid) as excinfo:
        validate(schema, correct_message, verbose)

    # check with number
    correct_message["ResponseMetadata"] = 123456
    # it should fail
    with pytest.raises(Invalid) as excinfo:
        validate(schema, correct_message, verbose)

    # check with different data type
    correct_message["ResponseMetadata"] = []
    # it should fail
    with pytest.raises(Invalid) as excinfo:
        validate(schema, correct_message, verbose)

    # check with different data type
    correct_message["ResponseMetadata"] = {}
    # it should fail
    with pytest.raises(Invalid) as excinfo:
        validate(schema, correct_message, verbose)
Example #13
0
def test_validate_message_wrong_attributes(validation_schema, verbose,
                                           correct_message, attribute):
    """Test the validation for improper payload."""
    # check with number
    correct_message[attribute] = 123456
    # it should fail
    with pytest.raises(Invalid) as excinfo:
        validate(schema, correct_message, verbose)

    # check with different data type
    correct_message[attribute] = []
    # it should fail
    with pytest.raises(Invalid) as excinfo:
        validate(schema, correct_message, verbose)
Example #14
0
def solve_lookahead(initial_board, verbose=False):
    candidates = {(i, j): set(range(1, 10)) for i in range(9) for j in range(9)}
    possibilities = [(candidates, initial_board)]
    pp = possibilities[0]
    recursive_single_elimination(pp[0], pp[1])
    if is_solved(possibilities[0][1]):
        return possibilities[0][1]

    while True:
        new_possibilities = []
        for p in possibilities:
            new_possibilities.extend(lookahead(p[0], p[1]))

        if verbose:
            print('Increasing from', len(possibilities), 'to', len(new_possibilities))

        valid_possibilities = []
        for p in new_possibilities:
            recursive_single_elimination(p[0], p[1])
            if validate(p[1]):
                valid_possibilities.append(p)

        if verbose:
            diff = len(new_possibilities) - len(valid_possibilities)
            if diff:
                print('Removed:', diff, 'invalid options')

        if any(is_solved(p[1]) for p in valid_possibilities):
            return [p[1] for p in valid_possibilities if is_solved(p[1])]
        possibilities = valid_possibilities

        if verbose:
            print('Length:', len(possibilities))
Example #15
0
    def test_x4_2(self):
        # Block of lines to Hexadecimal-4.
        common.request('../x4')
        input = ''.join(self.inputs)
        output = '''\
0x0A610A61, 0x620A6162, 0x630A6162, 0x63640A61, 0x62636465, 0x66676869,
0x0A616263, 0x64656667, 0x68696A6B, 0x6C6D6E6F, 0x70717273, 0x0A616263,
0x64656667, 0x68696A6B, 0x6C6D6E6F, 0x70717273, 0x74757677, 0x7A797A41,
0x42430A61, 0x62636465, 0x66676869, 0x6A6B6C6D, 0x6E6F7071, 0x72737475,
0x76777A79, 0x7A414243, 0x44454647, 0x48494A4B, 0x4C4D0A61, 0x62636465,
0x66676869, 0x6A6B6C6D, 0x6E6F7071, 0x72737475, 0x76777A79, 0x7A414243,
0x44454647, 0x48494A4B, 0x4C4D4E4F, 0x50515253, 0x54555657, 0x0A616263,
0x64656667, 0x68696A6B, 0x6C6D6E6F, 0x70717273, 0x74757677, 0x7A797A41,
0x42434445, 0x46474849, 0x4A4B4C4D, 0x4E4F5051, 0x52535455, 0x56575859,
0x5A303132, 0x33343536, 0x0A
'''
        common.validate(input, output)
Example #16
0
    def test_x4_2(self):
        # Block of lines to Hexadecimal-4.
        common.request('../x4')
        input = ''.join(self.inputs)
        output = '''\
0x0A610A61, 0x620A6162, 0x630A6162, 0x63640A61, 0x62636465, 0x66676869,
0x0A616263, 0x64656667, 0x68696A6B, 0x6C6D6E6F, 0x70717273, 0x0A616263,
0x64656667, 0x68696A6B, 0x6C6D6E6F, 0x70717273, 0x74757677, 0x7A797A41,
0x42430A61, 0x62636465, 0x66676869, 0x6A6B6C6D, 0x6E6F7071, 0x72737475,
0x76777A79, 0x7A414243, 0x44454647, 0x48494A4B, 0x4C4D0A61, 0x62636465,
0x66676869, 0x6A6B6C6D, 0x6E6F7071, 0x72737475, 0x76777A79, 0x7A414243,
0x44454647, 0x48494A4B, 0x4C4D4E4F, 0x50515253, 0x54555657, 0x0A616263,
0x64656667, 0x68696A6B, 0x6C6D6E6F, 0x70717273, 0x74757677, 0x7A797A41,
0x42434445, 0x46474849, 0x4A4B4C4D, 0x4E4F5051, 0x52535455, 0x56575859,
0x5A303132, 0x33343536, 0x0A
'''
        common.validate(input, output)
Example #17
0
    def test_o1_1(self):
        # Single lines to Octal-1.
        common.request('../o1')
        outputs = [
            '''\
0012
''', '''\
0141, 0012
''', '''\
0141, 0142, 0012
''', '''\
0141, 0142, 0143, 0012
''', '''\
0141, 0142, 0143, 0144, 0012
''', '''\
0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0012
''', '''\
0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154,
0155, 0156, 0157, 0160, 0161, 0162, 0163, 0012
''', '''\
0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154,
0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172,
0171, 0172, 0101, 0102, 0103, 0012
''', '''\
0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154,
0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172,
0171, 0172, 0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110, 0111, 0112,
0113, 0114, 0115, 0012
''', '''\
0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154,
0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172,
0171, 0172, 0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110, 0111, 0112,
0113, 0114, 0115, 0116, 0117, 0120, 0121, 0122, 0123, 0124, 0125, 0126,
0127, 0012
''', '''\
0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154,
0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172,
0171, 0172, 0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110, 0111, 0112,
0113, 0114, 0115, 0116, 0117, 0120, 0121, 0122, 0123, 0124, 0125, 0126,
0127, 0130, 0131, 0132, 0060, 0061, 0062, 0063, 0064, 0065, 0066, 0012
'''
        ]
        for input, output in zip(self.inputs, outputs):
            common.validate(input, output)
Example #18
0
    def test_x1_1(self):
        # Single lines to Hexadecimal-1.
        common.request('../x1')
        outputs = [
            '''\
0x0A
''', '''\
0x61, 0x0A
''', '''\
0x61, 0x62, 0x0A
''', '''\
0x61, 0x62, 0x63, 0x0A
''', '''\
0x61, 0x62, 0x63, 0x64, 0x0A
''', '''\
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x0A
''', '''\
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C,
0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x0A
''', '''\
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C,
0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A,
0x79, 0x7A, 0x41, 0x42, 0x43, 0x0A
''', '''\
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C,
0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A,
0x79, 0x7A, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A,
0x4B, 0x4C, 0x4D, 0x0A
''', '''\
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C,
0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A,
0x79, 0x7A, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A,
0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,
0x57, 0x0A
''', '''\
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C,
0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A,
0x79, 0x7A, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A,
0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,
0x57, 0x58, 0x59, 0x5A, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x0A
'''
        ]
        for input, output in zip(self.inputs, outputs):
            common.validate(input, output)
Example #19
0
    def test_d4_2(self):
        # Block of lines to Decimal-4.
        common.request('../d4')
        input = ''.join(self.inputs)
        output = '''\
 174131809, 1644847458, 1661624674, 1667500641, 1650680933,
1718052969,  174154339, 1684366951, 1751738987, 1819111023,
1886483059,  174154339, 1684366951, 1751738987, 1819111023,
1886483059, 1953855095, 2054781505, 1111689825, 1650680933,
1718052969, 1785425005, 1852797041, 1920169077, 1987541625,
2051097155, 1145390663, 1212762699, 1280117345, 1650680933,
1718052969, 1785425005, 1852797041, 1920169077, 1987541625,
2051097155, 1145390663, 1212762699, 1280134735, 1347506771,
1414878807,  174154339, 1684366951, 1751738987, 1819111023,
1886483059, 1953855095, 2054781505, 1111704645, 1179076681,
1246448717, 1313820753, 1381192789, 1448564825, 1513107762,
 859059510,  10
'''
        common.validate(input, output)
Example #20
0
    def test_d2_2(self):
        # Block of lines to Decimal-2.
        common.request('../d2')
        input = ''.join(self.inputs)
        output = '''\
 2657,  2657, 25098, 24930, 25354, 24930, 25444,  2657, 25187, 25701,
26215, 26729,  2657, 25187, 25701, 26215, 26729, 27243, 27757, 28271,
28785, 29299,  2657, 25187, 25701, 26215, 26729, 27243, 27757, 28271,
28785, 29299, 29813, 30327, 31353, 31297, 16963,  2657, 25187, 25701,
26215, 26729, 27243, 27757, 28271, 28785, 29299, 29813, 30327, 31353,
31297, 16963, 17477, 17991, 18505, 19019, 19533,  2657, 25187, 25701,
26215, 26729, 27243, 27757, 28271, 28785, 29299, 29813, 30327, 31353,
31297, 16963, 17477, 17991, 18505, 19019, 19533, 20047, 20561, 21075,
21589, 22103,  2657, 25187, 25701, 26215, 26729, 27243, 27757, 28271,
28785, 29299, 29813, 30327, 31353, 31297, 16963, 17477, 17991, 18505,
19019, 19533, 20047, 20561, 21075, 21589, 22103, 22617, 23088, 12594,
13108, 13622,  10
'''
        common.validate(input, output)
Example #21
0
    def test_d2_2(self):
        # Block of lines to Decimal-2.
        common.request('../d2')
        input = ''.join(self.inputs)
        output = '''\
 2657,  2657, 25098, 24930, 25354, 24930, 25444,  2657, 25187, 25701,
26215, 26729,  2657, 25187, 25701, 26215, 26729, 27243, 27757, 28271,
28785, 29299,  2657, 25187, 25701, 26215, 26729, 27243, 27757, 28271,
28785, 29299, 29813, 30327, 31353, 31297, 16963,  2657, 25187, 25701,
26215, 26729, 27243, 27757, 28271, 28785, 29299, 29813, 30327, 31353,
31297, 16963, 17477, 17991, 18505, 19019, 19533,  2657, 25187, 25701,
26215, 26729, 27243, 27757, 28271, 28785, 29299, 29813, 30327, 31353,
31297, 16963, 17477, 17991, 18505, 19019, 19533, 20047, 20561, 21075,
21589, 22103,  2657, 25187, 25701, 26215, 26729, 27243, 27757, 28271,
28785, 29299, 29813, 30327, 31353, 31297, 16963, 17477, 17991, 18505,
19019, 19533, 20047, 20561, 21075, 21589, 22103, 22617, 23088, 12594,
13108, 13622,  10
'''
        common.validate(input, output)
Example #22
0
    def test_d4_2(self):
        # Block of lines to Decimal-4.
        common.request('../d4')
        input = ''.join(self.inputs)
        output = '''\
 174131809, 1644847458, 1661624674, 1667500641, 1650680933,
1718052969,  174154339, 1684366951, 1751738987, 1819111023,
1886483059,  174154339, 1684366951, 1751738987, 1819111023,
1886483059, 1953855095, 2054781505, 1111689825, 1650680933,
1718052969, 1785425005, 1852797041, 1920169077, 1987541625,
2051097155, 1145390663, 1212762699, 1280117345, 1650680933,
1718052969, 1785425005, 1852797041, 1920169077, 1987541625,
2051097155, 1145390663, 1212762699, 1280134735, 1347506771,
1414878807,  174154339, 1684366951, 1751738987, 1819111023,
1886483059, 1953855095, 2054781505, 1111704645, 1179076681,
1246448717, 1313820753, 1381192789, 1448564825, 1513107762,
 859059510,  10
'''
        common.validate(input, output)
Example #23
0
    def test_o1_1(self):
        # Single lines to Octal-1.
        common.request('../o1')
        outputs = ['''\
0012
''', '''\
0141, 0012
''', '''\
0141, 0142, 0012
''', '''\
0141, 0142, 0143, 0012
''', '''\
0141, 0142, 0143, 0144, 0012
''', '''\
0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0012
''', '''\
0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154,
0155, 0156, 0157, 0160, 0161, 0162, 0163, 0012
''', '''\
0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154,
0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172,
0171, 0172, 0101, 0102, 0103, 0012
''', '''\
0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154,
0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172,
0171, 0172, 0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110, 0111, 0112,
0113, 0114, 0115, 0012
''', '''\
0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154,
0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172,
0171, 0172, 0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110, 0111, 0112,
0113, 0114, 0115, 0116, 0117, 0120, 0121, 0122, 0123, 0124, 0125, 0126,
0127, 0012
''', '''\
0141, 0142, 0143, 0144, 0145, 0146, 0147, 0150, 0151, 0152, 0153, 0154,
0155, 0156, 0157, 0160, 0161, 0162, 0163, 0164, 0165, 0166, 0167, 0172,
0171, 0172, 0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110, 0111, 0112,
0113, 0114, 0115, 0116, 0117, 0120, 0121, 0122, 0123, 0124, 0125, 0126,
0127, 0130, 0131, 0132, 0060, 0061, 0062, 0063, 0064, 0065, 0066, 0012
''']
        for input, output in zip(self.inputs, outputs):
            common.validate(input, output)
Example #24
0
    def test_x1_1(self):
        # Single lines to Hexadecimal-1.
        common.request('../x1')
        outputs = ['''\
0x0A
''', '''\
0x61, 0x0A
''', '''\
0x61, 0x62, 0x0A
''', '''\
0x61, 0x62, 0x63, 0x0A
''', '''\
0x61, 0x62, 0x63, 0x64, 0x0A
''', '''\
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x0A
''', '''\
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C,
0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x0A
''', '''\
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C,
0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A,
0x79, 0x7A, 0x41, 0x42, 0x43, 0x0A
''', '''\
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C,
0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A,
0x79, 0x7A, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A,
0x4B, 0x4C, 0x4D, 0x0A
''', '''\
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C,
0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A,
0x79, 0x7A, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A,
0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,
0x57, 0x0A
''', '''\
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C,
0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x7A,
0x79, 0x7A, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A,
0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,
0x57, 0x58, 0x59, 0x5A, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x0A
''']
        for input, output in zip(self.inputs, outputs):
            common.validate(input, output)
Example #25
0
def test_1():
    # Block of lines from Quoted Printable.
    common.request('qp..x1')
    output = '''\
0x44, 0x65, 0x61, 0x72, 0x20, 0xDE, 0x6F, 0x72, 0x76, 0x61, 0x72, 0x64,
0xF0, 0x75, 0x72, 0x2C, 0x0A, 0x0A, 0xAB, 0x20, 0x4F, 0xF9, 0x20, 0x71,
0x75, 0x27, 0x69, 0x6C, 0x20, 0x72, 0xE9, 0x73, 0x69, 0x64, 0x65, 0x2C,
0x20, 0xE0, 0x20, 0x4E, 0xEE, 0x6D, 0x65, 0x73, 0x20, 0x6F, 0x75, 0x20,
0x6D, 0xEA, 0x6D, 0x65, 0x20, 0x43, 0x61, 0x70, 0x68, 0x61, 0x72, 0x6E,
0x61, 0xFC, 0x6D, 0x2C, 0x20, 0x74, 0x6F, 0x75, 0x74, 0x20, 0x46, 0x72,
0x61, 0x6E, 0xE7, 0x61, 0x69, 0x73, 0x20, 0x69, 0x6E, 0x73, 0x63, 0x72,
0x69, 0x74, 0x0A, 0x61, 0x75, 0x20, 0x72, 0xF4, 0x6C, 0x65, 0x20, 0x70,
0x61, 0x79, 0x65, 0x72, 0x61, 0x20, 0x73, 0x6F, 0x6E, 0x20, 0x64, 0xFB,
0x20, 0x64, 0xE8, 0x73, 0x20, 0x61, 0x76, 0x61, 0x6E, 0x74, 0x20, 0x4E,
0x6F, 0xEB, 0x6C, 0x2C, 0x20, 0x71, 0x75, 0x27, 0x69, 0x6C, 0x20, 0x73,
0x6F, 0x69, 0x74, 0x20, 0x6E, 0x61, 0xEF, 0x66, 0x20, 0x6F, 0x75, 0x20,
0x72, 0xE2, 0x6C, 0x65, 0x75, 0x72, 0x2E, 0x20, 0xBB, 0x0A, 0x49, 0x6E,
0x63, 0x6F, 0x6D, 0x70, 0x6C, 0x65, 0x74, 0x65, 0x20, 0x6C, 0x61, 0x73,
0x74, 0x20, 0x6C, 0x69, 0x6E, 0x65
'''
    common.validate(input, output)
Example #26
0
def test_1():
    # Block of lines from Quoted Printable.
    common.request('qp..x1')
    output = '''\
0x44, 0x65, 0x61, 0x72, 0x20, 0xDE, 0x6F, 0x72, 0x76, 0x61, 0x72, 0x64,
0xF0, 0x75, 0x72, 0x2C, 0x0A, 0x0A, 0xAB, 0x20, 0x4F, 0xF9, 0x20, 0x71,
0x75, 0x27, 0x69, 0x6C, 0x20, 0x72, 0xE9, 0x73, 0x69, 0x64, 0x65, 0x2C,
0x20, 0xE0, 0x20, 0x4E, 0xEE, 0x6D, 0x65, 0x73, 0x20, 0x6F, 0x75, 0x20,
0x6D, 0xEA, 0x6D, 0x65, 0x20, 0x43, 0x61, 0x70, 0x68, 0x61, 0x72, 0x6E,
0x61, 0xFC, 0x6D, 0x2C, 0x20, 0x74, 0x6F, 0x75, 0x74, 0x20, 0x46, 0x72,
0x61, 0x6E, 0xE7, 0x61, 0x69, 0x73, 0x20, 0x69, 0x6E, 0x73, 0x63, 0x72,
0x69, 0x74, 0x0A, 0x61, 0x75, 0x20, 0x72, 0xF4, 0x6C, 0x65, 0x20, 0x70,
0x61, 0x79, 0x65, 0x72, 0x61, 0x20, 0x73, 0x6F, 0x6E, 0x20, 0x64, 0xFB,
0x20, 0x64, 0xE8, 0x73, 0x20, 0x61, 0x76, 0x61, 0x6E, 0x74, 0x20, 0x4E,
0x6F, 0xEB, 0x6C, 0x2C, 0x20, 0x71, 0x75, 0x27, 0x69, 0x6C, 0x20, 0x73,
0x6F, 0x69, 0x74, 0x20, 0x6E, 0x61, 0xEF, 0x66, 0x20, 0x6F, 0x75, 0x20,
0x72, 0xE2, 0x6C, 0x65, 0x75, 0x72, 0x2E, 0x20, 0xBB, 0x0A, 0x49, 0x6E,
0x63, 0x6F, 0x6D, 0x70, 0x6C, 0x65, 0x74, 0x65, 0x20, 0x6C, 0x61, 0x73,
0x74, 0x20, 0x6C, 0x69, 0x6E, 0x65
'''
    common.validate(input, output)
Example #27
0
    def test_x2_1(self):
        # Single lines to Hexadecimal-2.
        common.request('../x2')
        outputs = [
            '''\
0x0A
''', '''\
0x610A
''', '''\
0x6162, 0x0A
''', '''\
0x6162, 0x630A
''', '''\
0x6162, 0x6364, 0x0A
''', '''\
0x6162, 0x6364, 0x6566, 0x6768, 0x690A
''', '''\
0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70,
0x7172, 0x730A
''', '''\
0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70,
0x7172, 0x7374, 0x7576, 0x777A, 0x797A, 0x4142, 0x430A
''', '''\
0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70,
0x7172, 0x7374, 0x7576, 0x777A, 0x797A, 0x4142, 0x4344, 0x4546,
0x4748, 0x494A, 0x4B4C, 0x4D0A
''', '''\
0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70,
0x7172, 0x7374, 0x7576, 0x777A, 0x797A, 0x4142, 0x4344, 0x4546,
0x4748, 0x494A, 0x4B4C, 0x4D4E, 0x4F50, 0x5152, 0x5354, 0x5556,
0x570A
''', '''\
0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70,
0x7172, 0x7374, 0x7576, 0x777A, 0x797A, 0x4142, 0x4344, 0x4546,
0x4748, 0x494A, 0x4B4C, 0x4D4E, 0x4F50, 0x5152, 0x5354, 0x5556,
0x5758, 0x595A, 0x3031, 0x3233, 0x3435, 0x360A
'''
        ]
        for input, output in zip(self.inputs, outputs):
            common.validate(input, output)
Example #28
0
    def test_o4_1(self):
        # Single lines to Octal-4.
        common.request('../o4')
        outputs = [
            '''\
0012
''', '''\
0060412
''', '''\
030261012
''', '''\
014130461412
''', '''\
014130461544, 0012
''', '''\
014130461544, 014531463550, 0064412
''', '''\
014130461544, 014531463550, 015132465554, 015533467560,
016134471412
''', '''\
014130461544, 014531463550, 015132465554, 015533467560,
016134471564, 016535473572, 017136440502, 0041412
''', '''\
014130461544, 014531463550, 015132465554, 015533467560,
016134471564, 016535473572, 017136440502, 010321042506,
010722044512, 011323046412
''', '''\
014130461544, 014531463550, 015132465554, 015533467560,
016134471564, 016535473572, 017136440502, 010321042506,
010722044512, 011323046516, 011724050522, 012325052526,
0053412
''', '''\
014130461544, 014531463550, 015132465554, 015533467560,
016134471564, 016535473572, 017136440502, 010321042506,
010722044512, 011323046516, 011724050522, 012325052526,
012726054532, 006014231063, 006415233012
'''
        ]
        for input, output in zip(self.inputs, outputs):
            common.validate(input, output)
Example #29
0
    def test_d1_1(self):
        # Single lines to Decimal-1.
        common.request('../d1')
        outputs = [
            '''\
 10
''', '''\
 97,  10
''', '''\
 97,  98,  10
''', '''\
 97,  98,  99,  10
''', '''\
 97,  98,  99, 100,  10
''', '''\
 97,  98,  99, 100, 101, 102, 103, 104, 105,  10
''', '''\
 97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115,  10
''', '''\
 97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122,  65,  66,  67,  10
''', '''\
 97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122,  65,  66,  67,  68,
 69,  70,  71,  72,  73,  74,  75,  76,  77,  10
''', '''\
 97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122,  65,  66,  67,  68,
 69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,  80,  81,  82,  83,
 84,  85,  86,  87,  10
''', '''\
 97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122,  65,  66,  67,  68,
 69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,  80,  81,  82,  83,
 84,  85,  86,  87,  88,  89,  90,  48,  49,  50,  51,  52,  53,  54,  10
'''
        ]
        for input, output in zip(self.inputs, outputs):
            common.validate(input, output)
Example #30
0
    def test_o2_1(self):
        # Single lines to Octal-2.
        common.request('../o2')
        outputs = [
            '''\
0012
''', '''\
0060412
''', '''\
0060542, 0012
''', '''\
0060542, 0061412
''', '''\
0060542, 0061544, 0012
''', '''\
0060542, 0061544, 0062546, 0063550, 0064412
''', '''\
0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560,
0070562, 0071412
''', '''\
0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560,
0070562, 0071564, 0072566, 0073572, 0074572, 0040502, 0041412
''', '''\
0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560,
0070562, 0071564, 0072566, 0073572, 0074572, 0040502, 0041504, 0042506,
0043510, 0044512, 0045514, 0046412
''', '''\
0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560,
0070562, 0071564, 0072566, 0073572, 0074572, 0040502, 0041504, 0042506,
0043510, 0044512, 0045514, 0046516, 0047520, 0050522, 0051524, 0052526,
0053412
''', '''\
0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560,
0070562, 0071564, 0072566, 0073572, 0074572, 0040502, 0041504, 0042506,
0043510, 0044512, 0045514, 0046516, 0047520, 0050522, 0051524, 0052526,
0053530, 0054532, 0030061, 0031063, 0032065, 0033012
'''
        ]
        for input, output in zip(self.inputs, outputs):
            common.validate(input, output)
Example #31
0
    def test_o4_2(self):
        # Block of lines to Octal-4.
        common.request('../o4')
        input = ''.join(self.inputs)
        output = '''\
001230205141, 014202460542, 014302460542, 014331005141,
014230662145, 014631664151, 001230261143, 014431263147,
015032265153, 015433267157, 016034271163, 001230261143,
014431263147, 015032265153, 015433267157, 016034271163,
016435273167, 017236275101, 010220605141, 014230662145,
014631664151, 015232666155, 015633670161, 016234672165,
016635675171, 017220241103, 010421243107, 011022245113,
011423205141, 014230662145, 014631664151, 015232666155,
015633670161, 016234672165, 016635675171, 017220241103,
010421243107, 011022245113, 011423247117, 012024251123,
012425253127, 001230261143, 014431263147, 015032265153,
015433267157, 016034271163, 016435273167, 017236275101,
010220642105, 010621644111, 011222646115, 011623650121,
012224652125, 012625654131, 013214030462, 006315032466,
0012
'''
        common.validate(input, output)
Example #32
0
    def test_o2_2(self):
        # Block of lines to Octal-2.
        common.request('../o2')
        input = ''.join(self.inputs)
        output = '''\
0005141, 0005141, 0061012, 0060542, 0061412, 0060542, 0061544, 0005141,
0061143, 0062145, 0063147, 0064151, 0005141, 0061143, 0062145, 0063147,
0064151, 0065153, 0066155, 0067157, 0070161, 0071163, 0005141, 0061143,
0062145, 0063147, 0064151, 0065153, 0066155, 0067157, 0070161, 0071163,
0072165, 0073167, 0075171, 0075101, 0041103, 0005141, 0061143, 0062145,
0063147, 0064151, 0065153, 0066155, 0067157, 0070161, 0071163, 0072165,
0073167, 0075171, 0075101, 0041103, 0042105, 0043107, 0044111, 0045113,
0046115, 0005141, 0061143, 0062145, 0063147, 0064151, 0065153, 0066155,
0067157, 0070161, 0071163, 0072165, 0073167, 0075171, 0075101, 0041103,
0042105, 0043107, 0044111, 0045113, 0046115, 0047117, 0050121, 0051123,
0052125, 0053127, 0005141, 0061143, 0062145, 0063147, 0064151, 0065153,
0066155, 0067157, 0070161, 0071163, 0072165, 0073167, 0075171, 0075101,
0041103, 0042105, 0043107, 0044111, 0045113, 0046115, 0047117, 0050121,
0051123, 0052125, 0053127, 0054131, 0055060, 0030462, 0031464, 0032466,
0012
'''
        common.validate(input, output)
Example #33
0
    def test_d1_2(self):
        # Block of lines to Decimal-1.
        common.request('../d1')
        input = ''.join(self.inputs)
        output = '''\
 10,  97,  10,  97,  98,  10,  97,  98,  99,  10,  97,  98,  99, 100,  10,
 97,  98,  99, 100, 101, 102, 103, 104, 105,  10,  97,  98,  99, 100, 101,
102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,  10,
 97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122,  65,  66,  67,  10,
 97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122,  65,  66,  67,  68,
 69,  70,  71,  72,  73,  74,  75,  76,  77,  10,  97,  98,  99, 100, 101,
102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
117, 118, 119, 122, 121, 122,  65,  66,  67,  68,  69,  70,  71,  72,  73,
 74,  75,  76,  77,  78,  79,  80,  81,  82,  83,  84,  85,  86,  87,  10,
 97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122,  65,  66,  67,  68,
 69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,  80,  81,  82,  83,
 84,  85,  86,  87,  88,  89,  90,  48,  49,  50,  51,  52,  53,  54,  10
'''
        common.validate(input, output)
Example #34
0
    def test_o2_2(self):
        # Block of lines to Octal-2.
        common.request('../o2')
        input = ''.join(self.inputs)
        output = '''\
0005141, 0005141, 0061012, 0060542, 0061412, 0060542, 0061544, 0005141,
0061143, 0062145, 0063147, 0064151, 0005141, 0061143, 0062145, 0063147,
0064151, 0065153, 0066155, 0067157, 0070161, 0071163, 0005141, 0061143,
0062145, 0063147, 0064151, 0065153, 0066155, 0067157, 0070161, 0071163,
0072165, 0073167, 0075171, 0075101, 0041103, 0005141, 0061143, 0062145,
0063147, 0064151, 0065153, 0066155, 0067157, 0070161, 0071163, 0072165,
0073167, 0075171, 0075101, 0041103, 0042105, 0043107, 0044111, 0045113,
0046115, 0005141, 0061143, 0062145, 0063147, 0064151, 0065153, 0066155,
0067157, 0070161, 0071163, 0072165, 0073167, 0075171, 0075101, 0041103,
0042105, 0043107, 0044111, 0045113, 0046115, 0047117, 0050121, 0051123,
0052125, 0053127, 0005141, 0061143, 0062145, 0063147, 0064151, 0065153,
0066155, 0067157, 0070161, 0071163, 0072165, 0073167, 0075171, 0075101,
0041103, 0042105, 0043107, 0044111, 0045113, 0046115, 0047117, 0050121,
0051123, 0052125, 0053127, 0054131, 0055060, 0030462, 0031464, 0032466,
0012
'''
        common.validate(input, output)
Example #35
0
    def test_d1_2(self):
        # Block of lines to Decimal-1.
        common.request('../d1')
        input = ''.join(self.inputs)
        output = '''\
 10,  97,  10,  97,  98,  10,  97,  98,  99,  10,  97,  98,  99, 100,  10,
 97,  98,  99, 100, 101, 102, 103, 104, 105,  10,  97,  98,  99, 100, 101,
102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,  10,
 97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122,  65,  66,  67,  10,
 97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122,  65,  66,  67,  68,
 69,  70,  71,  72,  73,  74,  75,  76,  77,  10,  97,  98,  99, 100, 101,
102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
117, 118, 119, 122, 121, 122,  65,  66,  67,  68,  69,  70,  71,  72,  73,
 74,  75,  76,  77,  78,  79,  80,  81,  82,  83,  84,  85,  86,  87,  10,
 97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122,  65,  66,  67,  68,
 69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,  80,  81,  82,  83,
 84,  85,  86,  87,  88,  89,  90,  48,  49,  50,  51,  52,  53,  54,  10
'''
        common.validate(input, output)
Example #36
0
    def test_o4_2(self):
        # Block of lines to Octal-4.
        common.request('../o4')
        input = ''.join(self.inputs)
        output = '''\
001230205141, 014202460542, 014302460542, 014331005141,
014230662145, 014631664151, 001230261143, 014431263147,
015032265153, 015433267157, 016034271163, 001230261143,
014431263147, 015032265153, 015433267157, 016034271163,
016435273167, 017236275101, 010220605141, 014230662145,
014631664151, 015232666155, 015633670161, 016234672165,
016635675171, 017220241103, 010421243107, 011022245113,
011423205141, 014230662145, 014631664151, 015232666155,
015633670161, 016234672165, 016635675171, 017220241103,
010421243107, 011022245113, 011423247117, 012024251123,
012425253127, 001230261143, 014431263147, 015032265153,
015433267157, 016034271163, 016435273167, 017236275101,
010220642105, 010621644111, 011222646115, 011623650121,
012224652125, 012625654131, 013214030462, 006315032466,
0012
'''
        common.validate(input, output)
Example #37
0
    def test_x2_2(self):
        # Block of lines to Hexadecimal-2.
        common.request('../x2')
        input = ''.join(self.inputs)
        output = '''\
0x0A61, 0x0A61, 0x620A, 0x6162, 0x630A, 0x6162, 0x6364, 0x0A61,
0x6263, 0x6465, 0x6667, 0x6869, 0x0A61, 0x6263, 0x6465, 0x6667,
0x6869, 0x6A6B, 0x6C6D, 0x6E6F, 0x7071, 0x7273, 0x0A61, 0x6263,
0x6465, 0x6667, 0x6869, 0x6A6B, 0x6C6D, 0x6E6F, 0x7071, 0x7273,
0x7475, 0x7677, 0x7A79, 0x7A41, 0x4243, 0x0A61, 0x6263, 0x6465,
0x6667, 0x6869, 0x6A6B, 0x6C6D, 0x6E6F, 0x7071, 0x7273, 0x7475,
0x7677, 0x7A79, 0x7A41, 0x4243, 0x4445, 0x4647, 0x4849, 0x4A4B,
0x4C4D, 0x0A61, 0x6263, 0x6465, 0x6667, 0x6869, 0x6A6B, 0x6C6D,
0x6E6F, 0x7071, 0x7273, 0x7475, 0x7677, 0x7A79, 0x7A41, 0x4243,
0x4445, 0x4647, 0x4849, 0x4A4B, 0x4C4D, 0x4E4F, 0x5051, 0x5253,
0x5455, 0x5657, 0x0A61, 0x6263, 0x6465, 0x6667, 0x6869, 0x6A6B,
0x6C6D, 0x6E6F, 0x7071, 0x7273, 0x7475, 0x7677, 0x7A79, 0x7A41,
0x4243, 0x4445, 0x4647, 0x4849, 0x4A4B, 0x4C4D, 0x4E4F, 0x5051,
0x5253, 0x5455, 0x5657, 0x5859, 0x5A30, 0x3132, 0x3334, 0x3536,
0x0A
'''
        common.validate(input, output)
Example #38
0
    def test_x2_2(self):
        # Block of lines to Hexadecimal-2.
        common.request('../x2')
        input = ''.join(self.inputs)
        output = '''\
0x0A61, 0x0A61, 0x620A, 0x6162, 0x630A, 0x6162, 0x6364, 0x0A61,
0x6263, 0x6465, 0x6667, 0x6869, 0x0A61, 0x6263, 0x6465, 0x6667,
0x6869, 0x6A6B, 0x6C6D, 0x6E6F, 0x7071, 0x7273, 0x0A61, 0x6263,
0x6465, 0x6667, 0x6869, 0x6A6B, 0x6C6D, 0x6E6F, 0x7071, 0x7273,
0x7475, 0x7677, 0x7A79, 0x7A41, 0x4243, 0x0A61, 0x6263, 0x6465,
0x6667, 0x6869, 0x6A6B, 0x6C6D, 0x6E6F, 0x7071, 0x7273, 0x7475,
0x7677, 0x7A79, 0x7A41, 0x4243, 0x4445, 0x4647, 0x4849, 0x4A4B,
0x4C4D, 0x0A61, 0x6263, 0x6465, 0x6667, 0x6869, 0x6A6B, 0x6C6D,
0x6E6F, 0x7071, 0x7273, 0x7475, 0x7677, 0x7A79, 0x7A41, 0x4243,
0x4445, 0x4647, 0x4849, 0x4A4B, 0x4C4D, 0x4E4F, 0x5051, 0x5253,
0x5455, 0x5657, 0x0A61, 0x6263, 0x6465, 0x6667, 0x6869, 0x6A6B,
0x6C6D, 0x6E6F, 0x7071, 0x7273, 0x7475, 0x7677, 0x7A79, 0x7A41,
0x4243, 0x4445, 0x4647, 0x4849, 0x4A4B, 0x4C4D, 0x4E4F, 0x5051,
0x5253, 0x5455, 0x5657, 0x5859, 0x5A30, 0x3132, 0x3334, 0x3536,
0x0A
'''
        common.validate(input, output)
Example #39
0
    def test_o2_1(self):
        # Single lines to Octal-2.
        common.request('../o2')
        outputs = ['''\
0012
''', '''\
0060412
''', '''\
0060542, 0012
''', '''\
0060542, 0061412
''', '''\
0060542, 0061544, 0012
''', '''\
0060542, 0061544, 0062546, 0063550, 0064412
''', '''\
0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560,
0070562, 0071412
''', '''\
0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560,
0070562, 0071564, 0072566, 0073572, 0074572, 0040502, 0041412
''', '''\
0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560,
0070562, 0071564, 0072566, 0073572, 0074572, 0040502, 0041504, 0042506,
0043510, 0044512, 0045514, 0046412
''', '''\
0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560,
0070562, 0071564, 0072566, 0073572, 0074572, 0040502, 0041504, 0042506,
0043510, 0044512, 0045514, 0046516, 0047520, 0050522, 0051524, 0052526,
0053412
''', '''\
0060542, 0061544, 0062546, 0063550, 0064552, 0065554, 0066556, 0067560,
0070562, 0071564, 0072566, 0073572, 0074572, 0040502, 0041504, 0042506,
0043510, 0044512, 0045514, 0046516, 0047520, 0050522, 0051524, 0052526,
0053530, 0054532, 0030061, 0031063, 0032065, 0033012
''']
        for input, output in zip(self.inputs, outputs):
            common.validate(input, output)
Example #40
0
    def test_o4_1(self):
        # Single lines to Octal-4.
        common.request('../o4')
        outputs = ['''\
0012
''', '''\
0060412
''', '''\
030261012
''', '''\
014130461412
''', '''\
014130461544, 0012
''', '''\
014130461544, 014531463550, 0064412
''', '''\
014130461544, 014531463550, 015132465554, 015533467560,
016134471412
''', '''\
014130461544, 014531463550, 015132465554, 015533467560,
016134471564, 016535473572, 017136440502, 0041412
''', '''\
014130461544, 014531463550, 015132465554, 015533467560,
016134471564, 016535473572, 017136440502, 010321042506,
010722044512, 011323046412
''', '''\
014130461544, 014531463550, 015132465554, 015533467560,
016134471564, 016535473572, 017136440502, 010321042506,
010722044512, 011323046516, 011724050522, 012325052526,
0053412
''', '''\
014130461544, 014531463550, 015132465554, 015533467560,
016134471564, 016535473572, 017136440502, 010321042506,
010722044512, 011323046516, 011724050522, 012325052526,
012726054532, 006014231063, 006415233012
''']
        for input, output in zip(self.inputs, outputs):
            common.validate(input, output)
Example #41
0
    def test_d1_1(self):
        # Single lines to Decimal-1.
        common.request('../d1')
        outputs = ['''\
 10
''', '''\
 97,  10
''', '''\
 97,  98,  10
''', '''\
 97,  98,  99,  10
''', '''\
 97,  98,  99, 100,  10
''', '''\
 97,  98,  99, 100, 101, 102, 103, 104, 105,  10
''', '''\
 97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115,  10
''', '''\
 97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122,  65,  66,  67,  10
''', '''\
 97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122,  65,  66,  67,  68,
 69,  70,  71,  72,  73,  74,  75,  76,  77,  10
''', '''\
 97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122,  65,  66,  67,  68,
 69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,  80,  81,  82,  83,
 84,  85,  86,  87,  10
''', '''\
 97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 122, 121, 122,  65,  66,  67,  68,
 69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,  80,  81,  82,  83,
 84,  85,  86,  87,  88,  89,  90,  48,  49,  50,  51,  52,  53,  54,  10
''']
        for input, output in zip(self.inputs, outputs):
            common.validate(input, output)
Example #42
0
    def test_x2_1(self):
        # Single lines to Hexadecimal-2.
        common.request('../x2')
        outputs = ['''\
0x0A
''', '''\
0x610A
''', '''\
0x6162, 0x0A
''', '''\
0x6162, 0x630A
''', '''\
0x6162, 0x6364, 0x0A
''', '''\
0x6162, 0x6364, 0x6566, 0x6768, 0x690A
''', '''\
0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70,
0x7172, 0x730A
''', '''\
0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70,
0x7172, 0x7374, 0x7576, 0x777A, 0x797A, 0x4142, 0x430A
''', '''\
0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70,
0x7172, 0x7374, 0x7576, 0x777A, 0x797A, 0x4142, 0x4344, 0x4546,
0x4748, 0x494A, 0x4B4C, 0x4D0A
''', '''\
0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70,
0x7172, 0x7374, 0x7576, 0x777A, 0x797A, 0x4142, 0x4344, 0x4546,
0x4748, 0x494A, 0x4B4C, 0x4D4E, 0x4F50, 0x5152, 0x5354, 0x5556,
0x570A
''', '''\
0x6162, 0x6364, 0x6566, 0x6768, 0x696A, 0x6B6C, 0x6D6E, 0x6F70,
0x7172, 0x7374, 0x7576, 0x777A, 0x797A, 0x4142, 0x4344, 0x4546,
0x4748, 0x494A, 0x4B4C, 0x4D4E, 0x4F50, 0x5152, 0x5354, 0x5556,
0x5758, 0x595A, 0x3031, 0x3233, 0x3435, 0x360A
''']
        for input, output in zip(self.inputs, outputs):
            common.validate(input, output)
Example #43
0
    def test_d2_1(self):
        # Single lines to Decimal-2.
        common.request('../d2')
        outputs = [
            '''\
 10
''', '''\
24842
''', '''\
24930,  10
''', '''\
24930, 25354
''', '''\
24930, 25444,  10
''', '''\
24930, 25444, 25958, 26472, 26890
''', '''\
24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29450
''', '''\
24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29556,
30070, 30586, 31098, 16706, 17162
''', '''\
24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29556,
30070, 30586, 31098, 16706, 17220, 17734, 18248, 18762, 19276, 19722
''', '''\
24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29556,
30070, 30586, 31098, 16706, 17220, 17734, 18248, 18762, 19276, 19790,
20304, 20818, 21332, 21846, 22282
''', '''\
24930, 25444, 25958, 26472, 26986, 27500, 28014, 28528, 29042, 29556,
30070, 30586, 31098, 16706, 17220, 17734, 18248, 18762, 19276, 19790,
20304, 20818, 21332, 21846, 22360, 22874, 12337, 12851, 13365, 13834
'''
        ]
        for input, output in zip(self.inputs, outputs):
            common.validate(input, output)
Example #44
0
    def test_x4_1(self):
        # Single lines to Hexadecimal-4.
        common.request('../x4')
        outputs = [
            '''\
0x0A
''', '''\
0x610A
''', '''\
0x61620A
''', '''\
0x6162630A
''', '''\
0x61626364, 0x0A
''', '''\
0x61626364, 0x65666768, 0x690A
''', '''\
0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x7172730A
''', '''\
0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x71727374, 0x7576777A,
0x797A4142, 0x430A
''', '''\
0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x71727374, 0x7576777A,
0x797A4142, 0x43444546, 0x4748494A, 0x4B4C4D0A
''', '''\
0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x71727374, 0x7576777A,
0x797A4142, 0x43444546, 0x4748494A, 0x4B4C4D4E, 0x4F505152, 0x53545556,
0x570A
''', '''\
0x61626364, 0x65666768, 0x696A6B6C, 0x6D6E6F70, 0x71727374, 0x7576777A,
0x797A4142, 0x43444546, 0x4748494A, 0x4B4C4D4E, 0x4F505152, 0x53545556,
0x5758595A, 0x30313233, 0x3435360A
'''
        ]
        for input, output in zip(self.inputs, outputs):
            common.validate(input, output)
Example #45
0
    def test_d4_1(self):
        # Single lines to Decimal-4.
        common.request('../d4')
        outputs = [
            '''\
 10
''', '''\
24842
''', '''\
 6382090
''', '''\
1633837834
''', '''\
1633837924,  10
''', '''\
1633837924, 1701209960, 26890
''', '''\
1633837924, 1701209960, 1768581996, 1835954032, 1903325962
''', '''\
1633837924, 1701209960, 1768581996, 1835954032, 1903326068,
1970698106, 2038055234, 17162
''', '''\
1633837924, 1701209960, 1768581996, 1835954032, 1903326068,
1970698106, 2038055234, 1128547654, 1195919690, 1263291658
''', '''\
1633837924, 1701209960, 1768581996, 1835954032, 1903326068,
1970698106, 2038055234, 1128547654, 1195919690, 1263291726,
1330663762, 1398035798, 22282
''', '''\
1633837924, 1701209960, 1768581996, 1835954032, 1903326068,
1970698106, 2038055234, 1128547654, 1195919690, 1263291726,
1330663762, 1398035798, 1465407834,  808530483,  875902474
'''
        ]
        for input, output in zip(self.inputs, outputs):
            common.validate(input, output)
Example #46
0
def get_input_for_sold_between():
    """
    Provides input data for get_items_sold_between function

    Args:
        None

    Returns:
        list which contains dates for get_items_sold_between function purpose
    """
    title_list = ["Year from", "Month from", "Day from", "Year to", "Month to", "Day to"]
    title = "Please input desired time range"
    type_list = ["int", "month", "day", "int", "month", "day"]
    inputs = ui.get_inputs(title_list, title)
    inputs = common.validate(inputs, title_list, type_list)
    return inputs
Example #47
0
def test_validate_message_wrong_report_attributes(validation_schema, verbose,
                                                  correct_message, attribute):
    """Test the validation for improper payload."""
    correct_message["report"][0][attribute] = b"foobar"
    # it should fail
    with pytest.raises(Invalid) as excinfo:
        validate(schema, correct_message, verbose)

    # check with number
    correct_message["report"][0][attribute] = -123456
    # it should fail
    with pytest.raises(Invalid) as excinfo:
        validate(schema, correct_message, verbose)

    # check with different data type
    correct_message["report"][0][attribute] = None
    # it should fail
    with pytest.raises(Invalid) as excinfo:
        validate(schema, correct_message, verbose)
Example #48
0
def main():
    global best_acc

    args.out = args.dataset + '@N_' + str(args.num_max) + '_r_'
    if args.imb_ratio_l == args.imb_ratio_u:
        args.out += str(args.imb_ratio_l) + '_' + args.semi_method
    else:
        args.out += str(args.imb_ratio_l) + '_' + str(
            args.imb_ratio_u) + '_' + args.semi_method

    if args.darp:
        args.out += '_darp_alpha' + str(args.alpha) + '_iterT' + str(
            args.iter_T)

    if not os.path.isdir(args.out):
        mkdir_p(args.out)

    # Data
    N_SAMPLES_PER_CLASS = make_imb_data(args.num_max, args.num_class,
                                        args.imb_ratio_l)
    U_SAMPLES_PER_CLASS = make_imb_data(args.ratio * args.num_max,
                                        args.num_class, args.imb_ratio_u)
    N_SAMPLES_PER_CLASS_T = torch.Tensor(N_SAMPLES_PER_CLASS)

    print(args.out)

    if args.dataset == 'cifar10':
        print(f'==> Preparing imbalanced CIFAR-10')
        train_labeled_set, train_unlabeled_set, test_set = get_cifar10(
            '/home/jaehyung/data', N_SAMPLES_PER_CLASS, U_SAMPLES_PER_CLASS,
            args.out)
    elif args.dataset == 'stl10':
        print(f'==> Preparing imbalanced STL-10')
        train_labeled_set, train_unlabeled_set, test_set = get_stl10(
            '/home/jaehyung/data', N_SAMPLES_PER_CLASS, args.out)
    elif args.dataset == 'cifar100':
        print(f'==> Preparing imbalanced CIFAR-100')
        train_labeled_set, train_unlabeled_set, test_set = get_cifar100(
            '/home/jaehyung/data', N_SAMPLES_PER_CLASS, U_SAMPLES_PER_CLASS,
            args.out)
    labeled_trainloader = data.DataLoader(train_labeled_set,
                                          batch_size=args.batch_size,
                                          shuffle=True,
                                          num_workers=4,
                                          drop_last=True)
    unlabeled_trainloader = data.DataLoader(train_unlabeled_set,
                                            batch_size=args.batch_size,
                                            shuffle=True,
                                            num_workers=4,
                                            drop_last=True)
    test_loader = data.DataLoader(test_set,
                                  batch_size=args.batch_size,
                                  shuffle=False,
                                  num_workers=4)

    # Model
    print("==> creating WRN-28-2")

    def create_model(ema=False):
        model = models.WRN(2, args.num_class)
        model = model.cuda()

        if ema:
            for param in model.parameters():
                param.detach_()

        return model

    model = create_model()
    ema_model = create_model(ema=True)

    cudnn.benchmark = True
    print('    Total params: %.2fM' %
          (sum(p.numel() for p in model.parameters()) / 1000000.0))

    train_criterion = SemiLoss()
    criterion = nn.CrossEntropyLoss()
    optimizer = optim.Adam(model.parameters(), lr=args.lr)
    ema_optimizer = WeightEMA(model,
                              ema_model,
                              lr=args.lr,
                              alpha=args.ema_decay)
    start_epoch = 0

    # Resume
    title = 'Imbalanced' + '-' + args.dataset + '-' + args.semi_method
    if args.resume:
        # Load checkpoint.
        print('==> Resuming from checkpoint..')
        assert os.path.isfile(
            args.resume), 'Error: no checkpoint directory found!'
        args.out = os.path.dirname(args.resume)
        checkpoint = torch.load(args.resume)
        start_epoch = checkpoint['epoch']
        model.load_state_dict(checkpoint['state_dict'])
        ema_model.load_state_dict(checkpoint['ema_state_dict'])
        optimizer.load_state_dict(checkpoint['optimizer'])
        logger = Logger(os.path.join(args.out, 'log.txt'),
                        title=title,
                        resume=True)
    else:
        logger = Logger(os.path.join(args.out, 'log.txt'), title=title)
        logger.set_names([
            'Train Loss', 'Train Loss X', 'Train Loss U', 'Test Loss',
            'Test Acc.', 'Test GM.'
        ])

    test_accs = []
    test_gms = []

    # Default values for MixMatch and DARP
    emp_distb_u = torch.ones(args.num_class) / args.num_class
    pseudo_orig = torch.ones(len(train_unlabeled_set.data),
                             args.num_class) / args.num_class
    pseudo_refine = torch.ones(len(train_unlabeled_set.data),
                               args.num_class) / args.num_class

    # Main function
    for epoch in range(start_epoch, args.epochs):
        print('\nEpoch: [%d | %d] LR: %f' %
              (epoch + 1, args.epochs, state['lr']))

        # Use the estimated distribution of unlabeled data
        if args.est:
            if args.dataset == 'cifar10':
                est_name = './estimation/cifar10@N_1500_r_{}_{}_estim.npy'.format(
                    args.imb_ratio_l, args.imb_ratio_u)
            else:
                est_name = './estimation/stl10@N_450_r_{}_estim.npy'.format(
                    args.imb_ratio_l)
            est_disb = np.load(est_name)
            target_disb = len(train_unlabeled_set.data) * torch.Tensor(
                est_disb) / np.sum(est_disb)
        # Use the inferred distribution with labeled data
        else:
            target_disb = N_SAMPLES_PER_CLASS_T * len(
                train_unlabeled_set.data) / sum(N_SAMPLES_PER_CLASS)

        train_loss, train_loss_x, train_loss_u, emp_distb_u, pseudo_orig, pseudo_refine = trains(
            args, labeled_trainloader, unlabeled_trainloader, model, optimizer,
            ema_optimizer, train_criterion, epoch, use_cuda, target_disb,
            emp_distb_u, pseudo_orig, pseudo_refine)

        # Evaluation part
        test_loss, test_acc, test_cls, test_gm = validate(
            test_loader,
            ema_model,
            criterion,
            use_cuda,
            mode='Test Stats',
            num_class=args.num_class)

        # Append logger file
        logger.append([
            train_loss, train_loss_x, train_loss_u, test_loss, test_acc,
            test_gm
        ])

        # Save models
        save_checkpoint(
            {
                'epoch': epoch + 1,
                'state_dict': model.state_dict(),
                'ema_state_dict': ema_model.state_dict(),
                'optimizer': optimizer.state_dict(),
            }, epoch + 1, args.out)
        test_accs.append(test_acc)
        test_gms.append(test_gm)

    logger.close()

    # Print the final results
    print('Mean bAcc:')
    print(np.mean(test_accs[-20:]))

    print('Mean GM:')
    print(np.mean(test_gms[-20:]))

    print('Name of saved folder:')
    print(args.out)
Example #49
0
 def test_2(self):
     common.request('../,t-bambara/64..bambara/qp')
     common.validate(self.output, self.input)
Example #50
0
 def test_1(self):
     common.request('../,wolof/qp..t-wolof/64')
     common.validate(self.input, self.output)
Example #51
0
 def test_1(self):
     # Block of lines to Java.
     common.request('l1/qp..java')
     common.validate(input, output)
Example #52
0
 def test_1(self):
     common.request('../,bambara/qp..t-bambara/64')
     common.validate(self.input, self.output)
Example #53
0
 def test_2(self):
     common.request('../,t-wolof/64..wolof/qp')
     common.validate(self.output, self.input)
Example #54
0
 def test_1(self):
     common.request('../,fulfulde/qp..t-fulfulde/64')
     common.validate(self.input, self.output)
Example #55
0
 def test_2(self):
     common.request ('../,t-fulfulde/64..fulfulde/qp')
     common.validate(self.output, self.input)
Example #56
0
 def test_1(self):
     common.request('../,lingala/qp..t-lingala/64')
     common.validate(self.input, self.output)
Example #57
0
 def test_2(self):
     common.request('../,t-lingala/64..lingala/qp')
     common.validate(self.output, self.input)
Example #58
0
 def test_1(self):
     common.request('test16..x2,us..count')
     common.validate('', self.output)