Back to home page

Enduro/X

 
 

    


0001 /**
0002  *
0003  * @file test_cbget.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-2018, 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 3 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 <ubf.h>
0037 #include <ndrstandard.h>
0038 #include <string.h>
0039 #include "test.fd.h"
0040 #include "ubfunit1.h"
0041 
0042 
0043 /**
0044  * Original field is BFLD_SHORT => T_SHORT_FLD
0045  */
0046 Ensure(test_CBget_short_org)
0047 {
0048     char buf[640];
0049     UBFH *p_ub = (UBFH *)buf;
0050     short test_val=4564;
0051     int len = 0;
0052     short small_val=44;
0053     /* test buffers */
0054     short test_short = 0;
0055     long test_long = 0;
0056     char test_char = 0;
0057     float test_float = 0.0;
0058     double test_double = 0.0;
0059     char test_string[128];
0060     char test_carray[128];
0061 
0062     /* init */
0063     assert_equal(Binit(p_ub, sizeof(buf)), EXSUCCEED);
0064     len = sizeof(test_val);
0065     assert_equal(Badd(p_ub, T_SHORT_FLD, (char *)&test_val, len), EXSUCCEED);
0066 
0067     /* Now test all types */
0068     /* short out */
0069     len=sizeof(test_short);
0070     assert_equal(CBget(p_ub, T_SHORT_FLD, 0, (char *)&test_short, &len, BFLD_SHORT), EXSUCCEED);
0071     assert_equal(test_short, 4564);
0072     assert_equal(len, sizeof(test_short));
0073     /* long out */
0074     len=sizeof(test_long);
0075     assert_equal(CBget(p_ub, T_SHORT_FLD, 0, (char *)&test_long, &len, BFLD_LONG), EXSUCCEED);
0076     assert_equal(test_long, 4564);
0077     assert_equal(len, sizeof(test_long));
0078     /* char out */
0079     assert_equal(Bchg(p_ub, T_SHORT_FLD, 0, (char *)&small_val, 0), EXSUCCEED);
0080     assert_equal(CBget(p_ub, T_SHORT_FLD, 0, (char *)&test_char, 0, BFLD_CHAR), EXSUCCEED);
0081     assert_equal(test_char, ',');
0082     assert_equal(Bchg(p_ub, T_SHORT_FLD, 0, (char *)&test_val, 0), EXSUCCEED); /* restore back */
0083     /* test float */
0084     len=sizeof(test_float);
0085     assert_equal(CBget(p_ub, T_SHORT_FLD, 0, (char *)&test_float, &len, BFLD_FLOAT), EXSUCCEED);
0086     assert_equal(test_float, 4564);
0087     assert_equal(len, sizeof(test_float));
0088     /* test double */
0089     assert_equal(CBget(p_ub, T_SHORT_FLD, 0, (char *)&test_double, 0, BFLD_DOUBLE), EXSUCCEED);
0090     assert_equal(test_float, 4564);
0091     /* test string */
0092     len=sizeof(test_string);
0093     assert_equal(CBget(p_ub, T_SHORT_FLD, 0, (char *)test_string, &len, BFLD_STRING), EXSUCCEED);
0094     assert_string_equal(test_string, "4564");
0095     assert_equal(len, 5);
0096     /* test carray */
0097     assert_equal(CBget(p_ub, T_SHORT_FLD, 0, (char *)test_carray, 0, BFLD_CARRAY), EXSUCCEED);
0098     assert_equal(strncmp(test_carray, "4564", 4), 0);
0099 }
0100 
0101 /**
0102  * Original field is BFLD_LONG => T_LONG_FLD
0103  */
0104 Ensure(test_CBget_long_org)
0105 {
0106     char buf[640];
0107     UBFH *p_ub = (UBFH *)buf;
0108     long test_val=456412;
0109     int len = 0;
0110     long small_val=44;
0111     /* test buffers */
0112     short test_short = 0;
0113     long test_long = 0;
0114     char test_char = 0;
0115     float test_float = 0.0;
0116     double test_double = 0.0;
0117     char test_string[128];
0118     char test_carray[128];
0119 
0120     /* init */
0121     assert_equal(Binit(p_ub, sizeof(buf)), EXSUCCEED);
0122     len = sizeof(test_val);
0123     assert_equal(Badd(p_ub, T_LONG_FLD, (char *)&small_val, len), EXSUCCEED);
0124 
0125     /* Now test all types */
0126     /* short out */
0127     len=sizeof(test_short);
0128     assert_equal(CBget(p_ub, T_LONG_FLD, 0, (char *)&test_short, &len, BFLD_SHORT), EXSUCCEED);
0129     assert_equal(test_short, 44);
0130     assert_equal(len, sizeof(test_short));
0131     /* char out */
0132     len=sizeof(test_char);
0133     assert_equal(CBget(p_ub, T_LONG_FLD, 0, (char *)&test_char, &len, BFLD_CHAR), EXSUCCEED);
0134     assert_equal(test_char, ',');
0135     assert_equal(Bchg(p_ub, T_LONG_FLD, 0, (char *)&test_val, 0), EXSUCCEED); /* restore back */
0136     assert_equal(len, sizeof(test_char));
0137 
0138     /* long out */
0139     len=sizeof(test_long);
0140     assert_equal(CBget(p_ub, T_LONG_FLD, 0, (char *)&test_long, &len, BFLD_LONG), EXSUCCEED);
0141     assert_equal(test_long, 456412);
0142     assert_equal(len, sizeof(test_long));
0143     /* test float */
0144     len=sizeof(test_float);
0145     assert_equal(CBget(p_ub, T_LONG_FLD, 0, (char *)&test_float, &len, BFLD_FLOAT), EXSUCCEED);
0146     assert_equal(test_float, 456412);
0147     assert_equal(len, sizeof(test_float));
0148     /* test double */
0149     len=sizeof(test_double);
0150     assert_equal(CBget(p_ub, T_LONG_FLD, 0, (char *)&test_double, &len, BFLD_DOUBLE), EXSUCCEED);
0151     assert_equal(test_float, 456412);
0152     assert_equal(len, sizeof(test_double));
0153     /* test string */
0154     len=sizeof(test_string);
0155     assert_equal(CBget(p_ub, T_LONG_FLD, 0, (char *)test_string, &len, BFLD_STRING), EXSUCCEED);
0156     assert_string_equal(test_string, "456412");
0157     assert_equal(len, 7);
0158     /* test carray */
0159     len=sizeof(test_string);
0160     assert_equal(CBget(p_ub, T_LONG_FLD, 0, (char *)test_carray, &len, BFLD_CARRAY), EXSUCCEED);
0161     assert_equal(strncmp(test_carray, "456412", 6), 0);
0162     assert_equal(len, 6);
0163 }
0164 
0165 /**
0166  * Original field is BFLD_CHAR => T_CHAR_FLD
0167  */
0168 Ensure(test_CBget_char_org)
0169 {
0170     char buf[640];
0171     UBFH *p_ub = (UBFH *)buf;
0172     long test_val=456412;
0173     int len = 0;
0174     long small_val=0;
0175     /* test buffers */
0176     short test_short = 0;
0177     long test_long = 0;
0178     char test_char = 'r';
0179     float test_float = 0.0;
0180     double test_double = 0.0;
0181     char test_string[128];
0182     char test_carray[128];
0183 
0184     /* init */
0185     assert_equal(Binit(p_ub, sizeof(buf)), EXSUCCEED);
0186     len = sizeof(test_val);
0187     assert_equal(Badd(p_ub, T_CHAR_FLD, (char *)&test_char, len), EXSUCCEED);
0188 
0189     /* Now test all types */
0190     /* short out */
0191     len=sizeof(test_short);
0192     assert_equal(CBget(p_ub, T_CHAR_FLD, 0, (char *)&test_short, &len, BFLD_SHORT), EXSUCCEED);
0193     assert_equal(test_short, 114);
0194     assert_equal(len, sizeof(test_short));
0195 
0196     /* long out */
0197     len=sizeof(test_long);
0198     assert_equal(CBget(p_ub, T_CHAR_FLD, 0, (char *)&test_long, &len, BFLD_LONG), EXSUCCEED);
0199     assert_equal(test_long, 114);
0200     assert_equal(len, sizeof(test_long));
0201 
0202     /* char out */
0203     len=sizeof(test_char);
0204     assert_equal(CBget(p_ub, T_CHAR_FLD, 0, (char *)&test_char, &len, BFLD_CHAR), EXSUCCEED);
0205     assert_equal(test_char, 'r');
0206     assert_equal(len, sizeof(test_char));
0207 
0208     /* test float */
0209     len=sizeof(test_float);
0210     assert_equal(CBget(p_ub, T_CHAR_FLD, 0, (char *)&test_float, &len, BFLD_FLOAT), EXSUCCEED);
0211     assert_equal(test_float, 114);
0212     assert_equal(len, sizeof(test_float));
0213 
0214     /* test double */
0215     len=sizeof(test_double);
0216     assert_equal(CBget(p_ub, T_CHAR_FLD, 0, (char *)&test_double, &len, BFLD_DOUBLE), EXSUCCEED);
0217     assert_equal(test_float, 114);
0218     assert_equal(len, sizeof(test_double));
0219 
0220     /* test string */
0221     len=sizeof(test_string);
0222     assert_equal(CBget(p_ub, T_CHAR_FLD, 0, (char *)test_string, &len, BFLD_STRING), EXSUCCEED);
0223     assert_string_equal(test_string, "r");
0224     assert_equal(len, 2);
0225 
0226     /* test carray */
0227     len=sizeof(test_string);
0228     assert_equal(CBget(p_ub, T_CHAR_FLD, 0, (char *)test_carray, &len, BFLD_CARRAY), EXSUCCEED);
0229     assert_equal(strncmp(test_carray, "r", 1), 0);
0230     assert_equal(len, 1);   
0231 }
0232 
0233 /**
0234  * Original field is BFLD_FLOAT => T_FLOAT_FLD
0235  */
0236 Ensure(test_CBget_float_org)
0237 {
0238     char buf[640];
0239     UBFH *p_ub = (UBFH *)buf;
0240     long test_val=0;
0241     int len = 0;
0242     /* test buffers */
0243     short test_short = 0;
0244     long test_long = 0;
0245     unsigned char test_char = 0;
0246     float test_float = 16822.5;
0247     double test_double = 0.0;
0248     char test_string[128];
0249     char test_carray[128];
0250 
0251     /* init */
0252     assert_equal(Binit(p_ub, sizeof(buf)), EXSUCCEED);
0253     len = sizeof(test_float);
0254     assert_equal(Badd(p_ub, T_FLOAT_FLD, (char *)&test_float, len), EXSUCCEED);
0255 
0256     /* Now test all types */
0257     /* short out */
0258     len=sizeof(test_short);
0259     assert_equal(CBget(p_ub, T_FLOAT_FLD, 0, (char *)&test_short, &len, BFLD_SHORT), EXSUCCEED);
0260     assert_equal(test_short, 16822);
0261     assert_equal(len, sizeof(test_short));
0262 
0263     /* long out */
0264     len=sizeof(test_long);
0265     assert_equal(CBget(p_ub, T_FLOAT_FLD, 0, (char *)&test_long, &len, BFLD_LONG), EXSUCCEED);
0266     assert_equal(test_long, 16822);
0267     assert_equal(len, sizeof(test_long));
0268 
0269     /* char out */
0270 
0271     len = sizeof(test_float);
0272     test_float = 168.5;
0273     assert_equal(Bchg(p_ub, T_FLOAT_FLD, 0, (char *)&test_float, len), EXSUCCEED);
0274     len=sizeof(test_char);
0275     assert_equal(CBget(p_ub, T_FLOAT_FLD, 0, (char *)&test_char, &len, BFLD_CHAR), EXSUCCEED);
0276     assert_equal(test_char, 168);
0277     assert_equal(len, sizeof(test_char));
0278 
0279     /* test float */
0280     /* continue as normal */
0281     len = sizeof(test_float);
0282     test_float = 16822.5;
0283     assert_equal(Bchg(p_ub, T_FLOAT_FLD, 0, (char *)&test_float, len), EXSUCCEED);
0284 
0285     len=sizeof(test_float);
0286     assert_equal(CBget(p_ub, T_FLOAT_FLD, 0, (char *)&test_float, &len, BFLD_FLOAT), EXSUCCEED);
0287     assert_equal(test_float, 16822.5);
0288     assert_equal(len, sizeof(test_float));
0289 
0290     /* test double */
0291     len=sizeof(test_double);
0292     assert_equal(CBget(p_ub, T_FLOAT_FLD, 0, (char *)&test_double, &len, BFLD_DOUBLE), EXSUCCEED);
0293     assert_equal(test_float, 16822.5);
0294     assert_equal(len, sizeof(test_double));
0295 
0296     /* test string */
0297     len=sizeof(test_string);
0298     assert_equal(CBget(p_ub, T_FLOAT_FLD, 0, (char *)test_string, &len, BFLD_STRING), EXSUCCEED);
0299     assert_string_equal(test_string, "16822.50000");
0300     assert_equal(len, 12);
0301 
0302     /* test carray */
0303     len=sizeof(test_string);
0304     assert_equal(CBget(p_ub, T_FLOAT_FLD, 0, (char *)test_carray, &len, BFLD_CARRAY), EXSUCCEED);
0305     assert_equal(strncmp(test_carray, "16822.50000", 10), 0);
0306     assert_equal(len, 11);
0307 }
0308 
0309 /**
0310  * Original field is BFLD_DOUBLE => T_DOUBLE_FLD
0311  */
0312 Ensure(test_CBget_double_org)
0313 {
0314     char buf[640];
0315     UBFH *p_ub = (UBFH *)buf;
0316     int len = 0;
0317     /* test buffers */
0318     short test_short = 0;
0319     long test_long = 0;
0320     unsigned char test_char = 0;
0321     float test_float = 0.0;
0322     double test_double = 16822.5;
0323     char test_string[128];
0324     char test_carray[128];
0325 
0326     /* init */
0327     assert_equal(Binit(p_ub, sizeof(buf)), EXSUCCEED);
0328     len = sizeof(test_double);
0329     assert_equal(Badd(p_ub, T_DOUBLE_FLD, (char *)&test_double, len), EXSUCCEED);
0330 
0331     /* Now test all types */
0332     /* short out */
0333     len=sizeof(test_short);
0334     assert_equal(CBget(p_ub, T_DOUBLE_FLD, 0, (char *)&test_short, &len, BFLD_SHORT), EXSUCCEED);
0335     assert_equal(test_short, 16822);
0336     assert_equal(len, sizeof(test_short));
0337 
0338     /* long out */
0339     len=sizeof(test_long);
0340     assert_equal(CBget(p_ub, T_DOUBLE_FLD, 0, (char *)&test_long, &len, BFLD_LONG), EXSUCCEED);
0341     assert_equal(test_long, 16822);
0342     assert_equal(len, sizeof(test_long));
0343 
0344     /* char out */
0345     len = sizeof(test_double);
0346     test_double = 168.5;
0347     assert_equal(Bchg(p_ub, T_DOUBLE_FLD, 0, (char *)&test_double, len), EXSUCCEED);
0348     
0349     len=sizeof(test_char);
0350     assert_equal(CBget(p_ub, T_DOUBLE_FLD, 0, (char *)&test_char, &len, BFLD_CHAR), EXSUCCEED);
0351     assert_equal(test_char, 168);
0352     assert_equal(len, sizeof(test_char));
0353 
0354     /* test float */
0355     /* continue as normal */
0356     test_double = 16822.5;
0357     len = sizeof(test_double);
0358     assert_equal(Bchg(p_ub, T_DOUBLE_FLD, 0, (char *)&test_double, len), EXSUCCEED);
0359 
0360     len=sizeof(test_float);
0361     assert_equal(CBget(p_ub, T_DOUBLE_FLD, 0, (char *)&test_float, &len, BFLD_FLOAT), EXSUCCEED);
0362     assert_equal(test_float, 16822.5);
0363     assert_equal(len, sizeof(test_float));
0364 
0365     /* test double */
0366     len=sizeof(test_double);
0367     assert_equal(CBget(p_ub, T_DOUBLE_FLD, 0, (char *)&test_double, &len, BFLD_DOUBLE), EXSUCCEED);
0368     assert_equal(test_float, 16822.5);
0369     assert_equal(len, sizeof(test_double));
0370 
0371     /* test string */
0372     len=sizeof(test_string);
0373     assert_equal(CBget(p_ub, T_DOUBLE_FLD, 0, (char *)test_string, &len, BFLD_STRING), EXSUCCEED);
0374     assert_string_equal(test_string, "16822.500000");
0375     assert_equal(len, 13);
0376 
0377     /* test carray */
0378     len=sizeof(test_string);
0379     assert_equal(CBget(p_ub, T_DOUBLE_FLD, 0, (char *)test_carray, &len, BFLD_CARRAY), EXSUCCEED);
0380     assert_equal(strncmp(test_carray, "16822.500000", 10), 0);
0381     assert_equal(len, 12);
0382 }
0383 /**
0384  * Original field is BFLD_STRING => T_STRING_FLD
0385  */
0386 Ensure(test_CBget_string_org)
0387 {
0388     char buf[2048];
0389     UBFH *p_ub = (UBFH *)buf;
0390     int len = 0;
0391     /* test buffers */
0392     short test_short = 0;
0393     long test_long = 0;
0394     unsigned char test_char = 0;
0395     float test_float = 0.0;
0396     double test_double = 16822.5;
0397     char test_string[1024];
0398     char test_carray[1024];
0399 
0400     /* init */
0401     assert_equal(Binit(p_ub, sizeof(buf)), EXSUCCEED);
0402     /*  len 1 - should be ok, because it is ignored!*/
0403     assert_equal(Badd(p_ub, T_STRING_FLD, "16822.5000000000000", 1), EXSUCCEED);
0404 
0405     /* Now test all types */
0406     /* short out */
0407     len=sizeof(test_short);
0408     assert_equal(CBget(p_ub, T_STRING_FLD, 0, (char *)&test_short, &len, BFLD_SHORT), EXSUCCEED);
0409     assert_equal(test_short, 16822);
0410     assert_equal(len, sizeof(test_short));
0411 
0412     /* long out */
0413     len=sizeof(test_long);
0414     assert_equal(CBget(p_ub, T_STRING_FLD, 0, (char *)&test_long, &len, BFLD_LONG), EXSUCCEED);
0415     assert_equal(test_long, 16822);
0416     assert_equal(len, sizeof(test_long));
0417 
0418     /* char out */
0419     len=sizeof(test_char);
0420     assert_equal(CBget(p_ub, T_STRING_FLD, 0, (char *)&test_char, &len, BFLD_CHAR), EXSUCCEED);
0421     assert_equal(test_char, '1');
0422     assert_equal(len, sizeof(test_char));
0423 
0424     /* test float */
0425     len=sizeof(test_float);
0426     assert_equal(CBget(p_ub, T_STRING_FLD, 0, (char *)&test_float, &len, BFLD_FLOAT), EXSUCCEED);
0427     assert_equal(test_float, 16822.5);
0428     assert_equal(len, sizeof(test_float));
0429 
0430     /* test double */
0431     len=sizeof(test_double);
0432     assert_equal(CBget(p_ub, T_STRING_FLD, 0, (char *)&test_double, &len, BFLD_DOUBLE), EXSUCCEED);
0433     assert_equal(test_float, 16822.5);
0434     assert_equal(len, sizeof(test_double));
0435 
0436     /* test string */
0437     len=sizeof(test_string);
0438     assert_equal(CBget(p_ub, T_STRING_FLD, 0, (char *)test_string, &len, BFLD_STRING), EXSUCCEED);
0439     assert_string_equal(test_string, "16822.5000000000000");
0440     assert_equal(len, 20);
0441 
0442     /* test carray */
0443     len=sizeof(test_string);
0444     assert_equal(CBget(p_ub, T_STRING_FLD, 0, (char *)test_carray, &len, BFLD_CARRAY), EXSUCCEED);
0445     assert_equal(strncmp(test_carray, "16822.5000000000000", 17), 0);
0446     assert_equal(len, 19);
0447     
0448     /* Special test for hadling strings & carrays */
0449     assert_equal(Bchg(p_ub, T_STRING_FLD, 0, BIG_TEST_STRING, 0), EXSUCCEED);
0450     len=sizeof(test_carray);
0451     assert_equal(CBget(p_ub, T_STRING_FLD, 0, (char *)test_carray, &len, BFLD_CARRAY), EXSUCCEED);
0452     assert_equal(strncmp(test_carray, BIG_TEST_STRING, strlen(BIG_TEST_STRING)), 0);
0453     assert_equal(len, strlen(BIG_TEST_STRING));
0454     
0455 }
0456 
0457 /**
0458  * Original field is BFLD_CARRAY => T_CARRAY_FLD
0459  */
0460 Ensure(test_CBget_carray_org)
0461 {
0462     char buf[2048];
0463     UBFH *p_ub = (UBFH *)buf;
0464     int len = 0;
0465     /* test buffers */
0466     short test_short = 0;
0467     long test_long = 0;
0468     unsigned char test_char = 0;
0469     float test_float = 0.0;
0470     double test_double = 16822.5;
0471     char test_string[1024];
0472     char test_carray[1024];
0473     char test_data_str [] = "16822.5000000000000";
0474     /* init */
0475     assert_equal(Binit(p_ub, sizeof(buf)), EXSUCCEED);
0476     len = strlen(test_data_str);
0477     assert_equal(Badd(p_ub, T_CARRAY_FLD, test_data_str, len), EXSUCCEED);
0478 
0479     /* Now test all types */
0480     /* short out */
0481     len=sizeof(test_short);
0482     assert_equal(CBget(p_ub, T_CARRAY_FLD, 0, (char *)&test_short, &len, BFLD_SHORT), EXSUCCEED);
0483     assert_equal(test_short, 16822);
0484     assert_equal(len, sizeof(test_short));
0485 
0486     /* long out */
0487     len=sizeof(test_long);
0488     assert_equal(CBget(p_ub, T_CARRAY_FLD, 0, (char *)&test_long, &len, BFLD_LONG), EXSUCCEED);
0489     assert_equal(test_long, 16822);
0490     assert_equal(len, sizeof(test_long));
0491 
0492     /* char out */
0493     len=sizeof(test_char);
0494     assert_equal(CBget(p_ub, T_CARRAY_FLD, 0, (char *)&test_char, &len, BFLD_CHAR), EXSUCCEED);
0495     assert_equal(test_char, '1');
0496     assert_equal(len, sizeof(test_char));
0497 
0498     /* test float */
0499     len=sizeof(test_float);
0500     assert_equal(CBget(p_ub, T_CARRAY_FLD, 0, (char *)&test_float, &len, BFLD_FLOAT), EXSUCCEED);
0501     assert_equal(test_float, 16822.5);
0502     assert_equal(len, sizeof(test_float));
0503 
0504     /* test double */
0505     len=sizeof(test_double);
0506     assert_equal(CBget(p_ub, T_CARRAY_FLD, 0, (char *)&test_double, &len, BFLD_DOUBLE), EXSUCCEED);
0507     assert_equal(test_float, 16822.5);
0508     assert_equal(len, sizeof(test_double));
0509 
0510     /* test string */
0511     len=sizeof(test_string);
0512     assert_equal(CBget(p_ub, T_CARRAY_FLD, 0, (char *)test_string, &len, BFLD_STRING), EXSUCCEED);
0513     assert_string_equal(test_string, test_data_str);
0514     assert_equal(len, 20);
0515 
0516     /* test carray */
0517     len=sizeof(test_string);
0518     assert_equal(CBget(p_ub, T_CARRAY_FLD, 0, (char *)test_carray, &len, BFLD_CARRAY), EXSUCCEED);
0519     assert_equal(strncmp(test_carray, test_data_str, 17), 0);
0520     assert_equal(len, 19);
0521 
0522     /* Special test for hadling strings & carrays */
0523     len = strlen(BIG_TEST_STRING);
0524     assert_equal(Bchg(p_ub, T_CARRAY_FLD, 0, BIG_TEST_STRING, len), EXSUCCEED);
0525     len=sizeof(test_string);
0526     memset(test_string, 0xff, sizeof(test_string)); /* For checking EOS terminator */
0527     assert_equal(CBget(p_ub, T_CARRAY_FLD, 0, (char *)test_string, &len, BFLD_STRING), EXSUCCEED);
0528     assert_equal(strncmp(test_string, BIG_TEST_STRING, strlen(BIG_TEST_STRING)), 0);
0529     assert_equal(len, strlen(BIG_TEST_STRING)+1);
0530     assert_equal(strlen(test_string), strlen(BIG_TEST_STRING));
0531 }
0532 
0533 TestSuite *ubf_cfget_tests(void)
0534 {
0535     TestSuite *suite = create_test_suite();
0536     
0537     add_test(suite, test_CBget_short_org);
0538     add_test(suite, test_CBget_long_org);
0539     add_test(suite, test_CBget_char_org);
0540     add_test(suite, test_CBget_float_org);
0541     add_test(suite, test_CBget_double_org);
0542     add_test(suite, test_CBget_string_org);
0543     add_test(suite, test_CBget_carray_org);
0544     
0545     /* string & carray */
0546 
0547     return suite;
0548 }
0549