tests/qc/test_qc.c

/* [<][>]
[^][v][top][bottom][index][help] */

FUNCTIONS

This source file includes following functions.
  1. CO_get_comnd_logging
  2. CO_get_comnd_logfile
  3. SK_puts
  4. main

/***************************************
  $Revision: 1.2 $

  Example code: Unit test driver for mysql_driver.c

  ******************/ /******************
  Modification History:
        ottrey (07/04/1999) Created.
  ******************/ /******************
  Copyright (c) 1999                              RIPE NCC
 
  All Rights Reserved
  
  Permission to use, copy, modify, and distribute this software and its
  documentation for any purpose and without fee is hereby granted,
  provided that the above copyright notice appear in all copies and that
  both that copyright notice and this permission notice appear in
  supporting documentation, and that the name of the author not be
  used in advertising or publicity pertaining to distribution of the
  software without specific, written prior permission.
  
  THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
  AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  ***************************************/
#include "../test_.c"   /* unit test template */
#include "query_command.h"

#define TEST1 "1 Test 1"
#define TEST2 "2 Test 2"

int CO_get_comnd_logging() {
/* [<][>][^][v][top][bottom][index][help] */
  return 0;
} /* CO_get_comnd_logging() */

char *CO_get_comnd_logfile() {
/* [<][>][^][v][top][bottom][index][help] */
  return "stdout";
} /* CO_get_comnd_logfile() */

SK_puts(int sock, char *input) {
/* [<][>][^][v][top][bottom][index][help] */
  printf(input);
} /* SK_puts() */

int main(int argc, char **argv) {
/* [<][>][^][v][top][bottom][index][help] */
  FILE *infile;
  char input[STR_L];
  char *str;

  Query_command *query_command;
  
  /* Default to get the input from stdin */
  infile = stdin;

  /* Get the options from the command line */
  get_options(argc, argv);

  /* Object Initialization */
  OB_init();

  /* TEST1 */
  if (Test[1] == 1) {
    print_title(TEST1);

    if (Infile_name != NULL) {
      infile = fopen(Infile_name, "r");

      if (infile == NULL) {
        perror("Couldn't load infile");
        return -1;
      }
    }

    while (fgets(input, STR_L, infile)) {
      /* strip the \n */
      input[strlen(input)-1] = '\0';

      if (Verbose == 1) {
        printf("input=%s\n", input);
      }
      query_command = QC_new(input, 1);
      str = QC_query_command_to_string(query_command);
      printf("Query_command = %s\n", str);
      free(str);
      QC_free(query_command);
    }
    close(infile);
  } /* TEST1 */

  /* TEST2 */
  if (Test[2] == 1) {
    print_title(TEST2);

    OB_objects_to_string();

  } /* TEST2 */

  return 0;

} /* main() */


/* [<][>][^][v][top][bottom][index][help] */