1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00

test: positive return codes; match: disabled strlen check

This commit is contained in:
Gabor Adam Toth 2011-04-29 23:00:03 +02:00
parent ea3e40d575
commit 56371a3792
5 changed files with 25 additions and 24 deletions

View file

@ -7,8 +7,9 @@ int psyc_inherits(char* sho, size_t slen,
// the length.. but we would be faster here if we expected the callee
// to always use the PSYC_C2ARG() macro instead. additionally, the
// empty string would then be fully supported (in case you want that)
if (!slen) slen = strlen(sho);
if (!llen) llen = strlen(lon);
// Disabled this, let's use that macro rather.
//if (!slen) slen = strlen(sho);
//if (!llen) llen = strlen(lon);
if (slen == 0 || *sho != '_' ||
llen == 0 || *lon != '_') {
@ -45,8 +46,8 @@ int psyc_matches(char* sho, size_t slen,
char* lon, size_t llen) {
char *s, *l, *se, *le;
if (!slen) slen = strlen(sho);
if (!llen) llen = strlen(lon);
//if (!slen) slen = strlen(sho);
//if (!llen) llen = strlen(lon);
if (slen == 0 || *sho != '_' ||
llen == 0 || *lon != '_') {

View file

@ -24,14 +24,14 @@ int main() {
printf("%s: %d\n", vars[i], psyc_isRoutingVar(vars[i], strlen(vars[i])));
}
#else
unless (psyc_isRoutingVar(PSYC_C2ARG("_source"))) return -1;
unless (psyc_isRoutingVar(PSYC_C2ARG("_source_relay"))) return -2;
if (psyc_isRoutingVar(PSYC_C2ARG("_source_foo"))) return -3;
if (psyc_isRoutingVar(PSYC_C2ARG("_sourcherry"))) return -4;
if (psyc_isRoutingVar(PSYC_C2ARG("_sour"))) return -5;
if (psyc_isRoutingVar(PSYC_C2ARG("_foo"))) return -6;
if (psyc_isRoutingVar(PSYC_C2ARG("bar"))) return -7;
if (psyc_isRoutingVar(PSYC_C2ARG("_"))) return -8;
unless (psyc_isRoutingVar(PSYC_C2ARG("_source"))) return 1;
unless (psyc_isRoutingVar(PSYC_C2ARG("_source_relay"))) return 2;
if (psyc_isRoutingVar(PSYC_C2ARG("_source_foo"))) return 3;
if (psyc_isRoutingVar(PSYC_C2ARG("_sourcherry"))) return 4;
if (psyc_isRoutingVar(PSYC_C2ARG("_sour"))) return 5;
if (psyc_isRoutingVar(PSYC_C2ARG("_foo"))) return 6;
if (psyc_isRoutingVar(PSYC_C2ARG("bar"))) return 7;
if (psyc_isRoutingVar(PSYC_C2ARG("_"))) return 8;
puts("psyc_isRoutingVar passed all tests.");
#endif

View file

@ -2,17 +2,17 @@
#include "../include/psyc/lib.h"
int main() {
if (psyc_matches("_failure_delivery", 0, "_failure_unsuccessful_delivery_death", 0)) return -1;
if (psyc_matches("_failure_trash", 8, "_failure_unsuccessful_delivery_death", 0)) return -2;
if (psyc_matches("_unsuccessful", 0, "_failure_unsuccessful_delivery_death", 0)) return -3;
unless (psyc_matches("_fail", 0, "_failure_unsuccessful_delivery_death", 0)) return -4;
unless (psyc_matches("_truthahn", 0, "_failure_unsuccessful_delivery_death", 0)) return -5;
if (psyc_matches("_failure_delivery", 0, "_failure_unsuccessful_delivery_death", 0)) return 1;
if (psyc_matches("_failure_trash", 8, "_failure_unsuccessful_delivery_death", 0)) return 2;
if (psyc_matches("_unsuccessful", 0, "_failure_unsuccessful_delivery_death", 0)) return 3;
unless (psyc_matches("_fail", 0, "_failure_unsuccessful_delivery_death", 0)) return 4;
unless (psyc_matches("_truthahn", 0, "_failure_unsuccessful_delivery_death", 0)) return 5;
puts("psyc_matches passed all tests.");
unless (psyc_inherits("_failure_delivery", 0, "_failure_unsuccessful_delivery_death", 0)) return -11;
if (psyc_inherits("_failure_unsuccessful", 0, "_failure_unsuccessful_delivery_death", 0)) return -12;
unless (psyc_inherits("_fail", 0, "_failure_unsuccessful_delivery_death", 0)) return -13;
unless (psyc_inherits("_failure_delivery", 0, "_failure_unsuccessful_delivery_death", 0)) return 11;
if (psyc_inherits("_failure_unsuccessful", 0, "_failure_unsuccessful_delivery_death", 0)) return 12;
unless (psyc_inherits("_fail", 0, "_failure_unsuccessful_delivery_death", 0)) return 13;
puts("psyc_inherits passed all tests.");

View file

@ -83,7 +83,7 @@ int main(int argc, char **argv)
continue;
case PSYC_PARSE_INSUFFICIENT:
printf("Insufficient data.\n");
return -1;
return 1;
default:
printf("Error while parsing: %i\n", ret);
return 1;

View file

@ -32,7 +32,7 @@ int testPresence(const char *avail, int availlen, const char *desc, int desclen,
psyc_render(&packet, buffer, sizeof(buffer));
if (verbose)
write(0, buffer, packet.length);
return strncmp(rendered, buffer, packet.length);
return strncmp(rendered, buffer, packet.
}
int testList(const char *rendered, uint8_t verbose)
@ -94,7 +94,7 @@ int main(int argc, char **argv) {
=_description_presence\tI'm omnipresent right now\n\
_notice_presence\n\
|\n", verbose))
return -1;
return 1;
if (testList("\
:_source psyc://10.100.1000/~ludwig\n\
@ -106,7 +106,7 @@ qux\n\
_test_list\n\
list test\n\
|\n", verbose))
return -2;
return 2;
puts("psyc_render passed all tests.");