utSharedPPData.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "utSharedPPData.h"
  2. CPPUNIT_TEST_SUITE_REGISTRATION (SharedPPDataTest);
  3. static bool destructed;
  4. struct TestType
  5. {
  6. ~TestType()
  7. {
  8. destructed = true;
  9. }
  10. };
  11. void SharedPPDataTest :: setUp (void)
  12. {
  13. shared = new SharedPostProcessInfo();
  14. destructed = false;
  15. }
  16. void SharedPPDataTest :: tearDown (void)
  17. {
  18. }
  19. void SharedPPDataTest :: testPODProperty (void)
  20. {
  21. int i = 5;
  22. shared->AddProperty("test",i);
  23. int o;
  24. CPPUNIT_ASSERT(shared->GetProperty("test",o) && 5 == o);
  25. CPPUNIT_ASSERT(!shared->GetProperty("test2",o) && 5 == o);
  26. float f = 12.f, m;
  27. shared->AddProperty("test",f);
  28. CPPUNIT_ASSERT(shared->GetProperty("test",m) && 12.f == m);
  29. }
  30. void SharedPPDataTest :: testPropertyPointer (void)
  31. {
  32. int *i = new int[35];
  33. shared->AddProperty("test16",i);
  34. int* o;
  35. CPPUNIT_ASSERT(shared->GetProperty("test16",o) && o == i);
  36. shared->RemoveProperty("test16");
  37. CPPUNIT_ASSERT(!shared->GetProperty("test16",o));
  38. }
  39. void SharedPPDataTest :: testPropertyDeallocation (void)
  40. {
  41. TestType *out, * pip = new TestType();
  42. shared->AddProperty("quak",pip);
  43. CPPUNIT_ASSERT(shared->GetProperty("quak",out) && out == pip);
  44. delete shared;
  45. CPPUNIT_ASSERT(destructed);
  46. }