scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

0026-strstr.c (505B)


      1 #include <assert.h>
      2 #include <stdio.h>
      3 #include <string.h>
      4 
      5 /*
      6 output:
      7 testing
      8 done
      9 end:
     10 */
     11 
     12 int
     13 main()
     14 {
     15 	char buf[30] = "abc";
     16 
     17 	puts("testing");
     18 	assert(strstr(buf, "abc") == buf);
     19 	assert(strstr(buf, "bc") == buf + 1);
     20 	assert(strstr(buf, "c") == buf + 2);
     21 	assert(strstr(buf, "d") == NULL);
     22 	strcpy(buf, "ababc");
     23 	assert(strstr(buf, "abc") == buf+2);
     24 	assert(strstr("", "abc") == NULL);
     25 	assert(strstr(buf, "") == buf);
     26 	buf[0] = '\0';
     27 	assert(strstr(buf, "") == buf);
     28 	puts("done");
     29 
     30 	return 0;
     31 }
     32