Debian Codegraph @

src/interfaces/ecpg/test/compat_informix/rfmtlong.pgc

raw
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <pgtypes_error.h>
4 #include <sqltypes.h>
5
6 /*
7 * This file tests various forms of long-input/output by means of
8 * rfmtlong
9 */
10
11
12 static void
13 check_return(int ret);
14
15 static void
16 fmtlong(long lng, const char *fmt)
17 {
18 static int i;
19 int r;
20 char buf[30];
21
22 r = rfmtlong(lng, fmt, buf);
23 printf("r: %d ", r);
24 if (r == 0)
25 {
26 printf("%d: %s (fmt was: %s)\n", i++, buf, fmt);
27 }
28 else
29 check_return(r);
30 }
31
32 int
33 main(void)
34 {
35 ECPGdebug(1, stderr);
36
37 fmtlong(-8494493, "-<<<<,<<<,<<<,<<<");
38 fmtlong(-8494493, "################");
39 fmtlong(-8494493, "+++$$$$$$$$$$$$$.##");
40 fmtlong(-8494493, "(&,&&&,&&&,&&&.)");
41 fmtlong(-8494493, "<<<<,<<<,<<<,<<<");
42 fmtlong(-8494493, "$************.**");
43 fmtlong(-8494493, "---$************.**");
44 fmtlong(-8494493, "+-+################");
45 fmtlong(-8494493, "abc: ################+-+");
46 fmtlong(-8494493, "+<<<<,<<<,<<<,<<<");
47
48 return 0;
49 }
50
51 static void
52 check_return(int ret)
53 {
54 switch(ret)
55 {
56 case ECPG_INFORMIX_ENOTDMY:
57 printf("(ECPG_INFORMIX_ENOTDMY)");
58 break;
59 case ECPG_INFORMIX_ENOSHORTDATE:
60 printf("(ECPG_INFORMIX_ENOSHORTDATE)");
61 break;
62 case ECPG_INFORMIX_BAD_DAY:
63 printf("(ECPG_INFORMIX_BAD_DAY)");
64 break;
65 case ECPG_INFORMIX_BAD_MONTH:
66 printf("(ECPG_INFORMIX_BAD_MONTH)");
67 break;
68 default:
69 printf("(unknown ret: %d)", ret);
70 break;
71 }
72 printf("\n");
73 }