You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

84 regels
2.6 KiB

  1. #include "UnitTestPCH.h"
  2. #include "utFindInvalidData.h"
  3. CPPUNIT_TEST_SUITE_REGISTRATION (FindInvalidDataProcessTest);
  4. // ------------------------------------------------------------------------------------------------
  5. void FindInvalidDataProcessTest :: setUp (void)
  6. {
  7. CPPUNIT_ASSERT( AI_MAX_NUMBER_OF_TEXTURECOORDS >= 3);
  8. piProcess = new FindInvalidDataProcess();
  9. pcMesh = new aiMesh();
  10. pcMesh->mNumVertices = 1000;
  11. pcMesh->mVertices = new aiVector3D[1000];
  12. for (unsigned int i = 0; i < 1000;++i)
  13. pcMesh->mVertices[i] = aiVector3D((float)i);
  14. pcMesh->mNormals = new aiVector3D[1000];
  15. for (unsigned int i = 0; i < 1000;++i)
  16. pcMesh->mNormals[i] = aiVector3D((float)i+1);
  17. pcMesh->mTangents = new aiVector3D[1000];
  18. for (unsigned int i = 0; i < 1000;++i)
  19. pcMesh->mTangents[i] = aiVector3D((float)i);
  20. pcMesh->mBitangents = new aiVector3D[1000];
  21. for (unsigned int i = 0; i < 1000;++i)
  22. pcMesh->mBitangents[i] = aiVector3D((float)i);
  23. for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS;++a)
  24. {
  25. pcMesh->mTextureCoords[a] = new aiVector3D[1000];
  26. for (unsigned int i = 0; i < 1000;++i)
  27. pcMesh->mTextureCoords[a][i] = aiVector3D((float)i);
  28. }
  29. }
  30. // ------------------------------------------------------------------------------------------------
  31. void FindInvalidDataProcessTest :: tearDown (void)
  32. {
  33. delete piProcess;
  34. delete pcMesh;
  35. }
  36. // ------------------------------------------------------------------------------------------------
  37. void FindInvalidDataProcessTest :: testStepNegativeResult (void)
  38. {
  39. ::memset(pcMesh->mNormals,0,pcMesh->mNumVertices*sizeof(aiVector3D));
  40. ::memset(pcMesh->mBitangents,0,pcMesh->mNumVertices*sizeof(aiVector3D));
  41. pcMesh->mTextureCoords[2][455] = aiVector3D( std::numeric_limits<float>::quiet_NaN() );
  42. piProcess->ProcessMesh(pcMesh);
  43. CPPUNIT_ASSERT(NULL != pcMesh->mVertices);
  44. CPPUNIT_ASSERT(NULL == pcMesh->mNormals);
  45. CPPUNIT_ASSERT(NULL == pcMesh->mTangents);
  46. CPPUNIT_ASSERT(NULL == pcMesh->mBitangents);
  47. for (unsigned int i = 0; i < 2;++i)
  48. CPPUNIT_ASSERT(NULL != pcMesh->mTextureCoords[i]);
  49. for (unsigned int i = 2; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i)
  50. CPPUNIT_ASSERT(NULL == pcMesh->mTextureCoords[i]);
  51. }
  52. // ------------------------------------------------------------------------------------------------
  53. void FindInvalidDataProcessTest :: testStepPositiveResult (void)
  54. {
  55. piProcess->ProcessMesh(pcMesh);
  56. CPPUNIT_ASSERT(NULL != pcMesh->mVertices);
  57. CPPUNIT_ASSERT(NULL != pcMesh->mNormals);
  58. CPPUNIT_ASSERT(NULL != pcMesh->mTangents);
  59. CPPUNIT_ASSERT(NULL != pcMesh->mBitangents);
  60. for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS;++i)
  61. CPPUNIT_ASSERT(NULL != pcMesh->mTextureCoords[i]);
  62. }