1 |
|
|
#include "gtest/gtest.h" |
2 |
|
|
|
3 |
|
|
#include <fstream> |
4 |
|
|
#include <regex> |
5 |
|
|
|
6 |
✗✓ |
2 |
class DeprecatedAttributeTest : public ::testing::Test |
7 |
|
|
{ |
8 |
|
|
protected: |
9 |
|
|
bool matchInFile(const std::string& fileName, const std::regex& lineRegex) |
10 |
|
|
{ |
11 |
|
|
std::ifstream file(fileName.c_str()); |
12 |
|
|
|
13 |
|
|
bool isPresent = false; |
14 |
|
|
std::string line; |
15 |
|
|
while (std::getline(file, line)) |
16 |
|
|
{ |
17 |
|
|
if (std::regex_search(line, lineRegex)) |
18 |
|
|
{ |
19 |
|
|
isPresent = true; |
20 |
|
|
break; |
21 |
|
|
} |
22 |
|
|
} |
23 |
|
|
file.close(); |
24 |
|
|
|
25 |
|
|
return isPresent; |
26 |
|
|
} |
27 |
|
|
|
28 |
|
|
static const char* const ERROR_LOG_PATH; |
29 |
|
|
}; |
30 |
|
|
|
31 |
|
|
const char* const DeprecatedAttributeTest::ERROR_LOG_PATH = |
32 |
|
|
"zserio/deprecated_attribute/src/DeprecatedAttribute-stamp/DeprecatedAttribute-build-" |
33 |
|
|
#if defined(DEPRECATED_ATTRIBUTE_TEST_CHECK_WARNINGS) && DEPRECATED_ATTRIBUTE_TEST_CHECK_WARNINGS == 1 |
34 |
|
|
"out" |
35 |
|
|
#else |
36 |
|
|
"err" |
37 |
|
|
#endif |
38 |
|
|
".log"; |
39 |
|
|
|
40 |
✓✗✓✗ ✓✗✗✓
|
802 |
TEST_F(DeprecatedAttributeTest, checkWarnings) |
41 |
|
|
{ |
42 |
|
|
#if defined(DEPRECATED_ATTRIBUTE_TEST_CHECK_WARNINGS) && DEPRECATED_ATTRIBUTE_TEST_CHECK_WARNINGS != 0 |
43 |
|
|
ASSERT_FALSE(matchInFile(ERROR_LOG_PATH, std::regex("Unknown warning to check matchInFile method!"))); |
44 |
|
|
ASSERT_TRUE(matchInFile(ERROR_LOG_PATH, |
45 |
|
|
std::regex("DeprecatedAttribute\\.cpp.*15.*81.*warning.*FIVE.*deprecated"))) << |
46 |
|
|
"Warning not found in '" << ERROR_LOG_PATH << "'!"; |
47 |
|
|
#endif |
48 |
✓✗✓✗
|
2395 |
} |