| 23 | public: |
| 24 | virtual ~FileUtilsTest() = default; |
| 25 | virtual bool run(int precision) { |
| 26 | /*======== Create and Remove ========*/ |
| 27 | do { |
| 28 | // create a new file |
| 29 | file_t file = MNNCreateFile(file_path); |
| 30 | if (file == INVALID_FILE) { |
| 31 | return false; |
| 32 | } else { |
| 33 | MNNCloseFile(file); |
| 34 | } |
| 35 | bool exist = MNNFileExist(file_path); |
| 36 | if (!exist) { |
| 37 | return false; |
| 38 | } |
| 39 | // create a new file to cover an existing file |
| 40 | file = MNNCreateFile(file_path); |
| 41 | if (file == INVALID_FILE) { |
| 42 | return false; |
| 43 | } else { |
| 44 | MNNCloseFile(file); |
| 45 | } |
| 46 | exist = MNNFileExist(file_path); |
| 47 | if (!exist) { |
| 48 | return false; |
| 49 | } |
| 50 | // remove a file |
| 51 | MNN::ErrorCode ec = MNNRemoveFile(file_path); |
| 52 | if (ec != NO_ERROR) { |
| 53 | return false; |
| 54 | } |
| 55 | exist = MNNFileExist(file_path); |
| 56 | if (exist) { |
| 57 | return false; |
| 58 | } |
| 59 | printf("File Utils Test: Create and Remove passed\n"); |
| 60 | } while(false); |
| 61 | |
| 62 | /*======== Open and Close ========*/ |
| 63 | do { |
| 64 | // Open and close a non-existent file |
| 65 | file_t file = MNNOpenFile(file_path, MNN_FILE_READ | MNN_FILE_WRITE); |
| 66 | if (file != INVALID_FILE) { |
| 67 | return false; |
| 68 | } |
| 69 | MNN::ErrorCode ec = MNNCloseFile(file); |
| 70 | if (ec != FILE_NOT_EXIST) { |
| 71 | return false; |
| 72 | } |
| 73 | // Open and close an existent file |
| 74 | file = MNNCreateFile(file_path); |
| 75 | if (file == INVALID_FILE) { |
| 76 | return false; |
| 77 | } |
| 78 | bool exist = MNNFileExist(file_path); |
| 79 | if (!exist) { |
| 80 | return false; |
| 81 | } |
| 82 | ec = MNNCloseFile(file); |
nothing calls this directly
no test coverage detected