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. }