coreutil.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include "testUtils.h"
  2. using namespace irr;
  3. using namespace core;
  4. bool testMergeFilename()
  5. {
  6. // path mergeFilename(const path& path, const path& filename, const path& extension = "");
  7. if ( mergeFilename(IRR_TEXT(""), IRR_TEXT(""), IRR_TEXT("") ) != io::path(IRR_TEXT("")) )
  8. return false;
  9. if ( mergeFilename(IRR_TEXT("folder"), IRR_TEXT(""), IRR_TEXT("") ) != io::path(IRR_TEXT("folder/")) )
  10. return false;
  11. if ( mergeFilename(IRR_TEXT("folder/"), IRR_TEXT(""), IRR_TEXT("") ) != io::path(IRR_TEXT("folder/")) )
  12. return false;
  13. if ( mergeFilename(IRR_TEXT("folder"), IRR_TEXT("file"), IRR_TEXT("") ) != io::path(IRR_TEXT("folder/file")) )
  14. return false;
  15. if ( mergeFilename(IRR_TEXT("folder/"), IRR_TEXT("file"), IRR_TEXT("") ) != io::path(IRR_TEXT("folder/file")) )
  16. return false;
  17. if ( mergeFilename(IRR_TEXT("folder\\"), IRR_TEXT("file"), IRR_TEXT("") ) != io::path(IRR_TEXT("folder\\file")) )
  18. return false;
  19. if ( mergeFilename(IRR_TEXT(""), IRR_TEXT("file"), IRR_TEXT("") ) != io::path(IRR_TEXT("file")) )
  20. return false;
  21. if ( mergeFilename(IRR_TEXT("."), IRR_TEXT("file"), IRR_TEXT("") ) != io::path(IRR_TEXT("./file")) )
  22. return false;
  23. if ( mergeFilename(IRR_TEXT("folder"), IRR_TEXT(""), IRR_TEXT(".bmp") ) != io::path(IRR_TEXT("folder/.bmp")) )
  24. return false;
  25. if ( mergeFilename(IRR_TEXT("folder/"), IRR_TEXT(""), IRR_TEXT(".bmp") ) != io::path(IRR_TEXT("folder/.bmp")) )
  26. return false;
  27. if ( mergeFilename(IRR_TEXT("folder"), IRR_TEXT(""), IRR_TEXT("bmp") ) != io::path(IRR_TEXT("folder/.bmp")) )
  28. return false;
  29. if ( mergeFilename(IRR_TEXT("."), IRR_TEXT(""), IRR_TEXT("bmp") ) != io::path(IRR_TEXT("./.bmp")) )
  30. return false;
  31. if ( mergeFilename(IRR_TEXT("folder"), IRR_TEXT("file"), IRR_TEXT("bmp") ) != io::path(IRR_TEXT("folder/file.bmp")) )
  32. return false;
  33. if ( mergeFilename(IRR_TEXT("folder/"), IRR_TEXT("file"), IRR_TEXT("bmp") ) != io::path(IRR_TEXT("folder/file.bmp")) )
  34. return false;
  35. if ( mergeFilename(IRR_TEXT("folder/"), IRR_TEXT("file"), IRR_TEXT(".bmp") ) != io::path(IRR_TEXT("folder/file.bmp")) )
  36. return false;
  37. if ( mergeFilename(IRR_TEXT("folder"), IRR_TEXT("file.bmp"), IRR_TEXT("") ) != io::path(IRR_TEXT("folder/file.bmp")) )
  38. return false;
  39. if ( mergeFilename(IRR_TEXT(""), IRR_TEXT("file"), IRR_TEXT("bmp") ) != io::path(IRR_TEXT("file.bmp")) )
  40. return false;
  41. if ( mergeFilename(IRR_TEXT(""), IRR_TEXT("file"), IRR_TEXT(".bmp") ) != io::path(IRR_TEXT("file.bmp")) )
  42. return false;
  43. if ( mergeFilename(IRR_TEXT("c:"), IRR_TEXT("file"), IRR_TEXT(".bmp") ) != io::path(IRR_TEXT("c:/file.bmp")) ) // TODO: is this actually correct on windows?
  44. return false;
  45. return true;
  46. }
  47. // Test the functionality of the Irrlicht timer
  48. bool testCoreutil(void)
  49. {
  50. bool ok = true;
  51. ok &= testMergeFilename();
  52. return ok;
  53. }