|
|
@ -42,28 +42,8 @@ TEST(strError, returnSuccessAfterClosingFile)
|
|
|
|
std::string tmpFile("tmp.dat");
|
|
|
|
std::string tmpFile("tmp.dat");
|
|
|
|
std::ofstream auxFile(tmpFile.c_str());
|
|
|
|
std::ofstream auxFile(tmpFile.c_str());
|
|
|
|
auxFile.close();
|
|
|
|
auxFile.close();
|
|
|
|
bool useExactString{true};
|
|
|
|
|
|
|
|
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW__) || defined(__MSYS__)
|
|
|
|
|
|
|
|
const char * expectedString = "No error (errno = 0)";
|
|
|
|
|
|
|
|
#elif defined(__APPLE__)
|
|
|
|
|
|
|
|
const char * expectedString = "Undefined error: 0 (errno = 0)";
|
|
|
|
|
|
|
|
#elif defined(__sun__)
|
|
|
|
|
|
|
|
const char * expectedString = "Error 0 (errno = 0)";
|
|
|
|
|
|
|
|
#elif defined(__FreeBSD__)
|
|
|
|
|
|
|
|
const char * expectedString = "No error: 0 (errno = 0)";
|
|
|
|
|
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
|
|
|
|
const char * expectedString = "Undefined error: 0 (errno = 0)";
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
// On Alpine we get 'No error information (errno = 0)' instead of 'Success (errno = 0)'
|
|
|
|
|
|
|
|
const char * expectedString = "(errno = 0)";
|
|
|
|
|
|
|
|
useExactString = false;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
std::remove(tmpFile.c_str());
|
|
|
|
std::remove(tmpFile.c_str());
|
|
|
|
if (useExactString) {
|
|
|
|
ASSERT_TRUE(strError().find("(errno = 0)") != std::string::npos);
|
|
|
|
ASSERT_STREQ(expectedString, strError().c_str());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
ASSERT_TRUE(strError().find(expectedString) != std::string::npos);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(strError, returnNoSuchFileOrDirectoryWhenTryingToOpenNonExistingFile)
|
|
|
|
TEST(strError, returnNoSuchFileOrDirectoryWhenTryingToOpenNonExistingFile)
|
|
|
@ -75,29 +55,7 @@ TEST(strError, returnNoSuchFileOrDirectoryWhenTryingToOpenNonExistingFile)
|
|
|
|
TEST(strError, doNotRecognizeUnknownError)
|
|
|
|
TEST(strError, doNotRecognizeUnknownError)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
errno = 9999;
|
|
|
|
errno = 9999;
|
|
|
|
bool useExactString{true};
|
|
|
|
ASSERT_TRUE(strError().find("(errno = 9999)") != std::string::npos);
|
|
|
|
#if defined(__MINGW__) || defined(__MSYS__) || defined(__CYGWIN__)
|
|
|
|
|
|
|
|
const char * expectedString = "Unknown error 9999 (errno = 9999)";
|
|
|
|
|
|
|
|
#elif defined(_WIN32)
|
|
|
|
|
|
|
|
const char * expectedString = "Unknown error (errno = 9999)";
|
|
|
|
|
|
|
|
#elif defined(__APPLE__)
|
|
|
|
|
|
|
|
const char * expectedString = "Unknown error: 9999 (errno = 9999)";
|
|
|
|
|
|
|
|
#elif defined(__sun__)
|
|
|
|
|
|
|
|
const char * expectedString = "Unknown error (errno = 9999)";
|
|
|
|
|
|
|
|
#elif defined(__FreeBSD__)
|
|
|
|
|
|
|
|
const char * expectedString = "Unknown error: 9999 (errno = 9999)";
|
|
|
|
|
|
|
|
#elif defined(__NetBSD__)
|
|
|
|
|
|
|
|
const char * expectedString = "Unknown error: 9999 (errno = 9999)";
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
// On Alpine we get 'No error information (errno = 9999)' instead of 'Unknown error 9999 (errno = 9999)'
|
|
|
|
|
|
|
|
const char * expectedString = "(errno = 9999)";
|
|
|
|
|
|
|
|
useExactString = false;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (useExactString) {
|
|
|
|
|
|
|
|
ASSERT_STREQ(expectedString, strError().c_str());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
ASSERT_TRUE(strError().find(expectedString) != std::string::npos);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(getEnv, getsDefaultValueWhenExpectedEnvVariableDoesNotExist)
|
|
|
|
TEST(getEnv, getsDefaultValueWhenExpectedEnvVariableDoesNotExist)
|
|
|
|