Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

67 Zeilen
1.7 KiB

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