Source
xxxxxxxxxx
'100-200,{#M}-{$M},300-{$M},{#M}-400,{#M}-{#N},{#Z}', 0, ['usermacros' => true, 'lldmacros' => true],
<?php
/*
** 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 CRangesParserTest extends TestCase {
/**
* An array of time periods and parsed results.
*/
public static function dataProvider() {
return [
// success
[
'200,100', 0, [],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => '200,100',
'ranges' => [['200'],['100']]
]
],
[
'500-600,200', 0, [],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => '500-600,200',
'ranges' => [
['500', '600'],
['200']
]
]
],
[
'500-600,200-200', 0, [],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => '500-600,200-200',
'ranges' => [
['500', '600'],
['200', '200']
]
]
],
[
'500,600-700', 0, [],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => '500,600-700',
'ranges' => [
['500'],
['600', '700']
]
]
],
[
'150,250-350,400,450-600', 0, [],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => '150,250-350,400,450-600',
'ranges' => [
['150'],
['250', '350'],
['400'],
['450', '600']
]
]
],
[
'100,{$M},{$M.A}-{$M.B},200,{$M.C}-300', 0, ['usermacros' => true],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => '100,{$M},{$M.A}-{$M.B},200,{$M.C}-300',
'ranges' => [
['100'],
['{$M}'],
['{$M.A}', '{$M.B}'],
['200'],
['{$M.C}', '300']