Commit 9dc235b5 authored by Diomidis Spinellis's avatar Diomidis Spinellis
Browse files

Avoid array index out of range

Issue: #2140
parent d850e144
...@@ -122,7 +122,7 @@ To provide a custom failure message, simply stream it into the macro using the ...@@ -122,7 +122,7 @@ To provide a custom failure message, simply stream it into the macro using the
```c++ ```c++
ASSERT_EQ(x.size(), y.size()) << "Vectors x and y are of unequal length"; ASSERT_EQ(x.size(), y.size()) << "Vectors x and y are of unequal length";
for (int i = 0; i < x.size(); ++i) { for (int i = 0; i < std::min(x.size(), y.size()); ++i) {
EXPECT_EQ(x[i], y[i]) << "Vectors x and y differ at index " << i; EXPECT_EQ(x[i], y[i]) << "Vectors x and y differ at index " << i;
} }
``` ```
......
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