<?php


require __DIR__ . "/extcheck.php";

function Expect( bool $i_bExpect, string $i_strFile ) : bool {
	$bActual = IsFileExtensionSafe( $i_strFile );
	if ( $i_bExpect == $bActual )
		echo "OK: ";
	else
		echo "FAILED: ";

	echo $i_strFile, " (got ",
		( $bActual ? "true" : "false" ),
		" expected ",
		( $i_bExpect ? "true" : "false" ),
		")\n";

	return $i_bExpect == $bActual;
}


$rTests = [
	'test.gif' => true,
	'test.jpg' => true,
	'test.jpeg' => true,
	'test.png' => true,
	'test' => false,
	'test.bad' => false,
	'test.php' => false,
	'test.php.jpg' => false,
	'test.jpg.php' => false,
	'test.jpg.gif' => false,
];


$uCount = 0;
$uScore = 0;
foreach ( $rTests as $strFile => $bExpect )  {
	$uCount += 1;
	if ( Expect( $bExpect, $strFile ) )
		$uScore += 1;
}

echo $uScore, "/", $uCount, " OK.\n";
