Fixed use-after-free in isStartOfNewInst() tests.

This commit is contained in:
Andrew Woloszyn 2016-01-12 14:47:24 -05:00
parent 7ffd8ffeb2
commit ca50510ad4

View File

@ -41,19 +41,22 @@ TEST(TextStartsWithOp, YesAtStart) {
TEST(TextStartsWithOp, YesAtMiddle) {
{
AssemblyContext dat(AutoText(" OpFoo"), nullptr);
AutoText text(" OpFoo");
AssemblyContext dat(text, nullptr);
dat.seekForward(2);
EXPECT_TRUE(dat.isStartOfNewInst());
}
{
AssemblyContext dat(AutoText("xx OpFoo"), nullptr);
AutoText text("xx OpFoo");
AssemblyContext dat(text, nullptr);
dat.seekForward(2);
EXPECT_TRUE(dat.isStartOfNewInst());
}
}
TEST(TextStartsWithOp, NoIfTooFar) {
AssemblyContext dat(AutoText(" OpFoo"), nullptr);
AutoText text(" OpFoo");
AssemblyContext dat(text, nullptr);
dat.seekForward(3);
EXPECT_FALSE(dat.isStartOfNewInst());
}