Back to home page

Enduro/X

 
 

    


0001 /**
0002  *
0003  * @file test_badd.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 <fml.h>
0039 #include <fml32.h>
0040 #include <ndrstandard.h>
0041 #include <string.h>
0042 #include "test.fd.h"
0043 #include "ubfunit1.h"
0044 #include "ndebug.h"
0045 
0046 
0047 #define DEFAULT_BUFFER  1024
0048 exprivate UBFH *M_p_ub1 = NULL;
0049 exprivate UBFH *M_p_ub2 = NULL;
0050 exprivate UBFH *M_p_ub3 = NULL;
0051 
0052 /**
0053  * Basic preparation before the test
0054  */
0055 Ensure(basic_setup1)
0056 {
0057     /*printf("basic_setup\n"); */
0058     M_p_ub1 = malloc(DEFAULT_BUFFER);
0059     memset(M_p_ub1, 255, DEFAULT_BUFFER);
0060     if (EXFAIL==Binit(M_p_ub1, DEFAULT_BUFFER))
0061     {
0062         fprintf(stderr, "Binit failed 1!\n");
0063     }
0064     
0065     M_p_ub2 = malloc(DEFAULT_BUFFER*3);
0066     memset(M_p_ub2, 255, DEFAULT_BUFFER*3);
0067     if (EXFAIL==Binit(M_p_ub2, DEFAULT_BUFFER*3))
0068     {
0069         fprintf(stderr, "Binit failed 2!\n");
0070     }
0071     
0072     M_p_ub3 = malloc(DEFAULT_BUFFER);
0073     memset(M_p_ub3, 255, DEFAULT_BUFFER);
0074     if (EXFAIL==Binit(M_p_ub3, DEFAULT_BUFFER))
0075     {
0076         fprintf(stderr, "Binit failed 3!\n");
0077     }
0078 
0079     /* shared load */
0080     load_field_table();
0081 }
0082 
0083 void basic_teardown1(void)
0084 {
0085     /*printf("basic_teardown\n");*/
0086     free (M_p_ub1);
0087     free (M_p_ub2);
0088     free (M_p_ub3);
0089 }
0090 
0091 /**
0092  * Basic test for Badd & Bget
0093  */
0094 Ensure(test_Badd_str)
0095 {
0096     char pan1[32] = "THIS IS 1";
0097     char pan2[32] = "THIS IS 2";
0098     char pan3[32] = "THIS IS 3";
0099     char pan4[32] = "THIS IS 4";
0100 
0101     double amttxn1=10021.123;
0102     double amttxn2=20021.123;
0103     double amttxn3=321.123;
0104     double amttxn4=11.123;
0105     double amttxn5=33.123;
0106     double tmp_amttxn=0;
0107     char too_large[2048];
0108 
0109     char tmp_buf[32+8]; /* 8 for alignment */
0110     int org_used = Bused(M_p_ub1);
0111 
0112     assert_equal(
0113             Badd(M_p_ub1, T_STRING_FLD, pan1, 0),
0114             EXSUCCEED);
0115 
0116     assert_equal(
0117             Badd(M_p_ub1, T_STRING_FLD, pan2, 0),
0118             EXSUCCEED);
0119 
0120     assert_equal(
0121             Badd(M_p_ub1, T_STRING_FLD, pan3, 0),
0122             EXSUCCEED);
0123 
0124     assert_equal(
0125             Badd(M_p_ub1, T_STRING_FLD, pan4, 0),
0126             EXSUCCEED);
0127 
0128     /* Get the data from buffer */
0129     assert_equal(
0130             Bget(M_p_ub1, T_STRING_FLD, 0, tmp_buf, 0),
0131             EXSUCCEED);
0132     assert_string_equal(pan1, tmp_buf);
0133 
0134     assert_equal(
0135             Bget(M_p_ub1, T_STRING_FLD, 1, tmp_buf, 0),
0136             EXSUCCEED);
0137     assert_string_equal(pan2, tmp_buf);
0138 
0139     assert_equal(
0140             Bget(M_p_ub1, T_STRING_FLD, 2, tmp_buf, 0),
0141             EXSUCCEED);
0142     assert_string_equal(pan3, tmp_buf);
0143 
0144     assert_equal(
0145             Bget(M_p_ub1, T_STRING_FLD, 3, tmp_buf, 0),
0146             EXSUCCEED);
0147     assert_string_equal(pan4, tmp_buf);
0148 
0149     /* Now add something other, some double value? */
0150     assert_equal(
0151             Badd(M_p_ub1, T_DOUBLE_4_FLD, (char *)&amttxn1, 0),
0152             EXSUCCEED);
0153     assert_equal(
0154             Badd(M_p_ub1, T_DOUBLE_4_FLD, (char *)&amttxn2, 0),
0155             EXSUCCEED);
0156     assert_equal(
0157             Badd(M_p_ub1, T_DOUBLE_4_FLD, (char *)&amttxn3, 0),
0158             EXSUCCEED);
0159     assert_equal(
0160             Badd(M_p_ub1, T_DOUBLE_4_FLD, (char *)&amttxn4, 0),
0161             EXSUCCEED);
0162     /* Do not have space available in buffer  */
0163     assert_equal(
0164             Badd(M_p_ub1, T_CARRAY_FLD, (char *)too_large, sizeof(too_large)),
0165             EXFAIL);
0166     assert_equal(Berror, BNOSPACE);
0167     /* Compare the values from buffer */
0168     assert_equal(
0169         Bget(M_p_ub1, T_DOUBLE_4_FLD, 0, (char *)&tmp_amttxn, 0),
0170         EXSUCCEED);
0171     assert_double_equal(tmp_amttxn, 10021.123);
0172 
0173     assert_equal(
0174             Bget(M_p_ub1, T_DOUBLE_4_FLD, 1, (char *)&tmp_amttxn, 0),
0175             EXSUCCEED);
0176     assert_double_equal(tmp_amttxn, 20021.123);
0177 
0178     assert_equal(
0179             Bget(M_p_ub1, T_DOUBLE_4_FLD, 2, (char *)&tmp_amttxn, 0),
0180             EXSUCCEED);
0181     assert_double_equal(tmp_amttxn, 321.123);
0182     assert_equal(
0183             Bget(M_p_ub1, T_DOUBLE_4_FLD, 3, (char *)&tmp_amttxn, 0),
0184             EXSUCCEED);
0185     assert_double_equal(tmp_amttxn, 11.123);
0186     /* Do not have space in buffer! 
0187     assert_equal(
0188             Bget(M_p_ub1, T_DOUBLE_4_FLD, 4, (char *)&tmp_amttxn, 0),
0189             EXFAIL);
0190 
0191      Summ the stuff up (+4 - EOS symbols in buffer)*/
0192 #if 0
0193     assert_equal(org_used+strlen(pan1)+strlen(pan2)+strlen(pan3)+strlen(pan4)+4+
0194                 sizeof(amttxn1)+sizeof(amttxn2)+sizeof(amttxn3)+sizeof(amttxn4)+
0195                 8*sizeof(BFLDID)+8/*align*/, Bused(M_p_ub1));
0196 #endif
0197 }
0198 
0199 /**
0200  * UBF sub-buffer tests + ptr & view test
0201  * This will fill up sme recursive data to M_p_ub2
0202  */
0203 Ensure(test_Badd_ubf)
0204 {
0205     char tmp_buf[128];
0206     long l;
0207     struct UBTESTVIEW1 v;
0208     BVIEWFLD vf;
0209     int i;
0210     
0211     memset(&v, 18, sizeof(v));
0212     assert_equal(
0213             Badd(M_p_ub2, T_STRING_4_FLD, "HELLO4", 0),
0214             EXSUCCEED);
0215     
0216     assert_equal(
0217             Badd(M_p_ub3, T_STRING_2_FLD, "HELLO WORLD", 0),
0218             EXSUCCEED);
0219     
0220     assert_equal(
0221             Badd(M_p_ub3, T_STRING_2_FLD, "HELLO WORLD 2", 0),
0222             EXSUCCEED);
0223     
0224     /* Add empty */
0225     assert_equal(
0226             Badd(M_p_ub1, T_UBF_2_FLD, (char *)M_p_ub2, 0),
0227             EXSUCCEED);
0228    
0229     assert_equal(
0230             Badd(M_p_ub1, T_UBF_2_FLD, (char *)M_p_ub2, 0),
0231             EXSUCCEED);
0232     
0233     assert_equal(
0234             Badd(M_p_ub1, T_UBF_3_FLD, (char *)M_p_ub3, 0),
0235             EXSUCCEED);
0236    
0237     /* Add some data, 3x levels */
0238     assert_equal(
0239             Badd(M_p_ub2, T_UBF_FLD, (char *)M_p_ub1, 0),
0240             EXSUCCEED);
0241     
0242     /* Add field before UBF (ptr)  */
0243     assert_equal(
0244             CBadd(M_p_ub2, T_CARRAY_2_FLD, "0x55", 0, BFLD_STRING),
0245             EXSUCCEED);
0246     
0247     assert_equal(
0248             CBadd(M_p_ub2, T_PTR_FLD, "0x55", 0, BFLD_STRING),
0249             EXSUCCEED);
0250     
0251     NDRX_STRCPY_SAFE(v.tcarray5, "TEST");
0252     
0253     /* Load some view data... */
0254     vf.data=(char *)&v;
0255     vf.vflags=0;
0256     NDRX_STRCPY_SAFE(vf.vname, "UBTESTVIEW1");
0257     
0258     assert_equal(
0259             Badd(M_p_ub2, T_VIEW_FLD, (char *)&vf, 0),
0260             EXSUCCEED);
0261     
0262     NDRX_STRCPY_SAFE(v.tcarray5, "SOME");
0263     
0264     assert_equal(
0265             Badd(M_p_ub2, T_VIEW_FLD, (char *)&vf, 0),
0266             EXSUCCEED);
0267     
0268     /* add buffer full... */
0269     while (EXSUCCEED==Badd(M_p_ub2, T_VIEW_FLD, (char *)&vf, 0)){}
0270     assert_equal(Berror, BNOSPACE);
0271     
0272     /* test field presence... */
0273     UBF_LOG(log_debug, "First");
0274     assert_equal(Bpresr(M_p_ub2, (int []){T_UBF_FLD, 0, T_UBF_2_FLD, 0, BBADFLDOCC}), EXTRUE);
0275     
0276     assert_equal(Berror, EXSUCCEED);
0277     
0278     UBF_LOG(log_debug, "2nd");
0279     
0280     assert_equal(
0281             Bpresr(M_p_ub2, (int []){T_UBF_FLD, 0, T_UBF_2_FLD, 1, BBADFLDOCC}),
0282             EXTRUE);
0283     assert_equal(Berror, EXSUCCEED);
0284             
0285     assert_equal(
0286             Bpresr(M_p_ub2, (int []){T_UBF_FLD, 0, T_UBF_2_FLD, 2, BBADFLDOCC}),
0287             EXFALSE);
0288     
0289     assert_equal(Berror, EXSUCCEED);
0290             
0291     assert_equal(
0292             Bpresr(M_p_ub2, (int []){T_UBF_FLD, 0, T_UBF_3_FLD, 0, BBADFLDOCC}),
0293             EXTRUE);
0294     assert_equal(Berror, EXSUCCEED);
0295                         
0296             
0297     /* Load some values to-sub buffer */
0298     assert_equal(Bgetrv(M_p_ub2, tmp_buf, 0, 
0299             T_UBF_FLD, 0, T_UBF_2_FLD, 0, T_STRING_4_FLD, 0, BBADFLDOCC), EXSUCCEED);
0300     
0301     assert_string_equal(tmp_buf, "HELLO4");
0302     
0303     assert_equal(CBget(M_p_ub2, T_PTR_FLD, 0, (char *)&l, 0, BFLD_LONG), EXSUCCEED);
0304     assert_equal(l, 0x55);
0305     
0306     /* Read view... & check values - occ 0*/
0307     memset(&v, 0, sizeof(v));
0308     vf.vname[0]=EXEOS;
0309     vf.data=(char *)&v;
0310     
0311     assert_equal(Bget(M_p_ub2, T_VIEW_FLD, 0, (char *)&vf, 0), EXSUCCEED);
0312     assert_string_equal(vf.vname, "UBTESTVIEW1");
0313     assert_string_equal(v.tcarray5, "TEST");
0314     
0315     /* occ 1 */
0316     memset(&v, 0, sizeof(v));
0317     vf.vname[0]=EXEOS;
0318     vf.data=(char *)&v;
0319     assert_equal(Bget(M_p_ub2, T_VIEW_FLD, 1, (char *)&vf, 0), EXSUCCEED);
0320     assert_string_equal(vf.vname, "UBTESTVIEW1");
0321     assert_string_equal(v.tcarray5, "SOME");
0322     
0323     
0324     /* test buffer full of FBs... */
0325     assert_equal(Binit(M_p_ub2, Bsizeof(M_p_ub2)), EXSUCCEED);
0326     
0327     i=0;
0328     while (EXSUCCEED==Badd(M_p_ub2, T_UBF_3_FLD, (char *)M_p_ub3, 0)){i++;}
0329     assert_equal(Berror, BNOSPACE);
0330     assert_not_equal(i, 0);
0331     
0332     
0333     /* test buffer full of ptrs */
0334     assert_equal(Binit(M_p_ub2, Bsizeof(M_p_ub2)), EXSUCCEED);
0335     
0336     i=0;
0337     while (EXSUCCEED==Badd(M_p_ub2, T_PTR_FLD, (char *)M_p_ub3, 0)){i++;}
0338     assert_equal(Berror, BNOSPACE);
0339     assert_not_equal(i, 0);
0340     
0341 }
0342 
0343 /**
0344  * Test of FAST add test
0345  * Single field in buffer
0346  */
0347 Ensure(test_Baddfast1)
0348 {
0349     Bfld_loc_info_t state;
0350     int i;
0351     char str[16];
0352     char buf1[56000];
0353     UBFH *p_ub1 = (UBFH *)buf1;
0354     
0355     char buf2[56000];
0356     UBFH *p_ub2 = (UBFH *)buf2;
0357 
0358     
0359     memset(buf1, 0, sizeof(buf1));
0360     memset(buf2, 0, sizeof(buf2));
0361     
0362     assert_equal(Binit(p_ub1, sizeof(buf1)), EXSUCCEED);
0363     assert_equal(Binit(p_ub2, sizeof(buf2)), EXSUCCEED);
0364     
0365     memset(&state, 0, sizeof(state));
0366     
0367     for (i=0; i<100; i++)
0368     {
0369     snprintf(str, sizeof(str), "%i", i);
0370     assert_equal(Baddfast(p_ub1, T_STRING_FLD, str, 0, &state), EXSUCCEED);
0371         assert_equal(Badd(p_ub2, T_STRING_FLD, str, 0), EXSUCCEED);
0372     }
0373     
0374     /* the buffer shall be equal */
0375     
0376     assert_equal(memcmp(buf1, buf2, sizeof(buf1)), 0);
0377     
0378 }
0379 
0380 /**
0381  * Test of FAST add test
0382  * Some field exists before and after 
0383  */
0384 Ensure(test_Baddfast2)
0385 {
0386     Bfld_loc_info_t state;
0387     int i;
0388     char str[16];
0389     char buf1[56000];
0390     UBFH *p_ub1 = (UBFH *)buf1;
0391     
0392     char buf2[56000];
0393     UBFH *p_ub2 = (UBFH *)buf2;
0394 
0395     
0396     memset(buf1, 0, sizeof(buf1));
0397     memset(buf2, 0, sizeof(buf2));
0398     
0399     assert_equal(Binit(p_ub1, sizeof(buf1)), EXSUCCEED);
0400     assert_equal(Binit(p_ub2, sizeof(buf2)), EXSUCCEED);
0401     
0402     
0403     
0404     assert_equal(Badd(p_ub1, T_STRING_2_FLD, "HELLO", 0), EXSUCCEED);
0405     assert_equal(Badd(p_ub2, T_STRING_2_FLD, "HELLO", 0), EXSUCCEED);
0406     
0407     assert_equal(CBadd(p_ub1, T_SHORT_FLD, "14", 0, BFLD_STRING), EXSUCCEED);
0408     assert_equal(CBadd(p_ub2, T_SHORT_FLD, "14", 0, BFLD_STRING), EXSUCCEED);
0409     
0410     assert_equal(CBadd(p_ub1, T_CARRAY_FLD, "WORLD", 0, BFLD_STRING), EXSUCCEED);
0411     assert_equal(CBadd(p_ub2, T_CARRAY_FLD, "WORLD", 0, BFLD_STRING), EXSUCCEED);
0412     
0413     /* now perform fast add */
0414     memset(&state, 0, sizeof(state));
0415     
0416     for (i=0; i<100; i++)
0417     {
0418     snprintf(str, sizeof(str), "%i", i);
0419     assert_equal(Baddfast(p_ub1, T_STRING_FLD, str, 0, &state), EXSUCCEED);
0420         assert_equal(Badd(p_ub2, T_STRING_FLD, str, 0), EXSUCCEED);
0421     }
0422     
0423     /* the buffer shall be equal */
0424     
0425     assert_equal(memcmp(buf1, buf2, sizeof(buf1)), 0);
0426     
0427     
0428     /* should fail if state is NULL */
0429     
0430     assert_equal(Baddfast(p_ub1, T_STRING_FLD, str, 0, NULL), EXFAIL);
0431     assert_equal(Berror, BEINVAL);
0432     
0433 }
0434 
0435 /**
0436  * Test invalid sequence of the fields, add string by fastadd, then then short
0437  */
0438 Ensure(test_Baddfast3)
0439 {
0440     Bfld_loc_info_t state;
0441     char buf1[56000];
0442     short s;
0443     UBFH *p_ub1 = (UBFH *)buf1;
0444     
0445     
0446     memset(buf1, 0, sizeof(buf1));
0447     memset(&state, 0, sizeof(state));
0448     assert_equal(Binit(p_ub1, sizeof(buf1)), EXSUCCEED);
0449     
0450     
0451     assert_equal(Baddfast(p_ub1, T_STRING_FLD, "DUM1", 0, &state), EXSUCCEED);
0452     assert_equal(Baddfast(p_ub1, T_STRING_FLD, "DUM2", 0, &state), EXSUCCEED);
0453     
0454     /* so what happens? */
0455     s=991;
0456     assert_equal(Baddfast(p_ub1, T_SHORT_FLD, (char *)&s, 0, &state), EXFAIL);
0457     assert_equal(Berror, BEINVAL);
0458     
0459 }
0460 
0461 Ensure(test_CBaddfast)
0462 {
0463     Bfld_loc_info_t state;
0464     char buf1[56000];
0465     short s;
0466     UBFH *p_ub1 = (UBFH *)buf1;
0467     char *tree = NULL;
0468     
0469     memset(buf1, 0, sizeof(buf1));
0470     memset(&state, 0, sizeof(state));
0471     assert_equal(Binit(p_ub1, sizeof(buf1)), EXSUCCEED);
0472     
0473     
0474     assert_equal(CBaddfast(p_ub1, T_SHORT_FLD, "1", 0, BFLD_STRING, &state), EXSUCCEED);
0475     assert_equal(CBaddfast(p_ub1, T_SHORT_FLD, "2", 0, BFLD_STRING, &state), EXSUCCEED);
0476     
0477     /* continues next: */
0478     assert_equal(CBaddfast(p_ub1, T_LONG_FLD, "3", 0, BFLD_STRING, &state), EXSUCCEED);
0479     assert_equal(CBaddfast(p_ub1, T_LONG_FLD, "4", 0, BFLD_STRING, &state), EXSUCCEED);
0480     
0481     s=5;
0482     assert_equal(CBaddfast(p_ub1, T_STRING_FLD, (char *)&s, 0, BFLD_SHORT, &state), EXSUCCEED);
0483     s=6;
0484     assert_equal(CBaddfast(p_ub1, T_STRING_FLD, (char *)&s, 0, BFLD_SHORT, &state), EXSUCCEED);
0485     
0486     assert_equal(CBaddfast(p_ub1, T_CARRAY_FLD, "HELLO", 0, BFLD_STRING, &state), EXSUCCEED);
0487     assert_equal(CBaddfast(p_ub1, T_CARRAY_FLD, "WORLD", 0, BFLD_STRING, &state), EXSUCCEED);
0488     
0489     /* test some errors */
0490     assert_equal(CBaddfast(p_ub1, T_UBF_FLD, "1", 0, BFLD_UBF, &state), EXFAIL);
0491     assert_equal(Berror, BEBADOP);
0492     assert_equal(CBaddfast(p_ub1, T_UBF_FLD, "2", 0, BFLD_UBF, &state), EXFAIL);
0493     assert_equal(Berror, BEBADOP);
0494     
0495     /* validate the buffer */
0496     tree=Bboolco ("T_SHORT_FLD[0]==1 && T_SHORT_FLD[1]==2 && T_LONG_FLD[0]==3 && T_LONG_FLD[1]==4 &&"
0497                 "T_STRING_FLD[0]=='5' && T_STRING_FLD[1]=='6' && T_CARRAY_FLD[0]=='HELLO' &&"
0498                 " T_CARRAY_FLD[1]=='WORLD'");
0499     assert_not_equal(tree, NULL);
0500     assert_equal(Bboolev(p_ub1, tree), EXTRUE);
0501     Btreefree(tree);
0502 }
0503 
0504 
0505 
0506 /**
0507  * Test FML wrapper
0508  * i.e. FLD_PTR logic is different for FML.
0509  */
0510 Ensure(test_Fadd)
0511 {
0512     char buf1[56000];
0513     char buf_ptr1[100];
0514     char buf_ptr2[100];
0515     char *ptr_get = NULL;
0516     long l;
0517     BFLDLEN len;
0518     UBFH *p_ub1 = (UBFH *)buf1;
0519     
0520     memset(buf1, 0, sizeof(buf1));
0521     assert_equal(Binit(p_ub1, sizeof(buf1)), EXSUCCEED);
0522     
0523     /* Load ptr */
0524     assert_equal(Fadd(p_ub1, T_PTR_FLD, buf_ptr1, 0), EXSUCCEED);
0525     assert_equal(Fadd32(p_ub1, T_PTR_FLD, buf_ptr2, 0), EXSUCCEED);
0526 
0527     l=999;
0528     assert_equal(Fadd(p_ub1, T_LONG_FLD, (char *)&l, 0), EXSUCCEED);
0529     l=888;
0530     assert_equal(Fadd(p_ub1, T_LONG_FLD, (char *)&l, 0), EXSUCCEED);
0531     
0532     assert_equal(Fadd(p_ub1, T_STRING_FLD, "HELLO 1", 0), EXSUCCEED);
0533     assert_equal(Fadd32(p_ub1, T_STRING_FLD, "HELLO 2", 0), EXSUCCEED);
0534     
0535     assert_equal(Fadd(p_ub1, T_CARRAY_FLD, "ABCD", 1), EXSUCCEED);
0536     assert_equal(Fadd32(p_ub1, T_CARRAY_FLD, "CDE", 1), EXSUCCEED);
0537     
0538     /* Validate the data.., ptr */
0539     assert_equal(Bget(p_ub1, T_PTR_FLD, 0, (char *)&ptr_get, 0), EXSUCCEED);
0540     assert_equal(ptr_get, buf_ptr1);
0541     
0542     assert_equal(Bget(p_ub1, T_PTR_FLD, 1, (char *)&ptr_get, 0), EXSUCCEED);
0543     assert_equal(ptr_get, buf_ptr2);
0544     
0545     /* validate string */
0546     assert_equal(Bget(p_ub1, T_STRING_FLD, 0, buf_ptr1, 0), EXSUCCEED);
0547     assert_string_equal(buf_ptr1, "HELLO 1");
0548     
0549     assert_equal(Bget(p_ub1, T_STRING_FLD, 1, buf_ptr1, 0), EXSUCCEED);
0550     assert_string_equal(buf_ptr1, "HELLO 2");
0551     
0552     assert_equal(CBget(p_ub1, T_CARRAY_FLD, 0, buf_ptr1, 0, BFLD_STRING), EXSUCCEED);
0553     assert_string_equal(buf_ptr1, "A");
0554     
0555     assert_equal(CBget(p_ub1, T_CARRAY_FLD, 1, buf_ptr1, 0, BFLD_STRING), EXSUCCEED);
0556     assert_string_equal(buf_ptr1, "C");
0557     
0558     /* validate long */
0559     
0560     assert_equal(Bget(p_ub1, T_LONG_FLD, 0, (char *)&l, 0), EXSUCCEED);
0561     assert_equal(l, 999);
0562     
0563     assert_equal(Bget(p_ub1, T_LONG_FLD, 1, (char *)&l, 0), EXSUCCEED);
0564     assert_equal(l, 888);
0565         
0566 }
0567 /**
0568  * Common suite entry
0569  * @return
0570  */
0571 TestSuite *ubf_Badd_tests(void)
0572 {
0573     TestSuite *suite = create_test_suite();
0574 
0575     set_setup(suite, basic_setup1);
0576     set_teardown(suite, basic_teardown1);
0577 
0578     add_test(suite, test_Badd_str);
0579     add_test(suite, test_Baddfast1);
0580     add_test(suite, test_Baddfast2);
0581     add_test(suite, test_Baddfast3);
0582     add_test(suite, test_CBaddfast);
0583     
0584     add_test(suite, test_Badd_ubf);
0585     add_test(suite, test_Fadd);
0586 
0587     return suite;
0588 }
0589 /* vim: set ts=4 sw=4 et smartindent: */