I need to set side effect to an array size of 2, looking at the following defienition:
https://github.com/google/googletest/blob/master/googlemock/docs/CheatSheet.md
It seems like for array size of 2 the arguments should be (d.a, d.a + 1), but it does not work, only one of the array elements gets the right value. The following code works every time:
EXPECT_CALL(BFO, get(_, 2))
.WillOnce(DoAll(SetArrayArgument<0>(d.a, d.a + 2), Return(2)));
I am a bit confused, why do I need to add two for array size of 2?
The notation is a bit weird, but [first, last) is [first, last[ or [first, last-1]. The last value is not included.
An integer interval that has a finite lower or upper endpoint always includes that endpoint. Therefore, the exclusion of endpoints can be explicitly denoted by writing a .. b − 1 , a + 1 .. b , or a + 1 .. b − 1. Alternate-bracket notations like [a .. b) or [a .. b[ are rarely used for integer intervals.
From Wikipedia.