MySQL 5.6.14 Source Code Document
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
ndb_test_platform.cpp
1
/*
2
Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
3
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; version 2 of the License.
7
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
GNU General Public License for more details.
12
13
You should have received a copy of the GNU General Public License
14
along with this program; if not, write to the Free Software
15
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16
*/
17
18
19
#include <ndb_global.h>
20
#include <BaseString.hpp>
21
22
/*
23
* Test BaseString::snprintf
24
*/
25
26
static
27
int
test_snprintf(
const
char
*
fmt
,
int
buf_sz,
int
result)
28
{
29
int
ret
;
30
char
buf
[100];
31
ret =
BaseString::snprintf
(buf, buf_sz,
"%s"
, fmt);
32
33
if
(ret < 0)
34
{
35
printf(
"BaseString::snprint returns %d with size=%d and strlen(fmt)=%d\n"
,
36
ret, buf_sz, (
int
) strlen(fmt));
37
return
-1;
38
}
39
40
if
(ret+1 == buf_sz)
41
{
42
printf(
"BaseString::snprint truncates returns %d with size=%d and strlen(fmt)=%d\n"
,
43
ret, buf_sz, (
int
) strlen(fmt));
44
return
-1;
45
}
46
47
if
(ret != result)
48
{
49
printf(
"BaseString::snprint returns incorrect value: returned=%d != expected=%d\n"
,
50
ret, result);
51
return
-1;
52
}
53
54
for
(ret = 0; ret+1 < buf_sz && ret < result; ret++)
55
{
56
if
(buf[ret] != fmt[ret])
57
{
58
printf(
"BaseString::snprint Incorrect value in output buffer: "
59
"size=%d returned=expected=%d at pos=%d result=%d != expected=%d\n"
,
60
buf_sz, result, ret, buf[ret], fmt[ret]);
61
return
-1;
62
}
63
}
64
return
0;
65
}
66
67
int
68
main(
void
)
69
{
70
71
printf(
"ndb_test_platform - tests for snprintf and pointer size\n"
);
72
/*
73
* Test BaseString::snprintf
74
*/
75
76
if
(test_snprintf(
"test"
, 1, 4))
77
return
-1;
78
79
if
(test_snprintf(
"test"
, 0, 4))
80
return
-1;
81
82
if
(test_snprintf(
"test"
, 100, 4))
83
return
-1;
84
85
/*
86
* Test UintPtr
87
*/
88
89
if
(
sizeof
(UintPtr) !=
sizeof
(Uint32*))
90
{
91
printf(
"sizeof(UintPtr)=%d != sizeof(Uint32*)=%d\n"
,
92
(
int
)
sizeof
(UintPtr), (
int
)
sizeof
(Uint32*));
93
return
-1;
94
}
95
96
return
0;
97
}
storage
ndb
tools
ndb_test_platform.cpp
Generated on Sat Nov 9 2013 01:28:37 for MySQL 5.6.14 Source Code Document by
1.8.1.2