diff --git a/src/test/main.c b/src/test/main.c index 54f9f5c..72022b1 100644 --- a/src/test/main.c +++ b/src/test/main.c @@ -1,17 +1,28 @@ #include #include +#include #include "../../include/encrypter.h" #include "../../include/decrypter.h" +#define TEST_TEXT "Pepa smrdí." +#define TEST_KEY "lZwOBFvjJEmaYRIaKsALKLkSeJvXhFPbZIRNFbjQRNyiOuLTexhgOpObHzyQgNT" + int main(int args, char *argv[]) { - char *text = encryptText("Pepa smrdí.", "lZwOBFvjJEmaYRIaKsALKLkSeJvXhFPbZIRNFbjQRNyiOuLTexhgOpObHzyQgNT"); - printf("%s\n", text); + char *text = encryptText(TEST_TEXT, TEST_KEY); + text = decryptText(text, TEST_KEY); - text = decryptText(text, "lZwOBFvjJEmaYRIaKsALKLkSeJvXhFPbZIRNFbjQRNyiOuLTexhgOpObHzyQgNT"); - printf("%s\n", text); + if (strcmp(text, TEST_TEXT) == 0) + { + printf("Test successful!\n"); + } + else + { + fprintf(stderr, "Test failed!\n"); + exit(1); + } free(text); return 0;