2024-02-24 11:09:28 +00:00
|
|
|
{ pkgs, lib }:
|
|
|
|
|
|
|
|
pkgs.lib.runTests {
|
2024-02-24 13:39:59 +00:00
|
|
|
testToHexString = {
|
2024-02-24 11:09:28 +00:00
|
|
|
expr = lib.hex.toHexString 293454837;
|
|
|
|
expected = "117DC3F5";
|
|
|
|
};
|
|
|
|
|
|
|
|
testCreateHexRange = {
|
|
|
|
expr = lib.hex.range 10 17;
|
|
|
|
expected = [ "A" "B" "C" "D" "E" "F" "10" "11" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
testCreateHexWithHigherStart = {
|
|
|
|
expr = lib.hex.range 49 17;
|
|
|
|
expected = [ ];
|
|
|
|
};
|
2024-02-24 13:34:03 +00:00
|
|
|
|
|
|
|
testIsHexString = {
|
|
|
|
expr = lib.hex.isHexString "ABC";
|
|
|
|
expected = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
testIsHexStringWithInvalidHex = {
|
|
|
|
expr = lib.hex.isHexString "WHAT IS THIS";
|
|
|
|
expected = false;
|
|
|
|
};
|
2024-02-24 13:36:51 +00:00
|
|
|
|
|
|
|
testHexPad = {
|
|
|
|
expr = lib.hex.pad 5 "A";
|
|
|
|
expected = "0000A";
|
|
|
|
};
|
|
|
|
|
|
|
|
testHexPadWithLowerMaxDigits = {
|
|
|
|
expr = lib.hex.pad 1 "9AC";
|
|
|
|
expected = "9AC";
|
|
|
|
};
|
|
|
|
|
|
|
|
testHexPadWithNegativeDigits = {
|
2024-02-25 09:22:53 +00:00
|
|
|
expr = lib.hex.pad (-5) "A42C";
|
2024-02-24 13:36:51 +00:00
|
|
|
expected = "A42C";
|
|
|
|
};
|
2024-02-24 11:09:28 +00:00
|
|
|
}
|