2024-03-02 10:10:21 +00:00
|
|
|
{ pkgs, lib, self }:
|
2024-02-24 11:09:28 +00:00
|
|
|
|
2024-03-02 10:10:21 +00:00
|
|
|
lib.runTests {
|
2024-02-24 13:39:59 +00:00
|
|
|
testToHexString = {
|
2024-03-02 10:10:21 +00:00
|
|
|
expr = self.hex.fromDec 293454837;
|
2024-02-24 11:09:28 +00:00
|
|
|
expected = "117DC3F5";
|
|
|
|
};
|
|
|
|
|
2024-02-28 10:43:20 +00:00
|
|
|
testToHexString2 = {
|
2024-03-02 10:10:21 +00:00
|
|
|
expr = self.hex.fromDec 4500;
|
2024-02-28 10:43:20 +00:00
|
|
|
expected = "1194";
|
|
|
|
};
|
|
|
|
|
|
|
|
testToHexString3 = {
|
2024-03-02 10:10:21 +00:00
|
|
|
expr = self.hex.fromDec 5942819;
|
2024-02-28 10:43:20 +00:00
|
|
|
expected = "5AAE23";
|
|
|
|
};
|
|
|
|
|
|
|
|
testHexToDec = {
|
2024-03-02 10:10:21 +00:00
|
|
|
expr = self.hex.toDec "FF";
|
2024-02-28 10:43:20 +00:00
|
|
|
expected = 255;
|
|
|
|
};
|
|
|
|
|
|
|
|
testHexToDec2 = {
|
2024-03-02 10:10:21 +00:00
|
|
|
expr = self.hex.toDec "333FAB333";
|
2024-02-28 10:43:20 +00:00
|
|
|
expected = 13756969779;
|
|
|
|
};
|
|
|
|
|
2024-02-24 11:09:28 +00:00
|
|
|
testCreateHexRange = {
|
2024-03-02 10:10:21 +00:00
|
|
|
expr = self.hex.range 10 17;
|
2024-02-24 11:09:28 +00:00
|
|
|
expected = [ "A" "B" "C" "D" "E" "F" "10" "11" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
testCreateHexWithHigherStart = {
|
2024-03-02 10:10:21 +00:00
|
|
|
expr = self.hex.range 49 17;
|
2024-02-24 11:09:28 +00:00
|
|
|
expected = [ ];
|
|
|
|
};
|
2024-02-24 13:34:03 +00:00
|
|
|
|
|
|
|
testIsHexString = {
|
2024-03-02 10:10:21 +00:00
|
|
|
expr = self.hex.isHexString "ABC";
|
2024-02-24 13:34:03 +00:00
|
|
|
expected = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
testIsHexStringWithInvalidHex = {
|
2024-03-02 10:10:21 +00:00
|
|
|
expr = self.hex.isHexString "WHAT IS THIS";
|
2024-02-24 13:34:03 +00:00
|
|
|
expected = false;
|
|
|
|
};
|
2024-02-24 13:36:51 +00:00
|
|
|
|
|
|
|
testHexPad = {
|
2024-03-02 10:10:21 +00:00
|
|
|
expr = self.hex.pad 5 "A";
|
2024-02-24 13:36:51 +00:00
|
|
|
expected = "0000A";
|
|
|
|
};
|
|
|
|
|
|
|
|
testHexPadWithLowerMaxDigits = {
|
2024-03-02 10:10:21 +00:00
|
|
|
expr = self.hex.pad 1 "9AC";
|
2024-02-24 13:36:51 +00:00
|
|
|
expected = "9AC";
|
|
|
|
};
|
|
|
|
|
|
|
|
testHexPadWithNegativeDigits = {
|
2024-03-02 10:10:21 +00:00
|
|
|
expr = self.hex.pad (-5) "A42C";
|
2024-02-24 13:36:51 +00:00
|
|
|
expected = "A42C";
|
|
|
|
};
|
2024-02-24 11:09:28 +00:00
|
|
|
}
|