1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
/* $Id: cpl_msg-test.c,v 1.13 2010/11/11 09:23:18 llundin Exp $
*
* This file is part of the ESO Common Pipeline Library
* Copyright (C) 2001-2008 European Southern Observatory
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* $Author: llundin $
* $Date: 2010/11/11 09:23:18 $
* $Revision: 1.13 $
* $Name: cpl-6_1_1 $
*/
#include <string.h>
#include "cpl_msg.h"
#include "cpl_test.h"
/*-----------------------------------------------------------------------------
Defines
-----------------------------------------------------------------------------*/
#ifndef STR_LENGTH
#define STR_LENGTH 80
#endif
/*-----------------------------------------------------------------------------
Main
-----------------------------------------------------------------------------*/
int main(void)
{
char message[STR_LENGTH+1];
char toolong[CPL_MAX_MSG_LENGTH];
int nindent = 0;
cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
/* Insert tests below */
/* Construct the null-terminated string of STR_LENGTH dots */
(void)memset((void*)message, '.', STR_LENGTH);
message[STR_LENGTH] = '\0';
/* - and display it */
cpl_msg_info(cpl_func, "Display a string of %d dots: %s", STR_LENGTH,
message);
cpl_msg_info(cpl_func, "Domain is: %s", cpl_msg_get_domain());
cpl_msg_indent_more(); nindent++;
cpl_msg_info(cpl_func,"hhu: %hhu\n", (unsigned char)-1);
cpl_msg_indent_more(); nindent++;
cpl_msg_info(cpl_func,"hhd: %hhd\n", (char)-1);
cpl_msg_indent_more(); nindent++;
cpl_msg_info(cpl_func,"zu: %zu\n", sizeof(int));
cpl_msg_indent_more(); nindent++;
cpl_msg_info(cpl_func,"td: %td\n", (__func__ ) - (__func__ + 2) );
cpl_msg_indent_more(); nindent++;
cpl_msg_info(cpl_func,"llu: %llu\n", (unsigned long long)-1);
cpl_msg_indent_more(); nindent++;
cpl_msg_info(cpl_func,"lld: %lld\n", (long long)-1);
cpl_msg_indent_more(); nindent++;
/* Test a too long message */
/* Construct the null-terminated string of STR_LENGTH dots */
(void)memset((void*)toolong, '.', CPL_MAX_MSG_LENGTH-1);
toolong[CPL_MAX_MSG_LENGTH-1] = '\0';
cpl_msg_info(cpl_func, "Display a string of %d dots: %s",
CPL_MAX_MSG_LENGTH-1, toolong);
cpl_msg_set_time_on();
for (;nindent; nindent--)
cpl_msg_indent_less(); /* Undo the indenting */
/* End of tests */
return cpl_test_end(0);
}
|