1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 13:56:37 +02:00

api: add support of evaluated sub-strings and current date/time in function string_eval_expression() and command /eval

This commit is contained in:
Sébastien Helleu
2015-06-30 20:25:35 +02:00
parent e92a63427f
commit 9bf40517d3
26 changed files with 454 additions and 259 deletions
+13
View File
@@ -24,6 +24,7 @@
extern "C"
{
#include <stdio.h>
#include <string.h>
#include <regex.h>
#include "src/core/wee-eval.h"
#include "src/core/wee-config.h"
@@ -198,6 +199,9 @@ TEST(Eval, EvalExpression)
WEE_CHECK_EVAL("", "${}");
WEE_CHECK_EVAL("", "${xyz}");
/* test eval of substring */
WEE_CHECK_EVAL("\t", "${eval:${\\t}}");
/* test value from extra_vars */
WEE_CHECK_EVAL("value", "${test}");
@@ -230,6 +234,15 @@ TEST(Eval, EvalExpression)
/* test info */
WEE_CHECK_EVAL(version_get_version (), "${info:version}");
/* test date */
value = eval_expression ("${date}", pointers, extra_vars, options);
LONGS_EQUAL(19, strlen (value));
free (value);
value = eval_expression ("${date:%H:%M:%S}",
pointers, extra_vars, options);
LONGS_EQUAL(8, strlen (value));
free (value);
/* test option */
snprintf (str_value, sizeof (str_value),
"%d", CONFIG_INTEGER(config_look_scroll_amount));