diff options
Diffstat (limited to 'api/bytes.yaml')
| -rw-r--r-- | api/bytes.yaml | 55 |
1 files changed, 21 insertions, 34 deletions
diff --git a/api/bytes.yaml b/api/bytes.yaml index f7b8cb5d..dea650e2 100644 --- a/api/bytes.yaml +++ b/api/bytes.yaml @@ -19,14 +19,10 @@ Byte.get_bit: description: > The index of the bit to check (1-indexed, range 1-8). example: | - >> Byte(6).get_bit(1) - = no - >> Byte(6).get_bit(2) - = yes - >> Byte(6).get_bit(3) - = yes - >> Byte(6).get_bit(4) - = no + assert Byte(6).get_bit(1) == no + assert Byte(6).get_bit(2) == yes + assert Byte(6).get_bit(3) == yes + assert Byte(6).get_bit(4) == no Byte.hex: short: convert to hexidecimal @@ -52,8 +48,7 @@ Byte.hex: description: > Whether or not to prepend a `0x` prefix. example: | - >> Byte(18).hex() - = "0x12" + assert Byte(18).hex() == "0x12" Byte.is_between: short: test if inside a range @@ -77,12 +72,9 @@ Byte.is_between: description: > The upper bound to check (inclusive). example: | - >> Byte(7).is_between(1, 10) - = yes - >> Byte(7).is_between(100, 200) - = no - >> Byte(7).is_between(1, 7) - = yes + assert Byte(7).is_between(1, 10) == yes + assert Byte(7).is_between(100, 200) == no + assert Byte(7).is_between(1, 7) == yes Byte.parse: short: convert text to a byte @@ -104,18 +96,13 @@ Byte.parse: If non-none, this argument will be set to the remainder of the text after the matching part. If none, parsing will only succeed if the entire text matches. example: | - >> Byte.parse("5") - = Byte(5) : Byte? - >> Byte.parse("asdf") - = none : Byte? + assert Byte.parse("5") == Byte(5) + assert Byte.parse("asdf") == none + assert Byte.parse("123xyz") == none - >> Byte.parse("123xyz") - = none : Byte? remainder : Text - >> Byte.parse("123xyz", &remainder) - = Byte(123) : Byte? - >> remainder - = "xyz" + assert Byte.parse("123xyz", &remainder) == Byte(123) + assert remainder == "xyz" Byte.to: short: iterate over a range of bytes @@ -140,13 +127,13 @@ Byte.to: description: > An optional step size to use. If unspecified or `none`, the step will be inferred to be `+1` if `last >= first`, otherwise `-1`. example: | - >> Byte(2).to(5) - = func(->Byte?) - >> [x for x in Byte(2).to(5)] - = [Byte(2), Byte(3), Byte(4), Byte(5)] - >> [x for x in Byte(5).to(2)] - = [Byte(5), Byte(4), Byte(3), Byte(2)] + iter := Byte(2).to(4) + assert iter() == 2 + assert iter() == 3 + assert iter() == 4 + assert iter() == none - >> [x for x in Byte(2).to(5, step=2)] - = [Byte(2), Byte(4)] + assert [x for x in Byte(2).to(5)] == [Byte(2), Byte(3), Byte(4), Byte(5)] + assert [x for x in Byte(5).to(2)] == [Byte(5), Byte(4), Byte(3), Byte(2)] + assert [x for x in Byte(2).to(5, step=2)] == [Byte(2), Byte(4)] |
