TestFoo.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <Tests/Framework/Framework.h>
  7. namespace anki {
  8. /// A simple class used for testing containers.
  9. class TestFoo
  10. {
  11. public:
  12. int m_x;
  13. static inline int m_constructorCount = 0;
  14. static inline int m_destructorCount = 0;
  15. static inline int m_copyCount = 0;
  16. static inline int m_moveCount = 0;
  17. TestFoo()
  18. : m_x(0)
  19. {
  20. ++m_constructorCount;
  21. }
  22. TestFoo(int x)
  23. : m_x(x)
  24. {
  25. ++m_constructorCount;
  26. }
  27. TestFoo(const TestFoo& b)
  28. : m_x(b.m_x)
  29. {
  30. ++m_constructorCount;
  31. }
  32. TestFoo(TestFoo&& b)
  33. : m_x(b.m_x)
  34. {
  35. b.m_x = 0;
  36. ++m_constructorCount;
  37. }
  38. ~TestFoo()
  39. {
  40. ++m_destructorCount;
  41. }
  42. TestFoo& operator=(const TestFoo& b)
  43. {
  44. m_x = b.m_x;
  45. ++m_copyCount;
  46. return *this;
  47. }
  48. TestFoo& operator=(TestFoo&& b)
  49. {
  50. m_x = b.m_x;
  51. b.m_x = 0;
  52. ++m_moveCount;
  53. return *this;
  54. }
  55. static void reset()
  56. {
  57. m_constructorCount = 0;
  58. m_destructorCount = 0;
  59. m_copyCount = 0;
  60. m_moveCount = 0;
  61. }
  62. };
  63. } // end namespace anki