/* UTF-8 decoding tests */
+/* Other string util tests too */
-#include "silcincludes.h"
+#include "silc.h"
#define utf8fail(n, data, len) \
const unsigned char u##n[] = (data); \
int main(int argc, char **argv)
{
- bool success = FALSE;
+ SilcBool success = FALSE;
unsigned char *s1, *s2, *s3, *s4;
- int l;
-
- if (argc > 1 && !strcmp(argv[1], "-d")) {
- silc_debug = 1;
- silc_debug_hexdump = 1;
- silc_log_set_debug_string("*strutil*");
+ int l, opt;
+
+ while ((opt = getopt(argc, argv, "hVd")) != EOF) {
+ switch(opt) {
+ case 'h':
+ printf("usage: test_silcstrutil\n");
+ exit(0);
+ break;
+ case 'V':
+ printf("Secure Internet Live Conferencing\n");
+ exit(0);
+ break;
+ case 'd':
+ silc_log_debug(TRUE);
+ silc_log_debug_hexdump(TRUE);
+ silc_log_quick(TRUE);
+ if (optarg)
+ silc_log_set_debug_string(optarg);
+ else
+ silc_log_set_debug_string("*strutil*");
+ break;
+ default:
+ exit(1);
+ break;
+ }
}
/* Failure tests */
silc_free(s3);
silc_free(s4);
+ /* Regex test */
+ SILC_LOG_DEBUG(("Simple regex test"));
+ s1 = "foo,bar,silc,com";
+ SILC_LOG_DEBUG(("Find 'silc' from %s", s1));
+ if (!silc_string_match(s1, "silc"))
+ goto err;
+ SILC_LOG_DEBUG(("Regex match"));
+ SILC_LOG_DEBUG(("Find 'foobar' from %s", s1));
+ if (silc_string_match(s1, "foobar"))
+ goto err;
+ SILC_LOG_DEBUG(("Regex not found (Ok)"));
+
success = TRUE;
err: