source: mainline/uspace/lib/cpp/include/__bits/test/mock.hpp@ 7bbf91e

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 7bbf91e was 7bbf91e, checked in by Dzejrou <dzejrou@…>, 7 years ago

cpp: changed internal to bits to avoid include space pollusion, fixed old std::hel:: bugs in files that weren't touched since

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 * Copyright (c) 2017 Jaroslav Jindrak
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef LIBCPP_BITS_TEST_MOCK
30#define LIBCPP_BITS_TEST_MOCK
31
32#include <cstdlib>
33#include <tuple>
34
35namespace std::test
36{
37 /**
38 * Auxiliary type that lets us to monitor the number
39 * of calls to various functions for the purposes
40 * of testing smart pointers and other features of
41 * the library.
42 */
43 struct mock
44 {
45 static size_t constructor_calls;
46 static size_t copy_constructor_calls;
47 static size_t destructor_calls;
48 static size_t move_constructor_calls;
49
50 mock()
51 {
52 ++constructor_calls;
53 }
54
55 mock(const mock&)
56 {
57 ++copy_constructor_calls;
58 }
59
60 mock(mock&&)
61 {
62 ++move_constructor_calls;
63 }
64
65 ~mock()
66 {
67 ++destructor_calls;
68 }
69
70 static void clear()
71 {
72 constructor_calls = size_t{};
73 copy_constructor_calls = size_t{};
74 destructor_calls = size_t{};
75 move_constructor_calls = size_t{};
76 }
77 };
78}
79
80#endif
Note: See TracBrowser for help on using the repository browser.