Back to home page

Enduro/X

 
 

    


0001 /**
0002  *
0003  * @file test_bdel.c
0004  */
0005 /* -----------------------------------------------------------------------------
0006  * Enduro/X Middleware Platform for Distributed Transaction Processing
0007  * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0008  * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0009  * This software is released under one of the following licenses:
0010  * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0011  * See LICENSE file for full text.
0012  * -----------------------------------------------------------------------------
0013  * AGPL license:
0014  *
0015  * This program is free software; you can redistribute it and/or modify it under
0016  * the terms of the GNU Affero General Public License, version 3 as published
0017  * by the Free Software Foundation;
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 Affero General Public License, version 3
0022  * for more details.
0023  *
0024  * You should have received a copy of the GNU Affero General Public License along 
0025  * with this program; if not, write to the Free Software Foundation, Inc.,
0026  * 59 Temple 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 <ubf.h>
0038 #include <ndrstandard.h>
0039 #include <string.h>
0040 #include "test.fd.h"
0041 #include "ubfunit1.h"
0042 
0043 
0044 void load_fdel_test_data_1(UBFH *p_ub)
0045 {
0046     short s = 102;
0047     long l = 10212312;
0048     char c = 'a';
0049     float f = 127.001;
0050     double d = 12312312.1112;
0051     char carr[] = "CARRAY TEST";
0052     BFLDLEN len = strlen(carr);
0053 
0054     assert_equal(Bchg(p_ub, T_SHORT_FLD, 0, (char *)&s, 0), EXSUCCEED);
0055     assert_equal(Bchg(p_ub, T_LONG_FLD, 0, (char *)&l, 0), EXSUCCEED);
0056     assert_equal(Bchg(p_ub, T_CHAR_FLD, 0, (char *)&c, 0), EXSUCCEED);
0057     assert_equal(Bchg(p_ub, T_FLOAT_FLD, 0, (char *)&f, 0), EXSUCCEED);
0058     assert_equal(Bchg(p_ub, T_DOUBLE_FLD, 0, (char *)&d, 0), EXSUCCEED);
0059     assert_equal(Bchg(p_ub, T_STRING_FLD, 0, (char *)"TEST STR VAL", 0), EXSUCCEED);
0060     assert_equal(Bchg(p_ub, T_CARRAY_FLD, 0, (char *)carr, len), EXSUCCEED);
0061 
0062     /* Load View / UBF / PTR */
0063     gen_load_view(p_ub, 0, 1, 0);
0064     gen_load_ubf(p_ub, 0, 1, 0);
0065     gen_load_ptr(p_ub, 0, 1, 0);
0066     
0067 
0068     /* Make second copy of field data (another for not equal test)*/
0069     s = 212;
0070     l = 212;
0071     c = 'b';
0072     f = 12127;
0073     d = 1231232.1;
0074     carr[0] = 'X';
0075     assert_equal(Bchg(p_ub, T_SHORT_2_FLD, 0, (char *)&s, 0), EXSUCCEED);
0076     assert_equal(Bchg(p_ub, T_LONG_2_FLD, 0, (char *)&l, 0), EXSUCCEED);
0077     assert_equal(Bchg(p_ub, T_CHAR_2_FLD, 0, (char *)&c, 0), EXSUCCEED);
0078     assert_equal(Bchg(p_ub, T_FLOAT_2_FLD, 0, (char *)&f, 0), EXSUCCEED);
0079     assert_equal(Bchg(p_ub, T_DOUBLE_2_FLD, 0, (char *)&d, 0), EXSUCCEED);
0080     assert_equal(Bchg(p_ub, T_STRING_2_FLD, 0, (char *)"XTEST STR VAL", 0), EXSUCCEED);
0081     assert_equal(Bchg(p_ub, T_CARRAY_2_FLD, 0, (char *)carr, len), EXSUCCEED);
0082     
0083     /* Load View / UBF / PTR */
0084     gen_load_view(p_ub, 0, 1, 1);
0085     gen_load_ubf(p_ub, 0, 1, 1);
0086     gen_load_ptr(p_ub, 0, 1, 1);
0087     
0088 }
0089 
0090 Ensure(test_fdel_simple)
0091 {
0092     char fb[3072];
0093     UBFH *p_ub = (UBFH *)fb;
0094     assert_equal(Binit(p_ub, sizeof(fb)), EXSUCCEED);
0095     /* Load test data for fdel test */
0096     set_up_dummy_data(p_ub);
0097     load_fdel_test_data_1(p_ub);
0098     
0099     assert_equal(Bdel(p_ub, T_SHORT_FLD, 0), EXSUCCEED);
0100     assert_false(Bpres(p_ub, T_SHORT_FLD, 0));
0101 
0102     assert_equal(Bdel(p_ub, T_LONG_FLD, 0), EXSUCCEED);
0103     assert_false(Bpres(p_ub, T_LONG_FLD, 0));
0104 
0105     assert_equal(Bdel(p_ub, T_CHAR_FLD, 0), EXSUCCEED);
0106     assert_false(Bpres(p_ub, T_CHAR_FLD, 0));
0107 
0108     assert_equal(Bdel(p_ub, T_FLOAT_FLD, 0), EXSUCCEED);
0109     assert_false(Bpres(p_ub, T_FLOAT_FLD, 0));
0110 
0111     assert_equal(Bdel(p_ub, T_DOUBLE_FLD, 0), EXSUCCEED);
0112     assert_false(Bpres(p_ub, T_DOUBLE_FLD, 0));
0113 
0114     assert_equal(Bdel(p_ub, T_STRING_FLD, 0), EXSUCCEED);
0115     assert_false(Bpres(p_ub, T_STRING_FLD, 0));
0116 
0117     assert_equal(Bdel(p_ub, T_CARRAY_FLD, 0), EXSUCCEED);
0118     assert_false(Bpres(p_ub, T_CARRAY_FLD, 0));
0119     
0120     
0121     assert_true(Bpres(p_ub, T_VIEW_FLD, 0));
0122     assert_equal(Bdel(p_ub, T_VIEW_FLD, 0), EXSUCCEED);
0123     assert_false(Bpres(p_ub, T_VIEW_FLD, 0));
0124     
0125     assert_true(Bpres(p_ub, T_PTR_FLD, 0));
0126     assert_equal(Bdel(p_ub, T_PTR_FLD, 0), EXSUCCEED);
0127     assert_false(Bpres(p_ub, T_PTR_FLD, 0));
0128     
0129     assert_true(Bpres(p_ub, T_UBF_FLD, 0));
0130     assert_equal(Bdel(p_ub, T_UBF_FLD, 0), EXSUCCEED);
0131     assert_false(Bpres(p_ub, T_UBF_FLD, 0));
0132 
0133     do_dummy_data_test(p_ub);
0134 }
0135 
0136 TestSuite *ubf_fdel_tests(void)
0137 {
0138     TestSuite *suite = create_test_suite();
0139 
0140     add_test(suite, test_fdel_simple);
0141     
0142     return suite;
0143 }
0144 
0145 /* vim: set ts=4 sw=4 et smartindent: */