![]() |
|
|||
0001 /** 0002 * @brief Base64 tests (Bug #261) 0003 * 0004 * @file test_nstd_b64.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-2023, Mavimax, Ltd. All Rights Reserved. 0010 * This software is released under one of the following licenses: 0011 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use. 0012 * See LICENSE file for full text. 0013 * ----------------------------------------------------------------------------- 0014 * AGPL license: 0015 * 0016 * This program is free software; you can redistribute it and/or modify it under 0017 * the terms of the GNU Affero General Public License, version 3 as published 0018 * by the Free Software Foundation; 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 Affero General Public License, version 3 0023 * for more details. 0024 * 0025 * You should have received a copy of the GNU Affero General Public License along 0026 * with this program; if not, write to the Free Software Foundation, Inc., 0027 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0028 * 0029 * ----------------------------------------------------------------------------- 0030 * A commercial use license is available from Mavimax, Ltd 0031 * contact@mavimax.com 0032 * ----------------------------------------------------------------------------- 0033 */ 0034 0035 #include <stdio.h> 0036 #include <stdlib.h> 0037 #include <cgreen/cgreen.h> 0038 #include <ubf.h> 0039 #include <ndrstandard.h> 0040 #include <string.h> 0041 #include <ndebug.h> 0042 #include <exbase64.h> 0043 #include "test.fd.h" 0044 #include "ubfunit1.h" 0045 #include "xatmi.h" 0046 0047 /* 0048 * Bug #261 with this data bug gave incorrect base64 coding. 0049 */ 0050 exprivate char M_bin_data[] = { 0051 0x00, 0x00, 0x59, 0x5a, 0x54, 0x33, 0x6f, 0x52, 0052 0x41, 0x46, 0x59, 0x5f, 0x62, 0x57, 0x48, 0x4e, 0053 0x4f, 0x46, 0x54, 0x70, 0x6d, 0x41, 0x46, 0x4e, 0054 0x75, 0x64, 0x69, 0x6a, 0x2b, 0x6f, 0x63, 0x41, 0055 0x45, 0x42, 0x41, 0x44, 0x49, 0x41, 0x00, 0x00, 0056 0x30, 0xf9, 0xa2, 0xd6, 0xff, 0x7f, 0x00, 0x00, 0057 0xa8, 0x2c, 0x93, 0xeb, 0x01, 0x00, 0x01, 0x00, 0058 0x32, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0059 0x20, 0xf9, 0xa2, 0xd6, 0xff, 0x7f, 0x00, 0x00, 0060 0x31, 0x2b, 0x7e, 0xec, 0x27, 0x7f, 0x00, 0x00, 0061 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0062 0xf8, 0x38, 0x9c, 0xec, 0x01, 0x00, 0x00, 0x00 0063 }; 0064 0065 /** 0066 * Test base64 functions of Enduro/X standard library 0067 */ 0068 Ensure(test_nstd_base64) 0069 { 0070 char bin[TPCONVMAXSTR]; 0071 char str[TPCONVMAXSTR]; 0072 size_t outlen = sizeof(str); 0073 0074 assert_not_equal(ndrx_xa_base64_encode((unsigned char *)M_bin_data, sizeof(M_bin_data), 0075 &outlen, str), NULL); 0076 0077 /* str[outlen] = EXEOS; */ 0078 NDRX_LOG(log_debug, "Got b64 string: [%s]", str); 0079 0080 outlen = sizeof(bin); 0081 assert_not_equal(ndrx_xa_base64_decode((unsigned char *)str, strlen(str), 0082 &outlen, bin), NULL); 0083 0084 assert_equal(memcmp(bin, M_bin_data, sizeof(M_bin_data)), 0); 0085 0086 } 0087 0088 /** 0089 * Base64 tests from Enduro/X Standard Library 0090 * @return 0091 */ 0092 TestSuite *ubf_nstd_base64(void) 0093 { 0094 TestSuite *suite = create_test_suite(); 0095 0096 add_test(suite, test_nstd_base64); 0097 0098 return suite; 0099 } 0100 /* vim: set ts=4 sw=4 et smartindent: */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |