...
void test(char* input, char* output, char* result, void (*prc)(void))
{
FILE *comp1, *comp2;
char c1, c2;
int line=1;
freopen(input, "r", stdin);
freopen(output, "w", stdout);
prc();
freopen("CON", "r", stdin);
freopen("CON", "w", stdout);
comp1 = fopen(output,"r");
comp2 = fopen(result,"r");
while (c1 != EOF && c2 != EOF)
{
c1 = getc(comp1);
c2 = getc(comp2);
if(c1 == '\\n' && c2 == '\\n')
line++;
if(c1 != c2 && c1 != '\\n' && c2 != '\\n')
{
printf("Testing %s : FAILED (line %d)\\n", input, line);
exit(1);
}
}
printf("Testing %s : SUCCESSED\\n", input);
return;
}
...
int main()
{
test("1\\i.txt", "1\\o.txt", "1\\r.txt", process);
return 0;
}
문제 풀 때 테스트함수 만들어 놓고 푸니깐 세상 편하네. 앞으로 복붙해서 써야겠다.
+ 내가 봐도 코드가 개떡 같은데 조언해주실 분?
내 카페에서 bench.h 보면 조금 참고가 될듯도.
ㄴ 그거 직접 만든 거였음? 무슨 라이브러리가 있는 줄 알았는데
ㅇㅇ 직접 모두 만든거유~
C++를 할 줄 몰라서 무슨 말인지 전혀 모르겠음
C++ 공부한 다음에 봐야지