forked from google/flatbuffers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alignment_test.cpp
31 lines (22 loc) · 857 Bytes
/
alignment_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "alignment_test.h"
#include "flatbuffers/flatbuffer_builder.h"
#include "alignment_test_generated.h"
#include "test_assert.h"
namespace flatbuffers {
namespace tests {
void AlignmentTest() {
FlatBufferBuilder builder;
BadAlignmentLarge large;
Offset<OuterLarge> outer_large = CreateOuterLarge(builder, &large);
BadAlignmentSmall *small;
Offset<Vector<const BadAlignmentSmall *>> small_offset =
builder.CreateUninitializedVectorOfStructs(9, &small);
(void)small; // We do not have to write data to trigger the test failure
Offset<BadAlignmentRoot> root =
CreateBadAlignmentRoot(builder, outer_large, small_offset);
builder.Finish(root);
Verifier verifier(builder.GetBufferPointer(), builder.GetSize());
TEST_ASSERT(VerifyBadAlignmentRootBuffer(verifier));
}
} // namespace tests
} // namespace flatbuffers