Source
xxxxxxxxxx
'{$M} { label1 = "value1" , label2 =~ "{$M}" , } == {#LLD}', 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 CPrometheusPatternParserTest extends TestCase {
/**
* An array of Prometheus patterns and parsed results.
*/
public static function dataProvider() {
return [
// success
[
'metric', 0, [],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => 'metric'
]
],
[
'{}', 0, [],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => '{}'
]
],
[
'metric{}', 0, [],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => 'metric{}'
]
],
[
"{ \t}", 0, [],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => "{ \t}"
]
],
[
"metric\t { \t}", 0, [],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => "metric\t { \t}"
]
],
[
'metric==6', 0, [],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => 'metric==6'
]
],
[
'metric==-100', 0, [],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => 'metric==-100'
]
],
[
'metric==-.0e4', 0, [],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => 'metric==-.0e4'
]
],
[
'metric==1.e1', 0, [],
[
'rc' => CParser::PARSE_SUCCESS,
'match' => 'metric==1.e1'
]
],
[
'metric==+Inf', 0, [],