#include <iostream> #include <string.h> void unitTest(); int main() { unitTest(); getchar(); return 0; } void my_getword(char *dst, const char *str) { } const char *testCase[] = { "","", "123", "", "abc", "abc", "--abc", "abc", "XYZ--", "XYZ", "--abcXYZ--", "abcXYZ", 0, 0, }; void unitTest() { int cnt = 0; int failed = 0; char dst[256] = {'?'}; for(int i = 0; testCase[i] != 0; i+=2) { my_getword(dst, testCase[i]); int rc = strcmp(dst, testCase[i+1]); if( !rc ) { std::cout << "#" << ++cnt << ": OK\n"; } else { ++failed; std::cout << "#" << ++cnt << ": NG, expected = '" << testCase[i+1] << "', actual = '" << dst << "', text = '" << testCase[i] << "'\n";; } } }