Commit fe03d587 authored by yzshen@chromium.org's avatar yzshen@chromium.org

Mojo validation test input parser: disallow multiple [anchr]s with the same ID.

BUG=None
TEST=None

Review URL: https://codereview.chromium.org/340553002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277905 0039d316-1c4b-4281-b951-d872f2087c98
parent 0624005f
......@@ -10,6 +10,7 @@
#include <limits>
#include <map>
#include <set>
#include <utility>
#include "mojo/public/c/system/macros.h"
......@@ -112,6 +113,7 @@ class ValidationTestInputParser {
std::string* error_message_;
std::map<std::string, PendingDistanceItem> pending_distance_items_;
std::set<std::string> anchors_;
};
#define DATA_TYPE(name, data_size, parse_data_func) \
......@@ -329,6 +331,10 @@ bool ValidationTestInputParser::ParseDistance(const DataType& type,
bool ValidationTestInputParser::ParseAnchor(const DataType& type,
const std::string& value_string) {
if (anchors_.find(value_string) != anchors_.end())
return false;
anchors_.insert(value_string);
std::map<std::string, PendingDistanceItem>::iterator iter =
pending_distance_items_.find(value_string);
if (iter == pending_distance_items_.end())
......
......@@ -364,6 +364,8 @@ TEST(ValidationTest, InputParser) {
"[b]1111111k",
"[dist4]unmatched",
"[anchr]hello [dist8]hello",
"[dist4]a [dist4]a [anchr]a",
"[dist4]a [anchr]a [dist4]a [anchr]a",
"0 [handles]50",
NULL
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment