/// @return result code
spv_result_t advance(spv_text text, spv_position position) {
// NOTE: Consume white space, otherwise don't advance.
+ if (position->index >= text->length) return SPV_END_OF_STREAM;
switch (text->str[position->index]) {
case '\0':
return SPV_END_OF_STREAM;
ASSERT_EQ(SPV_END_OF_STREAM, data.advance());
}
+TEST(TextAdvance, NoNullTerminator) {
+ spv_text_t text = {"OpNop\nSomething else in memory", 6};
+ AssemblyContext data(&text, nullptr);
+ const spv_position_t line_break = {1, 5, 5};
+ data.setPosition(line_break);
+ ASSERT_EQ(SPV_END_OF_STREAM, data.advance());
+}
+
} // anonymous namespace