finish first set of functions for basic single process unit test
error tracking and reporting. This commit was SVN r387.
Этот коммит содержится в:
родитель
3550859627
Коммит
1efc0f4131
@ -5,6 +5,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ static char *lam_description;
|
|||||||
void test_init(char *a)
|
void test_init(char *a)
|
||||||
{
|
{
|
||||||
/* local variables */
|
/* local variables */
|
||||||
int len;
|
size_t len;
|
||||||
|
|
||||||
/* save the descriptive string */
|
/* save the descriptive string */
|
||||||
len=strlen(a);
|
len=strlen(a);
|
||||||
@ -38,3 +39,53 @@ void test_init(char *a)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_success(void){
|
||||||
|
|
||||||
|
lam_n_tests++;
|
||||||
|
lam_n_success++;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_failure(char *a){
|
||||||
|
lam_n_tests++;
|
||||||
|
lam_n_failures++;
|
||||||
|
|
||||||
|
fprintf(stderr," Failure : %s \n",a);
|
||||||
|
fflush(stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_verify(char *expected_result, char *test_result){
|
||||||
|
/* local variables */
|
||||||
|
size_t len_expect,len_result;
|
||||||
|
int return_value;
|
||||||
|
|
||||||
|
return_value=1;
|
||||||
|
len_expect=strlen(expected_result);
|
||||||
|
len_result=strlen(test_result);
|
||||||
|
|
||||||
|
if( (!(len_expect == len_result)) ||
|
||||||
|
( 0 != strcmp(expected_result,test_result)) ) {
|
||||||
|
fprintf(stderr," Comparison failure: \n");
|
||||||
|
fprintf(stderr," Expected result: %s \n",expected_result);
|
||||||
|
fprintf(stderr," Test result: %s \n",test_result);
|
||||||
|
fflush(stderr);
|
||||||
|
return_value=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return return_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_finalize(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
if( lam_n_tests == lam_n_success) {
|
||||||
|
fprintf(stderr," SUPPORT :: LAM Test Passed :: %s \n",lam_description);
|
||||||
|
fflush(stderr);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr," SUPPORT :: LAM Test failed :: %s :: %d of %d failed\n"
|
||||||
|
,lam_description,lam_n_failures,lam_n_tests);
|
||||||
|
fflush(stderr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
#define LAM_SUPPORT_H
|
#define LAM_SUPPORT_H
|
||||||
|
|
||||||
void test_init(char *a);
|
void test_init(char *a);
|
||||||
|
void test_success(void);
|
||||||
|
void test_failure(char *a);
|
||||||
|
int test_verify(char *expected_result, char *test_result);
|
||||||
|
void test_finalize(void);
|
||||||
|
|
||||||
#endif /* LAM_SUPPORT_H */
|
#endif /* LAM_SUPPORT_H */
|
||||||
|
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user