Skip to content

Commit

Permalink
Add example test
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalswierczek committed Sep 18, 2022
1 parent f2b17e8 commit 063de6d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendor/
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@
"psr-4": {
"rafalswierczek\\NumeralSystem\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"rafalswierczek\\NumeralSystem\\Test\\": "test/"
}
}
}
39 changes: 39 additions & 0 deletions test/GeneralTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace rafalswierczek\NumeralSystem;

require dirname(__DIR__).'/vendor/autoload.php';

class GeneralTest
{
public function testAllMethods()
{
$binary = random_bytes(4);

$hexStringBC = BinConverter::toHexString($binary);
$binaryStringHSC = HexStringConverter::toBinString($hexStringBC);
$hexStringBSC = BinStringConverter::toHexString($binaryStringHSC);
$intHSC = HexStringConverter::toInt($hexStringBSC);
$hexStringIC = IntConverter::toHexString($intHSC);
$binaryHSC = HexStringConverter::toBin($hexStringIC);
$binaryBSC = BinStringConverter::toBin($binaryStringHSC);
$binaryIC = IntConverter::toBin($intHSC);
$binaryStringIC = IntConverter::toBinString($intHSC);
$binaryStringBC = BinConverter::toBinString($binaryHSC);
$intBC = BinConverter::toInt($binaryIC);
$intBSC = BinStringConverter::toInt($binaryStringIC);

print_r(($binaryHSC === $binaryBSC && $binaryHSC === $binaryIC ? 'OK' : 'ERROR') . ' | binary: HSC === BSC === IC');
echo "\n";

print_r(($binaryStringBC === $binaryStringHSC && $binaryStringBC === $binaryStringIC ? 'OK' : 'ERROR') . ' | binary string: BC === HSC === IC');
echo "\n";

print_r(($hexStringBC === $hexStringBSC && $hexStringBC === $hexStringIC ? 'OK' : 'ERROR') . ' | hex string: BC === BSC === IC');
echo "\n";

print_r(($intBSC === $intHSC && $intBSC === $intBC ? 'OK' : 'ERROR') . ' | int: BSC === HSC === BC');
}
}

(new GeneralTest())->testAllMethods();

0 comments on commit 063de6d

Please sign in to comment.