Source
['text {? last(/host/key, #25) + max(sum(/host/key, 1d:now/d), sum(/host/key, 1d:now/d-1d)) } text', [], 5, [
<?php declare(strict_types = 0);
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
use PHPUnit\Framework\TestCase;
class CExpressionMacroParserTest extends TestCase {
public static function dataProvider() {
return [
['', [], 0, [
'rc' => CParser::PARSE_FAIL,
'match' => '',
'length' => 0
]],
['{', [], 0, [
'rc' => CParser::PARSE_FAIL,
'match' => '',
'length' => 0
]],
['{?', [], 0, [
'rc' => CParser::PARSE_FAIL,
'match' => '',
'length' => 0
]],
['text {?}', [], 5, [
'rc' => CParser::PARSE_FAIL,
'match' => '',
'length' => 0
]],
['text {?1+1}', [], 5, [
'rc' => CParser::PARSE_SUCCESS,
'match' => '{?1+1}',
'length' => 6
]],
['text {?1+1} text', [], 5, [
'rc' => CParser::PARSE_SUCCESS_CONT,
'match' => '{?1+1}',
'length' => 6
]],
['text {? 1 + 1 }', [], 5, [
'rc' => CParser::PARSE_SUCCESS,
'match' => '{? 1 + 1 }',
'length' => 12
]],
['text {?last(/'.'/system.cpu.load)}', [], 5, [
'rc' => CParser::PARSE_FAIL,
'match' => '',
'length' => 0
]],
['text {?last(/'.'/system.cpu.load)}', ['empty_host' => true], 5, [