Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
test_crypt.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <CUnit/Basic.h>
#include "ev_mgr.h"
#include "crypt.h"

Functions

void test_1_1 ()
 Test Initialize/Destroy Crypt module. More...
 
void test_1_2 ()
 Test Encrypt / Decrypt. More...
 
int add_suite_1_tests (void)
 Add Crypt suite tests. More...
 

Variables

CU_pSuite pSuite
 
int num_crypt_module
 

Detailed Description

Author
Kirill Scherba kiril.nosp@m.l@sc.nosp@m.herba.nosp@m..ru

Crypt module test suite

cUnit test suite code:

#include <stdio.h>
#include <stdlib.h>
#include <CUnit/Basic.h>
#include "ev_mgr.h"
#include "crypt.h"
extern CU_pSuite pSuite; // Test global variable
extern int num_crypt_module; // Teonet crypt module global variable
void test_1_1() {
CU_ASSERT_PTR_NOT_NULL_FATAL((kcr = ksnCryptInit(NULL)));
CU_ASSERT(num_crypt_module == 1);
CU_ASSERT(num_crypt_module == 0);
}
void test_1_2() {
CU_ASSERT_PTR_NOT_NULL_FATAL((kcr = ksnCryptInit(NULL)));
const char *package = "Hello world!";
const size_t package_len = strlen(package) + 1;
char buffer[KSN_BUFFER_SIZE];
size_t encrypt_len;
ksnEncryptPackage(kcr, (void *)package, package_len, buffer, &encrypt_len);
CU_ASSERT(num_crypt_module == 0);
}
int add_suite_1_tests(void) {
// Add the tests to the suite
if ((NULL == CU_add_test(pSuite, "Initialize/Destroy Crypt module", test_1_1)) ||
(NULL == CU_add_test(pSuite, "Encrypt / Decrypt", test_1_2))
) {
CU_cleanup_registry();
return CU_get_error();
}
return 0;
}

Created on Aug 7, 2015, 9:31:12 PM

Function Documentation

int add_suite_1_tests ( void  )

Add Crypt suite tests.

Returns

References pSuite, test_1_1(), and test_1_2().

Referenced by main().

void test_1_1 ( )

Test Initialize/Destroy Crypt module.

References ksnCryptDestroy(), ksnCryptInit(), and num_crypt_module.

Referenced by add_suite_1_tests().

void test_1_2 ( )

Test Encrypt / Decrypt.

Returns

References KSN_BUFFER_SIZE, ksnCryptDestroy(), ksnCryptInit(), ksnEncryptPackage(), and num_crypt_module.

Referenced by add_suite_1_tests().

Variable Documentation

int num_crypt_module
CU_pSuite pSuite

Referenced by add_suite_1_tests().