Ejemplo n.º 1
0
Archivo: strlib.c Proyecto: cs50/spl
void testStrlibModule(void) {
   testConcat();
   testIthChar();
   testSubString();
   testCharToString();
   testStringLength();
   testCopyString();
   testStringEqual();
   testStringEqualIgnoreCase();
   testStringCompare();
   testStartsWith();
   testEndsWith();
   testFindChar();
   testFindString();
   testFindLastChar();
   testFindLastString();
   testConvertToLowerCase();
   testConvertToUpperCase();
   testIntegerToString();
   testStringToInteger();
   testRealToString();
   testStringToReal();
   testTrim();
   testQuoteString();
   testQuoteHTML();
   testStringArrayLength();
   testSearchStringArray();
}
Ejemplo n.º 2
0
local void
checkPrintfCase(int w, const char *txt)
{
	String name = strPrintf("%d-[%s]", w, txt);
	char buf[20];
	sprintf(buf, "%*s", w, txt);
	String s2 = strPrintf("%*s", w, txt);

	testStringEqual(name, buf, s2);
	strFree(name);
}
Ejemplo n.º 3
0
local void
testPrintf1()
{
	char arr2[100];
	memset(arr, 'X', 100);
	String fmt = "foo: %s";
	String arg1 = "bar";
	sprintf(arr2, fmt, arg1);
	int cc = xprintf(arrWrite, fmt, arg1);
	
	testStringEqual("content", arr2, arr);
	testIntEqual("retval", cc, strlen(arr));
}
Ejemplo n.º 4
0
local void
testDocco()
{
	StringList text;
	AbSyn code;
	initFile();

	text = listList(String)(3, "+++ Words", "a: B;", "  ++ more words");
	code = abqParseLinesAsSeq(text);
	testAIntEqual("an id", AB_Declare, abTag(code));
	testStringEqual("docs", " Words\n more words\n", docString(abComment(abDefineeId(code))));

	text = listList(String)(2, "a: B;", "  ++ some words");
	code = abqParseLinesAsSeq(text);
	testAIntEqual("an id", AB_Declare, abTag(code));
	testStringEqual("docs", " some words\n", docString(abComment(abDefineeId(code))));

	text = listList(String)(2, "+++ ZZZ", "a: B;");
	code = abqParseLinesAsSeq(text);
	testAIntEqual("an id", AB_Declare, abTag(code));
	testStringEqual("docs", " ZZZ\n", docString(abComment(abDefineeId(code))));

	finiFile();
}