1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-05 17:23:15 +02:00

core: use function util_strftimeval in evaluation of expression date:xxx

This commit is contained in:
Sébastien Helleu
2024-01-27 12:15:40 +01:00
parent e3af6a91d4
commit 2469dc6df9
8 changed files with 52 additions and 28 deletions
+11 -1
View File
@@ -26,6 +26,7 @@ extern "C"
#include <stdio.h>
#include <string.h>
#include <regex.h>
#include <time.h>
#include "src/core/wee-eval.h"
#include "src/core/wee-config.h"
#include "src/core/wee-config-file.h"
@@ -453,8 +454,10 @@ TEST(CoreEval, EvalExpression)
{
struct t_hashtable *pointers, *extra_vars, *options;
struct t_config_option *ptr_option;
char *value, str_value[256], str_expr[256];
char *value, str_value[256], str_expr[256], *error;
const char *ptr_debug_output;
long number;
time_t time_now;
pointers = hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
@@ -898,6 +901,13 @@ TEST(CoreEval, EvalExpression)
pointers, extra_vars, options);
LONGS_EQUAL(8, strlen (value));
free (value);
value = eval_expression ("${date:%!}", pointers, extra_vars, options);
CHECK(value);
error = NULL;
number = strtol (value, &error, 10);
CHECK(error && !error[0]);
time_now = time (NULL);
CHECK((number >= time_now - 10) && (number <= time_now + 10));
/* test ternary operator */
WEE_CHECK_EVAL("1", "${if:5>2}");