shithub: scc

ref: e1bc6c3a19ded30fb1affa8dceaeec7d5c0a0951
dir: /tests/libc/execute/0026-strstr.c/

View raw version
#include <assert.h>
#include <stdio.h>
#include <string.h>

/*
output:
testing
done
end:
*/

int
main()
{
	char buf[30] = "abc";

	puts("testing");
	assert(strstr(buf, "abc") == buf);
	assert(strstr(buf, "bc") == buf + 1);
	assert(strstr(buf, "c") == buf + 2);
	assert(strstr(buf, "d") == NULL);
	strcpy(buf, "ababc");
	assert(strstr(buf, "abc") == buf+2);
	assert(strstr("", "abc") == NULL);
	assert(strstr(buf, "") == buf);
	buf[0] = '\0';
	assert(strstr(buf, "") == buf);
	puts("done");

	return 0;
}