/* Include snapshot.c to inspect its private arena accounting. The static * library supplies the terminal implementation; this translation unit's * snapshot symbols satisfy the test's references before the archive is read. */ #include #include "../src/snapshot.c" int main(void) { struct term_options options = { .size = { 8, 24 }, .scrollback = 5 }; struct term *t = term_new(&options); struct term_snapshot *s = term_snapshot_new(); assert(t && s && term_snapshot_update(s, t)); const char line[] = "e\xcc\x81\r\n"; for (int i = 0; i < 10000; i++) { term_feed(t, line, sizeof(line) - 1, 0); assert(term_snapshot_update(s, t)); } /* A fixed viewport holds fewer than 24 * 8 cluster records at once. * Dead records are compacted before they can dominate this arena. */ assert(term_history_rows(t) == 5); assert(s->arena_len < 8192); term_snapshot_free(s); term_free(t); return 0; }