Test of AutoDiff wrapper in an expression modified so that the upAligned size of the relevant binary expression is tested against the size of the expression in the AutoDiff wrapper. When the traceSize() of the expression containing the AutoDiff wrapper is computed, that value (the traceSize) will be computed such that an alignment (currently 16-bit) will be forced. It is thus necessary for the test to also upAlign the relevant binary expression. On x86_64 architectures, this test was accidentally passing because the relevant struct was already aligned on a 16-bit boundary. On AArch64 ('ARM64'), the alignment was *not* on a 16-bit boundary, and this test failed. Modifying the first argument to EXPECT_LONGS_EQUAL in this test to include upAlignment of the relevant binary expression makes the test pass in 'debug' and 'release' builds on both x86_64 and AArch64 architectures

release/4.3a0
Mike Sheffler 2018-09-11 00:22:20 -07:00
parent b0097b7751
commit 3b8985fb6e
1 changed files with 11 additions and 3 deletions

View File

@ -231,14 +231,22 @@ TEST(AdaptAutoDiff, AdaptAutoDiff) {
/* ************************************************************************* */
// Test AutoDiff wrapper in an expression
TEST(AdaptAutoDiff, SnavelyExpression) {
typedef AdaptAutoDiff<SnavelyProjection, 2, 9, 3> Adaptor;
Expression<Vector9> P(1);
Expression<Vector3> X(2);
typedef AdaptAutoDiff<SnavelyProjection, 2, 9, 3> Adaptor;
Expression<Vector2> expression(Adaptor(), P, X);
std::size_t RecordSize =
sizeof(internal::BinaryExpression<Vector2, Vector9, Vector3>::Record);
EXPECT_LONGS_EQUAL(
sizeof(internal::BinaryExpression<Vector2, Vector9, Vector3>::Record),
internal::upAligned(RecordSize) + P.traceSize() + X.traceSize(),
expression.traceSize());
set<Key> expected = list_of(1)(2);
EXPECT(expected == expression.keys());
}