Line data Source code
1 : #include "common.h"
2 :
3 : /* Testing: Set and get options with ct_options */
4 10 : TEST_MAIN()
5 : {
6 10 : int verbose = 0;
7 :
8 : CS_CONTEXT *ctx;
9 : CS_CONNECTION *conn;
10 : CS_COMMAND *cmd;
11 :
12 10 : CS_INT datefirst = 0;
13 10 : CS_INT dateformat = 0;
14 10 : CS_BOOL truefalse = 999;
15 :
16 : if (verbose) {
17 : printf("Trying login\n");
18 : }
19 :
20 10 : if (argc >= 5) {
21 0 : common_pwd.initialized = argc;
22 0 : strcpy(common_pwd.server, argv[1]);
23 0 : strcpy(common_pwd.database, argv[2]);
24 0 : strcpy(common_pwd.user, argv[3]);
25 0 : strcpy(common_pwd.password, argv[4]);
26 : }
27 :
28 10 : check_call(try_ctlogin, (&ctx, &conn, &cmd, verbose));
29 :
30 10 : printf("%s: Set/Retrieve DATEFIRST\n", __FILE__);
31 :
32 : /* DATEFIRST */
33 10 : datefirst = CS_OPT_WEDNESDAY;
34 10 : check_call(ct_options, (conn, CS_SET, CS_OPT_DATEFIRST, &datefirst, CS_UNUSED, NULL));
35 :
36 10 : datefirst = 999;
37 :
38 10 : check_call(ct_options, (conn, CS_GET, CS_OPT_DATEFIRST, &datefirst, CS_UNUSED, NULL));
39 10 : if (datefirst != CS_OPT_WEDNESDAY) {
40 0 : fprintf(stderr, "ct_options(DATEFIRST) didn't work retrieved %d expected %d\n", datefirst, CS_OPT_WEDNESDAY);
41 0 : return 1;
42 : }
43 :
44 10 : printf("%s: Set/Retrieve DATEFORMAT\n", __FILE__);
45 :
46 : /* DATEFORMAT */
47 10 : dateformat = CS_OPT_FMTMYD;
48 10 : check_call(ct_options, (conn, CS_SET, CS_OPT_DATEFORMAT, &dateformat, CS_UNUSED, NULL));
49 :
50 10 : dateformat = 999;
51 :
52 10 : check_call(ct_options, (conn, CS_GET, CS_OPT_DATEFORMAT, &dateformat, CS_UNUSED, NULL));
53 10 : if (dateformat != CS_OPT_FMTMYD) {
54 0 : fprintf(stderr, "ct_options(DATEFORMAT) didn't work retrieved %d expected %d\n", dateformat, CS_OPT_FMTMYD);
55 0 : return 1;
56 : }
57 :
58 10 : printf("%s: Set/Retrieve ANSINULL\n", __FILE__);
59 : /* ANSI NULLS */
60 10 : truefalse = CS_TRUE;
61 10 : check_call(ct_options, (conn, CS_SET, CS_OPT_ANSINULL, &truefalse, CS_UNUSED, NULL));
62 :
63 10 : truefalse = 999;
64 10 : check_call(ct_options, (conn, CS_GET, CS_OPT_ANSINULL, &truefalse, CS_UNUSED, NULL));
65 10 : if (truefalse != CS_TRUE) {
66 0 : fprintf(stderr, "ct_options(ANSINULL) didn't work\n");
67 0 : return 1;
68 : }
69 :
70 10 : printf("%s: Set/Retrieve CHAINXACTS\n", __FILE__);
71 : /* CHAINED XACT */
72 10 : truefalse = CS_TRUE;
73 10 : check_call(ct_options, (conn, CS_SET, CS_OPT_CHAINXACTS, &truefalse, CS_UNUSED, NULL));
74 :
75 10 : truefalse = 999;
76 10 : check_call(ct_options, (conn, CS_GET, CS_OPT_CHAINXACTS, &truefalse, CS_UNUSED, NULL));
77 10 : if (truefalse != CS_TRUE) {
78 0 : fprintf(stderr, "ct_options(CHAINXACTS) didn't work\n");
79 0 : return 1;
80 : }
81 :
82 : if (verbose) {
83 : printf("Trying logout\n");
84 : }
85 10 : check_call(try_ctlogout, (ctx, conn, cmd, verbose));
86 :
87 10 : return 0;
88 : }
|