/** * @brief Returns the first invalid key contained in the key-value list. * @details An invalid key-value is a key-value with a key whose case-insensitive * string does not match one of the valid key names. * * @return A pointer to the first invalid key-value or nullptr if there none. */ const ParseKeyValue* getFirstInvalidKeyValue() const { std::set<std::string> valid_names({kKeyCompress, kKeyType, kKeySort, kKeyBlockSizeMB}); for (const ParseKeyValue &key_value : *properties_) { std::string lower_key = ToLower(key_value.key()->value()); std::set<std::string>::iterator itr = valid_names.find(lower_key); if (itr == valid_names.end()) { return &key_value; } } return nullptr; }
void TestErrorDetection::test_invalid_month_name() { std::set<std::string> valid_names(months, months + 12); pattern = valid_pattern; for (int b0 = 0; b0 < 256; b0++) { pattern[MONTH0] = b0; for (int b1 = 0; b1 < 256; b1++) { pattern[MONTH1] = b1; for (int b2 = 0; b2 < 256; b2++) { pattern[MONTH2] = b2; const auto ret = invocation(); if (ret < 0) continue; std::string tmp = pattern.substr(8, 3); if (valid_names.count(tmp) == 0) { printf("b0, b1, b2 = {%02x, %02x, %02x}\n", b0, b1, b2); throw TestFailed{"'" + tmp + "' is not a valid month name"}; } } } } }