utMaterialSystem.cpp 2.2 KB

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