~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle-1.0/t/drizzle_query_st.c

  • Committer: Mark Atwood
  • Date: 2011-12-14 18:12:05 UTC
  • mfrom: (2465.1.4 drizzle)
  • Revision ID: me@mark.atwood.name-20111214181205-tkz0lq9c4c0ptrwo
mergeĀ lp:~brianaker/drizzle/fix-localhost

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Drizzle Client & Protocol Library
 
3
 *
 
4
 * Copyright (C) 2008 Eric Day (eday@oddments.org)
 
5
 * All rights reserved.
 
6
 *
 
7
 * Use and distribution licensed under the BSD license.  See
 
8
 * the COPYING file in this directory for full text.
 
9
 */
 
10
 
 
11
/**
 
12
 * @file
 
13
 * @brief drizzle_query_st tests
 
14
 */
 
15
 
 
16
#include "libdrizzle-1.0/t/common.h"
 
17
 
 
18
#include <unistd.h>
 
19
 
 
20
int main(void)
 
21
{
 
22
  close(STDOUT_FILENO);
 
23
 
 
24
  drizzle_st *drizzle;
 
25
  drizzle_query_st *query;
 
26
  drizzle_query_st query_buffer;
 
27
  size_t size;
 
28
 
 
29
  printf("sizeof(drizzle_query_st) = %zu\n", sizeof(drizzle_query_st));
 
30
 
 
31
  if ((drizzle= drizzle_create(NULL)) == NULL)
 
32
    drizzle_test_error("drizzle_create");
 
33
 
 
34
  if ((query= drizzle_query_create(drizzle, &query_buffer)) == NULL)
 
35
    drizzle_test_error("drizzle_query_create");
 
36
  drizzle_query_free(query);
 
37
 
 
38
  if ((query= drizzle_query_create(drizzle, NULL)) == NULL)
 
39
    drizzle_test_error("drizzle_query_create");
 
40
 
 
41
  if (drizzle_query_options(query) != DRIZZLE_QUERY_ALLOCATED)
 
42
    drizzle_test_error("drizzle_query_options");
 
43
 
 
44
  drizzle_query_set_string(query, "SELECT 1+1", 10);
 
45
 
 
46
  if (strncmp(drizzle_query_string(query, &size), "SELECT 1+1", 10) ||
 
47
      size != 10)
 
48
  {
 
49
    drizzle_test_error("drizzle_query_string");
 
50
  }
 
51
 
 
52
  drizzle_query_free(query);
 
53
  drizzle_free(drizzle);
 
54
 
 
55
  return 0;
 
56
}