#include <ndb_global.h>#include <my_sys.h>#include <BaseString.hpp>Include dependency graph for ndb_test_platform.cpp:

Go to the source code of this file.
Functions | |
| static int | test_snprintf (const char *fmt, int buf_sz, int result) |
| int | main (void) |
| int main | ( | void | ) |
Definition at line 68 of file ndb_test_platform.cpp.
References test_snprintf().
00069 { 00070 /* 00071 * Test BaseString::snprintf 00072 */ 00073 00074 if(test_snprintf("test", 1, 4)) 00075 return -1; 00076 00077 if(test_snprintf("test", 0, 4)) 00078 return -1; 00079 00080 if(test_snprintf("test", 100, 4)) 00081 return -1; 00082 00083 /* 00084 * Test UintPtr 00085 */ 00086 00087 if (sizeof(UintPtr) != sizeof(Uint32*)) 00088 { 00089 printf("sizeof(UintPtr)=%d != sizeof(Uint32*)=%d\n", 00090 (int) sizeof(UintPtr), (int) sizeof(Uint32*)); 00091 return -1; 00092 } 00093 00094 return 0; 00095 }
Here is the call graph for this function:

| static int test_snprintf | ( | const char * | fmt, | |
| int | buf_sz, | |||
| int | result | |||
| ) | [static] |
Definition at line 27 of file ndb_test_platform.cpp.
References buf, BaseString::snprintf(), and strlen().
Referenced by main().
00028 { 00029 int ret; 00030 char buf[100]; 00031 ret = BaseString::snprintf(buf, buf_sz, fmt); 00032 00033 if(ret < 0) 00034 { 00035 printf("BaseString::snprint returns %d with size=%d and strlen(fmt)=%d\n", 00036 ret, buf_sz, (int) strlen(fmt)); 00037 return -1; 00038 } 00039 00040 if(ret+1 == buf_sz) 00041 { 00042 printf("BaseString::snprint truncates returns %d with size=%d and strlen(fmt)=%d\n", 00043 ret, buf_sz, (int) strlen(fmt)); 00044 return -1; 00045 } 00046 00047 if(ret != result) 00048 { 00049 printf("BaseString::snprint returns incorrect value: returned=%d != expected=%d\n", 00050 ret, result); 00051 return -1; 00052 } 00053 00054 for(ret = 0; ret+1 < buf_sz && ret < result; ret++) 00055 { 00056 if(buf[ret] != fmt[ret]) 00057 { 00058 printf("BaseString::snprint Incorrect value in output buffer: " 00059 "size=%d returned=expected=%d at pos=%d result=%d != expected=%d\n", 00060 buf_sz, result, ret, buf[ret], fmt[ret]); 00061 return -1; 00062 } 00063 } 00064 return 0; 00065 }
Here is the call graph for this function:

Here is the caller graph for this function:

1.4.7

