<commit_before>import pexpect
import os

count = 0

def printline():
	x = ''
	for i in range(80):
		x = x + "="
	print x

def singleTest(send, ansExp):
	global count

	child = pexpect.spawn('./p014')
	child.sendline('1')
	child.expect('1')
	child.sendline(send)
	child.expect(send)

	child.expect('[0-9]+')
	ansGot = child.match.group()
	printline()
	count = count + 1
	print "Test number: " + str(count)
	print "Test input : " + send
	print "Expected Answer : " + ansExp
	print "Got this Answer : " + ansGot
	if (ansExp != ansGot):
		raise Exception('Test failed')
	#print ans


def smallDigitTests():
	singleTest('99', '99')
	singleTest('91', '99')
	singleTest('29', '33')
	singleTest('23', '33')
	singleTest('31', '33')

	singleTest('111', '111')
	singleTest('110', '111')
	singleTest('292', '292')
	singleTest('203', '212')
	singleTest('209', '212')

	singleTest('131231234', '131232131')
	singleTest('1991', '1991')
	singleTest('1981', '1991')
	singleTest('1891', '1991')

	singleTest('28994', '29092')
	singleTest('29994', '30003')


def largeDigitTest1():
	n1 = ''
	n2 = ''
	for i in range(100):
		n1 = n1 + '1'
		n2 = n2 + '9'
	singleTest(n1, n1)
	singleTest(n2, n2)

	n3 = "2211111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
	n4 = "2211111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111122"
	singleTest(n3, n4)
	n5 = "8899999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
	n6 = "8900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000098";
	singleTest(n5, n6)
	n7 = "890000000000000000000000000000123000000000000000000000000000000000000000000000000000000000000000000098"
	n8 = "890000000000000000000000000000123000000000000000000000000000000000000321000000000000000000000000000098"
	singleTest(n7, n8)

def runTests():
	smallDigitTests()
	largeDigitTest1()

def compileP014():
	ret = os.system('gcc -g -Wall p014_5.c -o p014')
	if (ret != 0):
		raise Exception("Did not compile")

def cleanup():
	os.system('rm p014')

def testP014():
	compileP014()
	runTests()
	cleanup()


testP014()
<commit_msg>Commit<commit_after>import pexpect
import os

count = 0

def printline():
	x = ''
	for i in range(80):
		x = x + "="
	print x

def singleTest(send, ansExp):
	global count

	child = pexpect.spawn('./p014', maxread=10000)
	child.sendline('1')
	child.expect('1')
	child.sendline(send)
	child.expect(send)

	pattern = '[0-9]{%d}' %(len(send))
	print "Expecting %s" %pattern
	child.expect(pattern)
	ansGot = child.match.group()
	printline()
	count = count + 1
	print "Test number: " + str(count)
	print "Test input : " + send
	print "Expected Answer : " + ansExp
	print "Got this Answer : " + ansGot
	if (ansExp != ansGot):
		raise Exception('Test failed')
	#print ans


def smallDigitTests():
	singleTest('99', '99')
	singleTest('91', '99')
	singleTest('29', '33')
	singleTest('23', '33')
	singleTest('31', '33')

	singleTest('111', '111')
	singleTest('110', '111')
	singleTest('292', '292')
	singleTest('203', '212')
	singleTest('209', '212')

	singleTest('131231234', '131232131')
	singleTest('1991', '1991')
	singleTest('1981', '1991')
	singleTest('1891', '1991')

	singleTest('28994', '29092')
	singleTest('29994', '30003')


def largeDigitTest1():
	n1 = ''
	n2 = ''
	for i in range(1000):
		n1 = n1 + '1'
		n2 = n2 + '9'
	singleTest(n1, n1)
	singleTest(n2, n2)

	n3 = "2211111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
	n4 = "2211111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111122"
	singleTest(n3, n4)
	n5 = "8899999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
	n6 = "8900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000098";
	singleTest(n5, n6)
	n7 = "890000000000000000000000000000123000000000000000000000000000000000000000000000000000000000000000000098"
	n8 = "890000000000000000000000000000123000000000000000000000000000000000000321000000000000000000000000000098"
	singleTest(n7, n8)

def runTests():
	smallDigitTests()
	largeDigitTest1()

def compileP014():
	ret = os.system('gcc -g -Wall p014.c -o p014')
	if (ret != 0):
		raise Exception("Did not compile")

def cleanup():
	os.system('rm p014')

def testP014():
	compileP014()
	runTests()
	cleanup()


testP014()

{'fraction_non_alphanumeric': 0.14186307519640853, 'fraction_numerical': 0.35084175084175084, 'mean_word_length': 6.257328990228013, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 18, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6097533', 'n_tokens_mistral': 2778, 'n_tokens_neox': 1485, 'n_words': 328}