MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mysys_my_malloc-t.cc
1 /* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 
16 // First include (the generated) my_config.h, to get correct platform defines.
17 #include "my_config.h"
18 #include <gtest/gtest.h>
19 
20 #include <my_global.h>
21 #include <my_sys.h>
22 
23 namespace mysys_my_malloc_unittest {
24 
25 TEST(Mysys, Malloc)
26 {
27  void *p;
28 
29  p= my_malloc(0, MYF(0));
30  EXPECT_TRUE(p != NULL) << "Zero-sized block allocation.";
31 
32  p= my_realloc(p, 32, MYF(0));
33  EXPECT_TRUE(p != NULL) << "Reallocated zero-sized block.";
34 
35  p= my_realloc(p, 16, MYF(0));
36  EXPECT_TRUE(p != NULL) << "Trimmed block.";
37 
38  my_free(p);
39  p= NULL;
40 
41  my_free(p);
42 }
43 
44 }