| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
- // All rights reserved.
- // Code licensed under the BSD License.
- // http://www.anki3d.org/LICENSE
- #pragma once
- #include <cstdio>
- #ifndef ANKI_TESTS_FOO_VERBOSE
- # define ANKI_TESTS_FOO_VERBOSE 0
- #endif
- #if ANKI_TESTS_FOO_VERBOSE
- # define ANKI_TESTS_FOO_PRINT() printf("%s\n", __PRETTY_FUNCTION__)
- #else
- # define ANKI_TESTS_FOO_PRINT() ((void)0)
- #endif
- /// Struct for testing
- struct Foo
- {
- int x = 666;
- static int constructorCallCount;
- static int destructorCallCount;
- Foo()
- {
- ANKI_TESTS_FOO_PRINT();
- ++constructorCallCount;
- }
- Foo(int x_)
- : x(x_)
- {
- ANKI_TESTS_FOO_PRINT();
- ++constructorCallCount;
- }
- Foo(const Foo& b)
- : x(b.x)
- {
- ANKI_TESTS_FOO_PRINT();
- ++constructorCallCount;
- }
- Foo(Foo&& b)
- : x(b.x)
- {
- ANKI_TESTS_FOO_PRINT();
- b.x = 0;
- ++constructorCallCount;
- }
- ~Foo()
- {
- ANKI_TESTS_FOO_PRINT();
- ++destructorCallCount;
- }
- Foo& operator=(const Foo& b)
- {
- ANKI_TESTS_FOO_PRINT();
- x = b.x;
- return *this;
- }
- Foo& operator=(Foo&& b)
- {
- ANKI_TESTS_FOO_PRINT();
- x = b.x;
- b.x = 0;
- return *this;
- }
- bool operator==(const Foo& b) const
- {
- return x == b.x;
- }
- bool operator!=(const Foo& b) const
- {
- return x != b.x;
- }
- static void reset()
- {
- destructorCallCount = constructorCallCount = 0;
- }
- };
|