Ticket #1956 (closed bug: fixed)

Opened 11 years ago

Last modified 11 years ago

Confused test 2 in t/src/misc.t

Reported by: doughera Owned by: NotFound
Priority: normal Milestone:
Component: none Version: 2.11.0
Severity: medium Keywords:
Cc: Language:
Patch status: new Platform:

Description

I think test 2 in t/src/misc.t is confused. The gist of the test is this (edited for clarity)

char *buf = "unchanged";
Parrot_snprintf(interp, buf, 0, "");
if (buf == "unchanged") puts("Done");
else fail(buf);

I think the test should actually test whether the *contents* of buf have changed. The attached patch uses strcmp instead.

Attachments

tt1956.patch Download (409 bytes) - added by doughera 11 years ago.
Use strcmp to compare strings in t/src/misc.t test 2.

Change History

Changed 11 years ago by doughera

Use strcmp to compare strings in t/src/misc.t test 2.

Changed 11 years ago by NotFound

'char *buf = "unchanged";' declares a char pointer that points to a constant char array. The "unchanged" is located in a constant segment, if the architecture has such concept, so if the functions is wrong and tries to modify it the result will be a segfault, not a failed test.

So a better way would be: char buf[] = "unchanged";

BTW there is no attachment in the ticket.

Changed 11 years ago by NotFound

I see the attachment now.

Changed 11 years ago by NotFound

  • status changed from new to assigned
  • owner set to NotFound

Changed 11 years ago by NotFound

  • status changed from assigned to closed
  • resolution set to fixed

Both changes done in 4740da3

Note: See TracTickets for help on using tickets.