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