File: test_setget.h

package info (click to toggle)
xnee 3.19-9.4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,432 kB
  • sloc: ansic: 23,555; sh: 13,521; makefile: 600
file content (106 lines) | stat: -rw-r--r-- 2,834 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include <stdio.h>

#include "libxnee/xnee.h"
#include "libxnee/xnee_resource.h"

extern int orig;
extern int ret;
extern int new;

extern char *orig_str;
extern char *ret_str;
extern char *new_str;

extern FILE *orig_fd;
extern FILE *ret_fd;
extern FILE *new_fd;

extern xnee_data *xdl;

extern int fails;
extern int total;
extern int verbose ; 

#define PRINT_FUN   printf ("   %s:%d     %s()\n", __FILE__, __LINE__ , __func__); 

#define XNEE_PRINT_ERROR(err) \
      fprintf (stderr, "Error number: %d\n", err);                                \
      fprintf (stderr, "  Error:      %s\n", xnee_get_err_description(err));     \
      fprintf (stderr, "  Solution:   %s\n", xnee_get_err_solution(err)); \

#define ON_FAIL(fun, line) \
   total++; \
   fails++ ; \
   printf("Test of function '%s()' failed  (%s:%d)   %d/%d\n", fun, __FILE__, line, fails, total );  

   #define ON_OK(fun, line)   if(verbose)printf("Test of function '%s()' OK    line:%d   %d/%d  \n", fun, line, fails, total); total++;

#define XNEE_TEST_ASSERT(ret_val, comp_val, fun_str) \
   { \
     if ( (int)ret_val != (int)comp_val )	\
       {                    \
           ON_FAIL(fun_str, __LINE__); \
           printf ("   %d != %d\n", ret_val, comp_val); \
           PRINT_FUN;\
           XNEE_PRINT_ERROR(ret);\
           exit(1); \
       }\
     else \
      { \
           ON_OK(fun_str, __LINE__); \
       } \
   }

#define XNEE_TEST_ASSERT_DIFF(ret_val, comp_val, fun_str) \
   { \
     if ( (int)ret_val == (int)comp_val )	\
       {                    \
          ON_FAIL(fun_str, __LINE__);\
          printf ("   %d == %d\n", (int)ret_val, (int)comp_val);	\
          PRINT_FUN \
           exit(1); \
       }\
     else \
        ON_OK(fun_str, __LINE__); \
   }

#define XNEE_TEST_ASSERT_DIFF_PTR(ret_val, comp_val, fun_str) \
   { \
     if ( (void*)ret_val == (void*)comp_val )	\
       {                    \
          ON_FAIL(fun_str, __LINE__);\
          printf ("   %p == %p\n", (void*)ret_val, (void*)comp_val);	\
          PRINT_FUN \
           exit(1); \
       }\
     else \
        ON_OK(fun_str, __LINE__); \
   }

#define XNEE_TEST_ASSERT_STR(ret_str, comp_str, fun_str) \
   { \
     if ( strcmp(ret_str, comp_str)!=0) \
       {                    \
          ON_FAIL(fun_str, __LINE__);\
          printf ("   %s != %s\n", ret_str, comp_str); \
          PRINT_FUN \
          exit(1); \
       }\
     else \
        ON_OK(fun_str, __LINE__);\
   }

#define XNEE_TEST_ASSERT_DIFF_STR(ret_str, comp_str, fun_str) \
   { \
     if ( strcmp(ret_str, comp_str )==0) \
       {                    \
          ON_FAIL(fun_str, __LINE__);\
          printf ("   %s == %s\n", ret_str, comp_str); fflush(stdout);\
          PRINT_FUN \
          exit(1); \
       }\
     else \
        ON_OK(fun_str, __LINE__);\
   }