Back to home page

Enduro/X

 
 

    


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