MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
delayable_insert_operation-t.cc
1 /* Copyright (c) 2011, 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 Foundation,
14  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
15 
16 #include "my_config.h"
17 #include <gtest/gtest.h>
18 #include "delayable_insert_operation.h"
19 
20 namespace
21 {
22 
23 class Mock_delayable: public Delayable_insert_operation
24 {
25 public:
26  Mock_delayable() : Delayable_insert_operation() {}
27 
29 };
30 
31 
32 TEST(DelayableInsertOperation, SetDupAndIgnore)
33 {
34  enum_duplicates duplicate_handling= DUP_REPLACE;
35  bool ignore_errors= true;
36 
37  Mock_delayable delayed_insert;
38 
39  delayed_insert.set_dup_and_ignore(duplicate_handling, ignore_errors);
40  EXPECT_EQ(duplicate_handling, delayed_insert.get_duplicate_handling());
41  EXPECT_EQ(ignore_errors, delayed_insert.get_ignore_errors());
42 }
43 
44 
45 /*
46  Test that Delayable_insert_operation does not touch its bitmap during
47  invocation of set_function_defaults(TABLE*).
48  */
49 TEST(DelayableInsertOperation, SetFunctionDefaults)
50 {
51  /*
52  The operation should not use the table, so we give the table some invalid
53  address, which will crash if used. This value is used to defeat any test
54  for NULL.
55  */
56  TABLE *table= reinterpret_cast<TABLE*>(0xffffffff);
57 
58  Mock_delayable delayed_insert;
59 
60  MY_BITMAP *initial_value= NULL;
61  EXPECT_EQ(initial_value, delayed_insert.get_cached_bitmap());
62  delayed_insert.set_function_defaults(table);
63  EXPECT_EQ(initial_value, delayed_insert.get_cached_bitmap())
64  << "Not supposed to allocate anything";
65 }
66 
67 }