/* Buffer formatting tests */
-#include "silc.h"
+#include "silcruntime.h"
int print(SilcStack stack, SilcBuffer buf, void *value, void *context)
{
if (silc_buffer_format(&buf,
SILC_STR_REGEX("foo", SILC_STR_REGEX_ALL |
SILC_STR_REGEX_INCLUSIVE),
- SILC_STR_STRING_APPEND("barbar"),
+ SILC_STR_REPLACE("barbar", 6),
SILC_STR_END,
SILC_STR_END) < 0)
goto err;
if (silc_buffer_format(&buf,
SILC_STR_REGEX("foo", SILC_STR_REGEX_ALL |
SILC_STR_REGEX_INCLUSIVE),
- SILC_STR_DELETE(-1),
+ SILC_STR_REPLACE("", 0),
SILC_STR_END,
SILC_STR_END) < 0)
goto err;
SILC_STR_END, SILC_STR_END) < 0)
goto err;
+ SILC_LOG_DEBUG(("Print all lines"));
+ silc_snprintf(string, sizeof(string),
+ "Rfoo\n\n\nbazfoobar\nRbarfoofoo\nRbar\nbaz\nRbazfoo");
+ silc_buffer_set(&buf, string, strlen(string));
+ SILC_LOG_DEBUG(("string: %s", string));
+ if (silc_buffer_unformat(&buf,
+ SILC_STR_REGEX("", SILC_STR_REGEX_NL),
+ SILC_STR_FUNC(print, NULL, NULL),
+ SILC_STR_END, SILC_STR_END) < 0)
+ goto err;
+
success = TRUE;
err:
SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE"));
fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE");
- return success;
+ return !success;
}