~drizzle-trunk/libdrizzle/jenkins-Libdrizzle-21

« back to all changes in this revision

Viewing changes to tests/unit/statement.c

  • Committer: Continuous Integration
  • Date: 2012-12-27 22:20:37 UTC
  • mfrom: (62.2.4 5.1-tests)
  • Revision ID: ci@drizzle.org-20121227222037-7ppxx42d00f6h58j
Merge lp:~linuxjedi/libdrizzle/5.1-tests Build: jenkins-Libdrizzle-10

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 *
36
36
 */
37
37
 
38
 
#include "config.h"
39
 
 
40
38
#include <libdrizzle-5.1/libdrizzle.h>
41
39
#include <stdio.h>
42
40
#include <stdlib.h>
 
41
#include <stdint.h>
 
42
#include <string.h>
 
43
#include <inttypes.h>
 
44
#include <string.h>
43
45
 
44
46
#ifndef EXIT_SKIP
45
47
# define EXIT_SKIP 77
88
90
    printf("Prepare failure\n");
89
91
    return EXIT_FAILURE;
90
92
  }
91
 
  printf("Params: %" PRIu16 "\n", drizzle_stmt_param_count(stmt));
 
93
  /* Query should have 1 param */
 
94
  if (drizzle_stmt_param_count(stmt) != 1)
 
95
  {
 
96
    printf("Retrieved bad param count\n");
 
97
    return EXIT_FAILURE;
 
98
  }
92
99
 
93
100
  uint32_t val= 1;
94
101
  ret = drizzle_stmt_bind_param(stmt, 0, DRIZZLE_COLUMN_TYPE_LONG, &val, 4, DRIZZLE_BIND_OPTION_NONE);
110
117
    printf("Buffer failure\n");
111
118
    return EXIT_FAILURE;
112
119
  }
113
 
  printf("Rows found: %" PRIu64 "\n", drizzle_stmt_row_count(stmt));
 
120
  /* Result should have 2 rows */
 
121
  if (drizzle_stmt_row_count(stmt) != 2)
 
122
  {
 
123
    printf("Retrieved bad row count\n");
 
124
    return EXIT_FAILURE;
 
125
  }
 
126
  uint32_t i= 1;
114
127
  while (drizzle_stmt_fetch(stmt) != DRIZZLE_RETURN_ROW_END)
115
128
  {
116
129
    uint32_t *res_val;
117
130
    res_val= (uint32_t*)drizzle_stmt_item_data(stmt, 0);
118
 
    printf("Got value: %" PRIu32 "\n", *res_val);
 
131
    i++;
 
132
    if (*res_val != i)
 
133
    {
 
134
      printf("Retrieved unexpected value\n");
 
135
      return EXIT_FAILURE;
 
136
    }
 
137
  }
 
138
  /* Should have cycled through 2 rows (values 2 and 3) */
 
139
  if (i != 3)
 
140
  {
 
141
    printf("Retrieved bad number of rows\n");
 
142
    return EXIT_FAILURE;
119
143
  }
120
144
  ret = drizzle_stmt_close(stmt);
121
145
  if (ret != DRIZZLE_RETURN_OK)