tests.c

Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /*
00003  *  tests.c
00004  *  tests for code coverage and bugs
00005  *
00006  *  (C) Copyright 2010 Olivier Delhomme
00007  *  e-mail : heraia@delhomme.org
00008  *  URL    : http://heraia.tuxfamily.org
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2, or  (at your option)
00013  *  any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY;  without even the implied warranty of
00017  *  MERCHANTABILITY  or  FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License
00021  *  along with this program; if not, write to the Free Software
00022  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00023  */
00024 
00025  /**
00026  * @file tests.c
00027  * tests (code coverage and bug tracking)
00028  */
00029 #include <libheraia.h>
00030 
00031 static gboolean test_one_function(DecodeFunc a_function, gchar *function_name, guchar *data, gpointer data_struct, gchar *expected_result);
00032 
00033 
00034 /**
00035  *  test one decoding function from the decode.c module
00036  *  @param a_function : a decoding function that responds to the DecodeFunc template
00037  *  @param function_name : a gchar * representing the name of the function
00038  *  @param data : the data to be decoded
00039  *  @param data_struct : a structure related to the decoding function that may
00040  *                       help to decode data correctly
00041  *  @param expected_result : the result that may give the decoding function with
00042  *                           those specific parameters
00043  */
00044 static gboolean test_one_function(DecodeFunc a_function, gchar *function_name, guchar *data, gpointer data_struct, gchar *expected_result)
00045 {
00046     gchar *ret_code = NULL;
00047 
00048     ret_code = a_function(data, data_struct);
00049 
00050     if (g_strcmp0(ret_code, expected_result) == 0)
00051         {
00052             return TRUE;
00053         }
00054     else
00055         {
00056             fprintf(stderr, Q_("WARNING : expected result was not good with %s\n"), function_name);
00057             return FALSE;
00058         }
00059 }
00060 
00061 
00062 /**
00063  *  test decode functions
00064  *  No parameters
00065  */
00066 gboolean test_decode_functions(void)
00067 {
00068 
00069     gboolean exit_value = TRUE;
00070 
00071     exit_value = exit_value && test_one_function(decode_8bits_signed, "decode_8bits_signed", NULL, NULL, NULL);
00072     exit_value = exit_value && test_one_function(decode_8bits_unsigned, "decode_8bits_unsigned", NULL, NULL, NULL);
00073 
00074     exit_value = exit_value && test_one_function(decode_16bits_signed, "decode_16bits_signed", NULL, NULL, NULL);
00075     exit_value = exit_value && test_one_function(decode_16bits_unsigned, "decode_16bits_unsigned", NULL, NULL, NULL);
00076 
00077     exit_value = exit_value && test_one_function(decode_32bits_signed, "decode_32bits_signed", NULL, NULL, NULL);
00078     exit_value = exit_value && test_one_function(decode_32bits_unsigned, "decode_32bits_unsigned", NULL, NULL, NULL);
00079 
00080     exit_value = exit_value && test_one_function(decode_64bits_signed, "decode_64bits_signed", NULL, NULL, NULL);
00081     exit_value = exit_value && test_one_function(decode_64bits_unsigned, "decode_64bits_unsigned", NULL, NULL, NULL);
00082 
00083     exit_value = exit_value && test_one_function(decode_float_normal, "decode_float_normal", NULL, NULL, NULL);
00084     exit_value = exit_value && test_one_function(decode_float_scientific, "decode_float_scientific", NULL, NULL, NULL);
00085 
00086     exit_value = exit_value && test_one_function(decode_double_normal, "decode_double_normal", NULL, NULL, NULL);
00087     exit_value = exit_value && test_one_function(decode_double_scientific, "decode_double_scientific", NULL, NULL, NULL);
00088 
00089     return exit_value;
00090 }
00091 
00092 
00093 /**
00094  * functions to tests heraia's UI
00095  * @param main_struct : the main structure (the whole one)
00096  */
00097 gboolean tests_ui(heraia_struct_t *main_struct)
00098 {
00099 
00100     return TRUE;
00101 }
Generated on Tue Aug 10 18:29:02 2010 for Heraia by  doxygen 1.6.3