tests/ut/test_ut.c
/* [<][>][^][v][top][bottom][index][help] */
FUNCTIONS
This source file includes following functions.
- string_new
- string_free
- main
/***************************************
$Revision: 1.2 $
Example code: Unit test driver for mysql_driver.c
******************/ /******************
Modification History:
ottrey (29/07/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 "memwrap.h"
#include "bitmask.h"
#define TEST1 "1 Memory wrapper test."
#define TEST2 "2 Test TEST2"
#define TEST3 "3 Test TEST3"
#define TEST4 "4 Test TEST4"
char *string_new(const char *src) {
/* [<][>][^][v][top][bottom][index][help] */
er_ret_t err;
char *str;
if ( (err=wr_malloc( (void **) & str, strlen(src)+1 )) != UT_OK ) {
die;
}
ER_dbg_va(FAC_UT, MA_new(ER_ASP_RX, -1), "creating a string at %08x", str);
strcpy(str, src);
return str;
} /* string_new() */
char *string_free(char *str) {
/* [<][>][^][v][top][bottom][index][help] */
free(str);
} /* string_new() */
int main(int argc, char **argv) {
/* [<][>][^][v][top][bottom][index][help] */
char *str;
/* Get the options from the command line */
get_options(argc, argv);
/* TEST1 */
if (Test[1] == 1) {
print_title(TEST1);
str = string_new("Hello there.");
printf("str=%s\n", str);
string_free(str);
} /* TEST1 */
/* TEST2 */
if (Test[2] == 1) {
print_title(TEST2);
} /* TEST2 */
/* TEST3 */
if (Test[3] == 1) {
print_title(TEST3);
} /* TEST3 */
/* TEST4 */
if (Test[4] == 1) {
print_title(TEST4);
} /* TEST4 */
return 0;
} /* main() */