Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2021-08-10 02:33:04 +02:00
<?php
namespace LibreNMS\Tests\Unit\Util;
use LibreNMS\Tests\TestCase;
use LibreNMS\Util\Rewrite;
2023-05-24 22:30:01 +02:00
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
2021-08-10 02:33:04 +02:00
2023-05-24 20:23:38 +00:00
final class RewriteTest extends TestCase
2021-08-10 02:33:04 +02:00
{
2023-05-24 20:23:37 +00:00
#[Test]
#[DataProvider('validMacProvider')]
2021-08-10 02:33:04 +02:00
public function testMacToHex(string $from, string $to): void
{
2022-01-30 16:28:18 -06:00
$this->assertEquals($to, Rewrite::macToHex($from));
2021-08-10 02:33:04 +02:00
}
2023-05-24 20:23:37 +00:00
public static function validMacProvider(): array
2021-08-10 02:33:04 +02:00
{
return [
['00:00:00:00:00:01', '000000000001'],
['00-00-00-00-00-01', '000000000001'],
['000000.000001', '000000000001'],
['000000000001', '000000000001'],
['00:12:34:ab:cd:ef', '001234abcdef'],
2022-01-30 16:28:18 -06:00
['00:12:34:AB:CD:EF', '001234abcdef'],
['0:12:34:AB:CD:EF', '001234abcdef'],
['00-12-34-AB-CD-EF', '001234abcdef'],
['001234-ABCDEF', '001234abcdef'],
['0012.34AB.CDEF', '001234abcdef'],
['00:02:04:0B:0D:0F', '0002040b0d0f'],
['0:2:4:B:D:F', '0002040b0d0f'],
['0:2:4:B:D:F', '0002040b0d0f'],
['80 62 0c 85 25 5c e5 00', '0c85255ce500'], // BridgeId format
['80620c85255ce500', '0c85255ce500'],
2021-08-10 02:33:04 +02:00
];
}
}