<commit_before>#!/bin/bash

FAILURES=0

function do_test {
	ScriptName="$1"
	Input="$2"
	ExpectedOutput=$(printf "$3")
	TailLines="${4:-1}"
	echo -n Compiling "$ScriptName"...
	g++ -std=c++0x "$ScriptName".cpp -o "$ScriptName".obj
	echo -n " Executing..."
	GotOutput=$(printf "$Input" | ./"$ScriptName".obj | tail -n "$TailLines")
	if [ "$GotOutput" != "$ExpectedOutput" ]
	then
		printf " Failed\n    Expected: $ExpectedOutput\n    Got: $GotOutput\n"

		((FAILURES++))
	else
		echo " Passed"
	fi
}

function finalize {
	if [ "$FAILURES" -gt 0 ]
	then
		printf "There are %d failed tests!\n" "$FAILURES"
		exit 1
	fi

	exit 0

}

do_test triangle_centers "0\n6\n3\n0\n0\n0\n" "Centroid: (1, 2)\nOrthocenter: (0, 0)\nCircumcenter: (3, 3)\nIncenter: (2, 2)" 4

# repeated real root
do_test surd_quadratic "4\n12\n9\n" "One real root: -1.5"
# 2 distinct real roots
do_test surd_quadratic "0.5\n-5\n-774\n" "Two real roots: 44.6611 OR -34.6611\nSurd form: 5 +- 11 sqrt( 13 )" 2
# 2 distinct imaginary roots
do_test surd_quadratic "0.5\n-5\n799\n" "Two imaginary roots: 5 +- sqrt( 1573 ) i\nSurd form: 5 +- 11i sqrt( 13 )" 2
<commit_msg>The test script is wrong.<commit_after>#!/bin/bash

FAILURES=0

function do_test {
	ScriptName="$1"
	Input="$2"
	ExpectedOutput=$(printf "$3")
	TailLines="${4:-1}"
	echo -n Compiling "$ScriptName"...
	g++ -std=c++0x "$ScriptName".cpp -o "$ScriptName".obj
	echo -n " Executing..."
	GotOutput=$(printf "$Input" | ./"$ScriptName".obj | tail -n "$TailLines")
	if [ "$GotOutput" != "$ExpectedOutput" ]
	then
		printf " Failed\n    Expected: $ExpectedOutput\n    Got: $GotOutput\n"

		((FAILURES++))
	else
		echo " Passed"
	fi
}

function finalize {
	if [ "$FAILURES" -gt 0 ]
	then
		printf "There are %d failed tests!\n" "$FAILURES"
		exit 1
	fi

	exit 0

}

do_test triangle_centers "0\n6\n3\n0\n0\n0\n" "Centroid: (1, 2)\nOrthocenter: (2.1333, 0.6667)\nCircumcenter: (-0.2333, 3)\nIncenter: (1.1819, 0.8971)" 4

# repeated real root
do_test surd_quadratic "4\n12\n9\n" "One real root: -1.5"
# 2 distinct real roots
do_test surd_quadratic "0.5\n-5\n-774\n" "Two real roots: 44.6611 OR -34.6611\nSurd form: 5 +- 11 sqrt( 13 )" 2
# 2 distinct imaginary roots
do_test surd_quadratic "0.5\n-5\n799\n" "Two imaginary roots: 5 +- sqrt( 1573 ) i\nSurd form: 5 +- 11i sqrt( 13 )" 2

{'fraction_non_alphanumeric': 0.18114682884448305, 'fraction_numerical': 0.07298001737619461, 'mean_word_length': 3.6244979919678717, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '29712', 'n_tokens_mistral': 1088, 'n_tokens_neox': 961, 'n_words': 250}