FUNCTION
Test if RB_Match correctly matches literal strings.
SOURCE
void Test_RB_Match_1 ( void )
{
RBT_Assert( RB_Match( "test", "test" ) );
RBT_Assert( ! RB_Match( "xest", "test" ) );
RBT_Assert( ! RB_Match( "tesx", "test" ) );
RBT_Assert( ! RB_Match( "txxt", "test" ) );
RBT_Assert( ! RB_Match( "testo", "test" ) );
}
FUNCTION
Test if RB_Match correctly processes the wildcard character '*'.
SOURCE
void Test_RB_Match_2 ( void )
{
/* It should match the empty string. */
RBT_Assert( RB_Match( "", "*" ) );
/* It should match a single character */
RBT_Assert( RB_Match( "a", "*" ) );
/* And multiple characters */
RBT_Assert( RB_Match( "aaa", "*" ) );
RBT_Assert( RB_Match( "aaa", "a*" ) );
/* a substring of several characters inside a longer string */
RBT_Assert( RB_Match( "aaaxaaxaaxaax", "a*aaxaax" ) );
/* twice an empty string in a string */
RBT_Assert( RB_Match( "aaaxaaxaaxaax", "aaax*aaxaa*xaax" ) );
/* empty string infront of a string */
RBT_Assert( RB_Match( "aaaxaaxaaxaax", "*aaaxaaxaaxaax" ) );
RBT_Assert( RB_Match( "aaaxaaxaaxaax", "aaaxaaxaaxaax*" ) );
RBT_Assert( RB_Match( "aaa", "*a*" ) );
/* This should not match */
RBT_Assert( ! RB_Match( "aaa", "*b*" ) );
}
FUNCTION
Test if RB_Match correctly processes the wildcard character '?'.
SOURCE
void Test_RB_Match_3 ( void )
{
RBT_Assert( RB_Match( "a", "?" ) );
RBT_Assert( RB_Match( "0", "?" ) );
RBT_Assert( RB_Match( "aap", "a?p" ) );
RBT_Assert( RB_Match( "aap", "??p" ) );
RBT_Assert( RB_Match( "aap", "a??" ) );
RBT_Assert( RB_Match( "aap", "?a?" ) );
}
FUNCTION
Test if RB_Match correctly processes combinations of the wildcard characters '?' and '*'.
SOURCE
void Test_RB_Match_4 ( void )
{
RBT_Assert( RB_Match( "aapjes", "*?" ) );
RBT_Assert( RB_Match( "aapjes", "?*" ) );
RBT_Assert( RB_Match( "aapjes", "?a*jes" ) );
RBT_Assert( RB_Match( "aaaapjes", "?a*jes" ) );
RBT_Assert( ! RB_Match( "aaaapjes", "?a*bjes" ) );
RBT_Assert( ! RB_Match( "aaaapjes", "?a*jes?" ) );
}