From 65f13bb1e48831ac16d75fafc5f159d87f7a8049 Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Mon, 19 Feb 2018 21:49:58 -0600 Subject: [PATCH] Add missing output and fix buffer size issue We use BUFSIZ everywhere, except in setvbuf(), which kinda needs to know the proper buffer size. Because we were passing 256, which is (much!) lower than BUFSIZ, we were wrapping output around in an odd, unexpected way. --- tests/mos6502.dis.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/mos6502.dis.c b/tests/mos6502.dis.c index 02aba0c..2bb3a43 100644 --- a/tests/mos6502.dis.c +++ b/tests/mos6502.dis.c @@ -37,7 +37,7 @@ setup() // into, but use an underlying string buffer that we can easily // check with Criterion. Uh, unless we blow out the buffer size... // don't do that :D - setvbuf(stream, buf, _IOFBF, 256); + setvbuf(stream, buf, _IOFBF, BUFSIZ); mem = vm_segment_create(MOS6502_MEMSIZE); cpu = mos6502_create(mem, mem); @@ -216,7 +216,7 @@ Test(mos6502_dis, opcode) mos6502_set(cpu, 1, 0x38); bytes = mos6502_dis_opcode(cpu, stream, 0); - assert_buf(" AND #$38 ; pc:0000 cy:02 val:38 a:00 x:00 y:00 p:NO-dIZC s:ff | 29 38\n"); + assert_buf(" AND #$38 ; pc:0000 cy:02 addr:0000 val:38 a:00 x:00 y:00 p:NO-dIZC s:ff | 29 38\n"); cr_assert_eq(bytes, 2); } @@ -230,14 +230,14 @@ Test(mos6502_dis, scan) mos6502_set(cpu, 5, 0x12); mos6502_dis_scan(cpu, stream, 0, 6); - + // FIXME: scan does not currently advance the PC byte; _should_ it? // I'm honestly not sure. There are definitely times (e.g. during // runtime operation) when you don't want it to, but as a standalone // disassembler, it feels less useful when PC isn't emulated. - assert_buf(" AND #$38 ; pc:0000 cy:02 val:38 a:00 x:00 y:00 p:NO-dIZC s:ff | 29 38\n" - " DEY ; pc:0000 cy:02 val: a:00 x:00 y:00 p:NO-dIZC s:ff | 88\n" - " JMP ($1234) ; pc:0000 cy:05 val:29 a:00 x:00 y:00 p:NO-dIZC s:ff | 6c 34 12\n" + assert_buf(" AND #$38 ; pc:0000 cy:02 addr:0000 val:38 a:00 x:00 y:00 p:NO-dIZC s:ff | 29 38\n" + " DEY ; pc:0000 cy:02 addr:0000 val: a:00 x:00 y:00 p:NO-dIZC s:ff | 88\n" + " JMP ($1234) ; pc:0000 cy:05 addr:0000 val:29 a:00 x:00 y:00 p:NO-dIZC s:ff | 6c 34 12\n" ";;;\n\n" ); }