Foo.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef ANKI_TESTS_UTIL_FOO_H
  2. #define ANKI_TESTS_UTIL_FOO_H
  3. #include <iostream>
  4. /// Struct for testing
  5. struct Foo
  6. {
  7. int x = 666;
  8. static int constructorCallCount;
  9. static int destructorCallCount;
  10. Foo()
  11. {
  12. std::cout << __PRETTY_FUNCTION__ << std::endl;
  13. ++constructorCallCount;
  14. }
  15. Foo(int x_)
  16. : x(x_)
  17. {
  18. std::cout << __PRETTY_FUNCTION__ << std::endl;
  19. ++constructorCallCount;
  20. }
  21. Foo(const Foo& b)
  22. : x(b.x)
  23. {
  24. std::cout << __PRETTY_FUNCTION__ << std::endl;
  25. ++constructorCallCount;
  26. }
  27. Foo(Foo&& b)
  28. : x(b.x)
  29. {
  30. std::cout << __PRETTY_FUNCTION__ << std::endl;
  31. b.x = 0;
  32. ++constructorCallCount;
  33. }
  34. ~Foo()
  35. {
  36. std::cout << __PRETTY_FUNCTION__ << std::endl;
  37. ++destructorCallCount;
  38. }
  39. Foo& operator=(const Foo& b)
  40. {
  41. std::cout << __PRETTY_FUNCTION__ << std::endl;
  42. x = b.x;
  43. return *this;
  44. }
  45. Foo& operator=(Foo&& b)
  46. {
  47. std::cout << __PRETTY_FUNCTION__ << std::endl;
  48. x = b.x;
  49. b.x = 0;
  50. return *this;
  51. }
  52. static void reset()
  53. {
  54. destructorCallCount = constructorCallCount = 0;
  55. }
  56. };
  57. #endif