예제 #1
0
파일: test_encoder.py 프로젝트: heuer/segno
def test_thonky_pattern_2():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-2')
    matrix_size = len(matrix)
    assert 206 == encoder.score_n1(matrix, matrix_size)
    assert 141 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 160
    assert 800 == encoder.score_n3(matrix, matrix_size)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    assert 507 - 160 + 800 == encoder.evaluate_mask(matrix, matrix_size)
예제 #2
0
def test_thonky_pattern_2():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-2')
    matrix_size = len(matrix)
    assert 206 == encoder.score_n1(matrix, matrix_size)
    assert 141 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 160
    assert 800 == encoder.score_n3(matrix, matrix_size)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    assert 507 - 160 + 800 == encoder.evaluate_mask(matrix, matrix_size)
예제 #3
0
def test_thonky_pattern_3():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-3')
    matrix_size = len(matrix)
    assert 180 == encoder.score_n1(matrix, matrix_size)
    assert 141 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 120
    assert 760 == encoder.score_n3(matrix, matrix_size)
    # Thonky: 2, but that's impossible: Either 0 or a multiple of 10 (N4 = 10)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    assert 443 - 2 - 120 + 760 == encoder.evaluate_mask(matrix, matrix_size)
예제 #4
0
def test_thonky_pattern_1():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-1')
    matrix_size = len(matrix)
    assert 172 == encoder.score_n1(matrix, matrix_size)
    assert 129 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 120
    assert 760 == encoder.score_n3(matrix, matrix_size)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3
    assert 421 - 120 + 760 == encoder.evaluate_mask(matrix, matrix_size)
예제 #5
0
def test_thonky_pattern_0():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-0')
    matrix_size = len(matrix)
    assert 180 == encoder.score_n1(matrix, matrix_size)
    assert 90 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 80
    assert 760 == encoder.score_n3(matrix, matrix_size)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3
    assert 350 - 80 + 760 == encoder.evaluate_mask(matrix, matrix_size)
예제 #6
0
파일: test_encoder.py 프로젝트: heuer/segno
def test_thonky_pattern_0():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-0')
    matrix_size = len(matrix)
    assert 180 == encoder.score_n1(matrix, matrix_size)
    assert 90 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 80
    assert 760 == encoder.score_n3(matrix, matrix_size)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3
    assert 350 - 80 + 760 == encoder.evaluate_mask(matrix, matrix_size)
예제 #7
0
파일: test_encoder.py 프로젝트: heuer/segno
def test_thonky_pattern_7():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-7')
    matrix_size = len(matrix)
    assert 197 == encoder.score_n1(matrix, matrix_size)
    assert 123 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 200
    assert 720 == encoder.score_n3(matrix, matrix_size)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3
    assert 520 - 200 + 720 == encoder.evaluate_mask(matrix, matrix_size)
예제 #8
0
파일: test_encoder.py 프로젝트: heuer/segno
def test_thonky_pattern_3():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-3')
    matrix_size = len(matrix)
    assert 180 == encoder.score_n1(matrix, matrix_size)
    assert 141 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 120
    assert 760 == encoder.score_n3(matrix, matrix_size)
    # Thonky: 2, but that's impossible: Either 0 or a multiple of 10 (N4 = 10)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    assert 443 - 2 - 120 + 760 == encoder.evaluate_mask(matrix, matrix_size)
예제 #9
0
파일: test_encoder.py 프로젝트: heuer/segno
def test_thonky_pattern_1():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-1')
    matrix_size = len(matrix)
    assert 172 == encoder.score_n1(matrix, matrix_size)
    assert 129 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 120
    assert 760 == encoder.score_n3(matrix, matrix_size)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3
    assert 421 - 120 + 760 == encoder.evaluate_mask(matrix, matrix_size)
예제 #10
0
def test_thonky_pattern_7():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-7')
    matrix_size = len(matrix)
    assert 197 == encoder.score_n1(matrix, matrix_size)
    assert 123 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 200
    assert 720 == encoder.score_n3(matrix, matrix_size)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3
    assert 520 - 200 + 720 == encoder.evaluate_mask(matrix, matrix_size)
예제 #11
0
def test_thonky_pattern_6():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-6')
    matrix_size = len(matrix)
    assert 171 == encoder.score_n1(matrix, matrix_size)
    assert 102 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 80
    assert 840 == encoder.score_n3(matrix, matrix_size)
    # Thonky: 4, but that's impossible: Either 0 or a multiple of 10 (N4 = 10)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3 and 4
    assert 357 - 4 - 80 + 840 == encoder.evaluate_mask(matrix, matrix_size)
예제 #12
0
def test_thonky_pattern_5():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-5')
    matrix_size = len(matrix)
    assert 189 == encoder.score_n1(matrix, matrix_size)
    assert 156 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 200
    assert 800 == encoder.score_n3(matrix, matrix_size)
    # Thonky: 2, but that's impossible: Either 0 or a multiple of 10 (N4 = 10)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3 and 4
    assert 547 - 2 - 200 + 800 == encoder.evaluate_mask(matrix, matrix_size)
예제 #13
0
파일: test_encoder.py 프로젝트: heuer/segno
def test_thonky_pattern_6():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-6')
    matrix_size = len(matrix)
    assert 171 == encoder.score_n1(matrix, matrix_size)
    assert 102 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 80
    assert 840 == encoder.score_n3(matrix, matrix_size)
    # Thonky: 4, but that's impossible: Either 0 or a multiple of 10 (N4 = 10)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3 and 4
    assert 357 - 4 - 80 + 840 == encoder.evaluate_mask(matrix, matrix_size)
예제 #14
0
파일: test_encoder.py 프로젝트: heuer/segno
def test_thonky_pattern_5():
    # http://www.thonky.com/qr-code-tutorial/data-masking
    matrix = read_matrix('thonky_datamasking_mask-5')
    matrix_size = len(matrix)
    assert 189 == encoder.score_n1(matrix, matrix_size)
    assert 156 == encoder.score_n2(matrix, matrix_size)
    # Thonky: 200
    assert 800 == encoder.score_n3(matrix, matrix_size)
    # Thonky: 2, but that's impossible: Either 0 or a multiple of 10 (N4 = 10)
    assert 0 == encoder.score_n4(matrix, matrix_size)
    # See score 3 and 4
    assert 547 - 2 - 200 + 800 == encoder.evaluate_mask(matrix, matrix_size)
예제 #15
0
파일: test_encoder.py 프로젝트: heuer/segno
def test_score_n1_iso():
    # For example, impose 5 penalty points on the block of “dark:dark:dark:dark:dark:dark:dark”
    # module pattern, where a series of seven consecutive modules is counted as one block
    matrix = tuple(bytearray([1] * 7) for i in range(7))
    score = encoder.score_n1(matrix, len(matrix))
    assert 5 * 7 * 2 == score
예제 #16
0
def test_score_n1():
    matrix, matrix_size = make_thonky_score_matrix()
    score = encoder.score_n1(matrix, matrix_size)
    assert 180 == score
예제 #17
0
def test_score_n1_iso():
    # For example, impose 5 penalty points on the block of “dark:dark:dark:dark:dark:dark:dark”
    # module pattern, where a series of seven consecutive modules is counted as one block
    matrix = tuple(bytearray([1] * 7) for i in range(7))
    score = encoder.score_n1(matrix, len(matrix))
    assert 5 * 7 * 2 == score
예제 #18
0
파일: test_encoder.py 프로젝트: heuer/segno
def test_score_n1():
    matrix, matrix_size = make_thonky_score_matrix()
    score = encoder.score_n1(matrix, matrix_size)
    assert 180 == score