Skip to content

Instantly share code, notes, and snippets.

[~/src/SillyMUD/src]$ make
gcc -g -DIMPL_SECURITY -DNEW_RENT -DLEVEL_LOSS -DNEWEXP -DGROUP_NAMES -Werror -DIMPL_SECURITY -DNEW_RENT -DLEVEL_LOSS -DNEWEXP -DGROUP_NAMES -c -o act.info.o act.info.c
act.info.c:2005:14: error: address of array 'd->host' will always evaluate to
'true' [-Werror,-Wpointer-bool-conversion]
if (d->host && *d->host) {
~~~^~~~ ~~
1 error generated.
make: *** [act.info.o] Error 1
void dsearch(char *string, char *tmp)
{
char *src, *dst;
src = string;
dst = tmp;
while(*src != '\0') {
if (*src == '~') {
if (*(src + 1) == 'N') {
*dst++ = '$';
Test(act_wizard, dsearch_simple_arg) {
char arg[255], dst[255];
sprintf(arg, "Someone appears!");
dsearch(arg, dst);
cr_assert_str_eq(arg, "Someone appears!");
}
Test(act_wizard, dsearch_simple_tilde_arg) {
char arg[255], dst[255];
sprintf(arg, "Someone ~ appears!");
Test(act_wizard, dsearch_double_substitution) {
char arg[255], dst[255];
sprintf(arg, "Someone ~N~N appears!");
dsearch(arg, dst);
cr_assert_str_eq(dst, "Someone $n$n appears!");
}
Test(act_wizard, dsearch_double_tilde) {
char arg[255], dst[255];
sprintf(arg, "Someone ~~ appears!");
dsearch(arg, dst);
cr_assert_str_eq(dst, "Someone appears!");
}
Test(act_wizard, dsearch_tilde_N_simple) {
char arg[255], dst[255];
sprintf(arg, "Someone ~N appears!");
dsearch(arg, dst);
cr_assert_str_eq(dst, "Someone $n appears!");
}
Test(act_wizard, dsearch_tilde_at_end) {
char arg[255], dst[255];
sprintf(arg, "Someone appears!~");
dsearch(arg, dst);
cr_assert_str_eq(dst, "Someone appears!");
}
Test(act_wizard, dsearch_simple_tilde) {
char arg[255], dst[255];
sprintf(arg, "Someone ~ appears!");
dsearch(arg, dst);
cr_assert_str_eq(dst, "Someone appears!");
}
@jonm
jonm / test-tilde-fail.c
Created October 23, 2015 11:08
testing a string with a tilde
Test(act_wizard, dsearch_simple_tilde) {
char arg[255], dst[255];
sprintf(arg, "Someone ~ appears!");
dsearch(arg, dst);
cr_assert_str_eq(dst, "");
}
@jonm
jonm / intentional-fail.txt
Created October 23, 2015 11:07
unit test fails, as expected, but with less info than we'd want
[~/src/SillyMUD/src]$ make test
gcc -g -DIMPL_SECURITY -DNEW_RENT -DLEVEL_LOSS -DNEWEXP -DGROUP_NAMES -DIMPL_SECURITY -DNEW_RENT -DLEVEL_LOSS -DNEWEXP -DGROUP_NAMES -c -o test.act.wizard.o test.act.wizard.c
gcc -o tests comm.o act.comm.o act.info.o act.move.o act.obj1.o act.obj2.o act.off.o act.other.o act.social.o act.wizard.o handler.o db.o interpreter.o utility.o spec_assign.o shop.o limits.o mobact.o fight.o modify.o weather.o spells1.o spells2.o spell_parser.o reception.o constants.o spec_procs.o signals.o board.o magic.o magic2.o skills.o Opinion.o Trap.o magicutils.o multiclass.o hash.o Sound.o Heap.o spec_procs2.o magic3.o security.o spec_procs3.o create.o bsd.o parser.o intrinsics.o test.act.wizard.o -lcriterion
./tests
[----] test.act.wizard.c:17: Assertion failed: The expression (as strings) (dst) == ("") is false.
[FAIL] act_wizard::dsearch_simple_tilde: (0.00s)
[====] Synthesis: Tested: 2 | Passing: 1 | Failing: 1 | Crashing: 0
make: *** [test] Error 1