22 lines
897 B
C
22 lines
897 B
C
|
#include <assert.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
extern void sort_strings(const char * input, char * output, unsigned int n);
|
||
|
|
||
|
const char * S_sorted = "cfreq\0concatenate\0concatenate/tests\0coursesdb\0deletedigits\0deletedigits/tests\0findstrings\0flipline\0flipline/tests\0flipstream\0linkedlist\0redactdigits\0redactdigits/tests\0topcolor\0topcolor/tests\0volumes\0volumes/tests\0wordcount\0wordcount/tests";
|
||
|
|
||
|
const char * S = "concatenate/tests\0concatenate\0linkedlist\0topcolor/tests\0topcolor\0flipstream\0deletedigits/tests\0deletedigits\0coursesdb\0volumes/tests\0volumes\0cfreq\0wordcount/tests\0wordcount\0flipline/tests\0flipline\0findstrings\0redactdigits/tests\0redactdigits";
|
||
|
|
||
|
|
||
|
int main() {
|
||
|
char buf[1000];
|
||
|
|
||
|
sort_strings("ciao\0cia", buf, 2);
|
||
|
assert(memcmp(buf, "cia\0ciao", 9) == 0);
|
||
|
|
||
|
sort_strings(S, buf, 19);
|
||
|
assert(memcmp(buf, S_sorted, 239) == 0);
|
||
|
|
||
|
return 0;
|
||
|
}
|