diff --git a/coding/coding_tests/varint_test.cpp b/coding/coding_tests/varint_test.cpp index 1dc3b7bd29..c1d2f6b69e 100644 --- a/coding/coding_tests/varint_test.cpp +++ b/coding/coding_tests/varint_test.cpp @@ -2,9 +2,11 @@ #include "../../testing/testing.hpp" #include "../byte_stream.hpp" + #include "../../base/macros.hpp" #include "../../base/stl_add.hpp" + namespace { template void TestVarUint(T const x) @@ -151,16 +153,25 @@ UNIT_TEST(ReadVarInt64Array) ASSERT_GREATER(data.size(), 0, ()); { + // Factor out variables here to show the obvious compiler error. + // clang 3.5, loop optimization. + /// @todo Need to check with the new XCode (and clang) update. + + void const * pDataStart = &data[0]; + void const * pDataEnd = &data[0] + data.size(); + vector result; - void const * pEnd = ReadVarInt64Array(&data[0], &data[0] + data.size(), + void const * pEnd = ReadVarInt64Array(pDataStart, pDataEnd, MakeBackInsertFunctor(result)); - TEST_EQUAL(pEnd, &data[0] + data.size(), ("UntilBufferEnd", data.size())); + + TEST_EQUAL(pEnd, pDataEnd, ("UntilBufferEnd", data.size())); TEST_EQUAL(result, testValues, ("UntilBufferEnd", data.size())); } { vector result; void const * pEnd = ReadVarInt64Array(&data[0], testValues.size(), MakeBackInsertFunctor(result)); + TEST_EQUAL(pEnd, &data[0] + data.size(), ("GivenSize", data.size())); TEST_EQUAL(result, testValues, ("GivenSize", data.size())); }