From 3f5724dc0b1f0a29f75e21a82ae62dc130784f5a Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Wed, 27 Apr 2022 19:18:30 +0200 Subject: [PATCH] created test code --- src/test/main.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) 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;