Files
compute-runtime/unit_tests/helpers/file_io_tests.cpp
Filip Hazubski 8b57d28116 clang-format: enable sorting includes
Include files are now grouped and sorted in following order:
1. Header file of the class the current file implements
2. Project files
3. Third party files
4. Standard library

Change-Id: If31af05652184169f7fee1d7ad08f1b2ed602cf0
Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
2019-02-27 11:50:07 +01:00

42 lines
938 B
C++

/*
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/helpers/file_io.h"
#include "gtest/gtest.h"
#include <cstdio>
TEST(FileIO, existsHasSize) {
std::string fileName("fileIO.bin");
std::remove(fileName.c_str());
ASSERT_FALSE(fileExists(fileName.c_str()));
FILE *fp = nullptr;
fopen_s(&fp, fileName.c_str(), "wb");
ASSERT_NE(nullptr, fp);
fprintf(fp, "TEST");
fclose(fp);
EXPECT_TRUE(fileExists(fileName.c_str()));
EXPECT_TRUE(fileExistsHasSize(fileName.c_str()));
}
TEST(FileIO, existsSizeZero) {
std::string fileName("fileIO.bin");
std::remove(fileName.c_str());
ASSERT_FALSE(fileExists(fileName.c_str()));
FILE *fp = nullptr;
fopen_s(&fp, fileName.c_str(), "wb");
ASSERT_NE(nullptr, fp);
fclose(fp);
EXPECT_TRUE(fileExists(fileName.c_str()));
EXPECT_FALSE(fileExistsHasSize(fileName.c_str()));
}