Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

91 рядки
3.0 KiB

  1. #include "UnitTestPCH.h"
  2. #include "utMaterialSystem.h"
  3. CPPUNIT_TEST_SUITE_REGISTRATION (MaterialSystemTest);
  4. // ------------------------------------------------------------------------------------------------
  5. void MaterialSystemTest :: setUp (void)
  6. {
  7. this->pcMat = new aiMaterial();
  8. }
  9. // ------------------------------------------------------------------------------------------------
  10. void MaterialSystemTest :: tearDown (void)
  11. {
  12. delete this->pcMat;
  13. }
  14. // ------------------------------------------------------------------------------------------------
  15. void MaterialSystemTest :: testFloatProperty (void)
  16. {
  17. float pf = 150392.63f;
  18. this->pcMat->AddProperty(&pf,1,"testKey1");
  19. pf = 0.0f;
  20. CPPUNIT_ASSERT(AI_SUCCESS == pcMat->Get("testKey1",0,0,pf));
  21. CPPUNIT_ASSERT(pf == 150392.63f);
  22. }
  23. // ------------------------------------------------------------------------------------------------
  24. void MaterialSystemTest :: testFloatArrayProperty (void)
  25. {
  26. float pf[] = {0.0f,1.0f,2.0f,3.0f};
  27. unsigned int pMax = sizeof(pf) / sizeof(float);
  28. this->pcMat->AddProperty(&pf,pMax,"testKey2");
  29. pf[0] = pf[1] = pf[2] = pf[3] = 12.0f;
  30. CPPUNIT_ASSERT(AI_SUCCESS == pcMat->Get("testKey2",0,0,pf,&pMax));
  31. CPPUNIT_ASSERT(pMax == sizeof(pf) / sizeof(float));
  32. CPPUNIT_ASSERT(!pf[0] && 1.0f == pf[1] && 2.0f == pf[2] && 3.0f == pf[3] );
  33. }
  34. // ------------------------------------------------------------------------------------------------
  35. void MaterialSystemTest :: testIntProperty (void)
  36. {
  37. int pf = 15039263;
  38. this->pcMat->AddProperty(&pf,1,"testKey3");
  39. pf = 12;
  40. CPPUNIT_ASSERT(AI_SUCCESS == pcMat->Get("testKey3",0,0,pf));
  41. CPPUNIT_ASSERT(pf == 15039263);
  42. }
  43. // ------------------------------------------------------------------------------------------------
  44. void MaterialSystemTest :: testIntArrayProperty (void)
  45. {
  46. int pf[] = {0,1,2,3};
  47. unsigned int pMax = sizeof(pf) / sizeof(int);
  48. this->pcMat->AddProperty(&pf,pMax,"testKey4");
  49. pf[0] = pf[1] = pf[2] = pf[3] = 12;
  50. CPPUNIT_ASSERT(AI_SUCCESS == pcMat->Get("testKey4",0,0,pf,&pMax));
  51. CPPUNIT_ASSERT(pMax == sizeof(pf) / sizeof(int));
  52. CPPUNIT_ASSERT(!pf[0] && 1 == pf[1] && 2 == pf[2] && 3 == pf[3] );
  53. }
  54. // ------------------------------------------------------------------------------------------------
  55. void MaterialSystemTest :: testColorProperty (void)
  56. {
  57. aiColor4D clr;
  58. clr.r = 2.0f;clr.g = 3.0f;clr.b = 4.0f;clr.a = 5.0f;
  59. this->pcMat->AddProperty(&clr,1,"testKey5");
  60. clr.b = 1.0f;
  61. clr.a = clr.g = clr.r = 0.0f;
  62. CPPUNIT_ASSERT(AI_SUCCESS == pcMat->Get("testKey5",0,0,clr));
  63. CPPUNIT_ASSERT(clr.r == 2.0f && clr.g == 3.0f && clr.b == 4.0f && clr.a == 5.0f);
  64. }
  65. // ------------------------------------------------------------------------------------------------
  66. void MaterialSystemTest :: testStringProperty (void)
  67. {
  68. aiString s;
  69. s.Set("Hello, this is a small test");
  70. this->pcMat->AddProperty(&s,"testKey6");
  71. s.Set("358358");
  72. CPPUNIT_ASSERT(AI_SUCCESS == pcMat->Get("testKey6",0,0,s));
  73. CPPUNIT_ASSERT(!::strcmp(s.data,"Hello, this is a small test"));
  74. }