Back to home page

Enduro/X

 
 

    


0001 /**
0002  * @brief Standard library tests - macros
0003  *
0004  * @file test_nstd_macros.c
0005  */
0006 /* -----------------------------------------------------------------------------
0007  * Enduro/X Middleware Platform for Distributed Transaction Processing
0008  * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0009  * Copyright (C) 2017-2018, Mavimax, Ltd. All Rights Reserved.
0010  * This software is released under one of the following licenses:
0011  * GPL or Mavimax's license for commercial use.
0012  * -----------------------------------------------------------------------------
0013  * GPL license:
0014  * 
0015  * This program is free software; you can redistribute it and/or modify it under
0016  * the terms of the GNU General Public License as published by the Free Software
0017  * Foundation; either version 3 of the License, or (at your option) any later
0018  * version.
0019  *
0020  * This program is distributed in the hope that it will be useful, but WITHOUT ANY
0021  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0022  * PARTICULAR PURPOSE. See the GNU General Public License for more details.
0023  *
0024  * You should have received a copy of the GNU General Public License along with
0025  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
0026  * Place, Suite 330, Boston, MA 02111-1307 USA
0027  *
0028  * -----------------------------------------------------------------------------
0029  * A commercial use license is available from Mavimax, Ltd
0030  * contact@mavimax.com
0031  * -----------------------------------------------------------------------------
0032  */
0033 
0034 #include <stdio.h>
0035 #include <stdlib.h>
0036 #include <cgreen/cgreen.h>
0037 #include <ndrstandard.h>
0038 #include <string.h>
0039 #include <ndebug.h>
0040 #include <excrypto.h>
0041 #include "test.fd.h"
0042 #include "ubfunit1.h"
0043 
0044 /**
0045  * Test for Enduro/X standard C header macros
0046  */
0047 Ensure(test_nstd_ndrstandard)
0048 {
0049     char buf1[9];
0050     char buf2[5];
0051     
0052     
0053     NDRX_STRCPY_LAST_SAFE(buf1, "ABC", 8);
0054     assert_string_equal(buf1, "ABC");
0055     
0056     NDRX_STRCPY_LAST_SAFE(buf1, "1234567890ABCDEFGHIJK", 8);
0057     assert_string_equal(buf1, "DEFGHIJK");
0058     
0059     
0060     NDRX_STRCPY_LAST_SAFE(buf2, "ABCD", 8);
0061     assert_string_equal(buf2, "ABCD");
0062     
0063     NDRX_STRCPY_LAST_SAFE(buf2, "1234567890ABCDEFGHIJK", 8);
0064     
0065     /* because of safe copy... */
0066     assert_string_equal(buf2, "DEFG");
0067     
0068 }
0069 
0070 /**
0071  * C macros testings of standard library
0072  * @return
0073  */
0074 TestSuite *test_nstd_macros(void)
0075 {
0076     TestSuite *suite = create_test_suite();
0077 
0078     /*
0079     set_setup(suite, basic_setup1);
0080     set_teardown(suite, basic_teardown1);
0081     */
0082     
0083     add_test(suite, test_nstd_ndrstandard);
0084             
0085     return suite;
0086 }