If macro_name[] is not equal to value[], check that str[] contains the string "macro_name=value". Otherwise, check that str[] does not contain any string starting with macro_name=".
| 75 | // string "macro_name=value". Otherwise, check that str[] does not contain any |
| 76 | // string starting with macro_name=". |
| 77 | static void CheckStr(const string_vec &str, const std::string ¯o_name, |
| 78 | const std::string &value) { |
| 79 | std::string value_from_str; |
| 80 | if (GetValue(str, macro_name, &value_from_str)) { |
| 81 | if (value != value_from_str) { |
| 82 | // Output everything found, to aid debugging. |
| 83 | LOG(ERROR) << "===== value=" << value |
| 84 | << " value_from_str=" << value_from_str; |
| 85 | for (int i = 0; i != str.size(); i++) { |
| 86 | LOG(ERROR) << "% " << str[i]; |
| 87 | } |
| 88 | LOG(ERROR) << "====="; |
| 89 | } |
| 90 | CHECK_EQ(value, value_from_str) << " " << macro_name << ": bad value"; |
| 91 | } else { |
| 92 | // If the string is not found, we expect value to be macro_name. |
| 93 | if (value != macro_name) { |
| 94 | // Output everything found, to aid debugging. |
| 95 | LOG(ERROR) << "===== value=" << value << " macro_name=" << macro_name; |
| 96 | for (int i = 0; i != str.size(); i++) { |
| 97 | LOG(ERROR) << "% " << str[i]; |
| 98 | } |
| 99 | LOG(ERROR) << "====="; |
| 100 | } |
| 101 | CHECK_EQ(value, macro_name) << " " << macro_name << ": not found in binary"; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | // Helper for AS_STR(), below, to perform macro expansion. |
| 106 | #define AS_STR_1_(x) #x |