feat: add Char.to-byte and Char.from-byte (#1187)

This commit is contained in:
Veit Heller 2021-03-16 11:14:16 +01:00 committed by GitHub
parent 007d020e05
commit 459a62e61f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View File

@ -6,6 +6,8 @@
(register > (Fn [Char Char] Bool))
(register to-int (Fn [Char] Int))
(register from-int (Fn [Int] Char))
(register to-byte (Fn [Char] Byte))
(register from-byte (Fn [Byte] Char))
(register copy (Fn [&Char] Char))
(implements < Char.<)

View File

@ -18,6 +18,14 @@ Char Char_from_MINUS_int(int i) {
return (Char)i;
}
int Char_to_MINUS_byte(Char c) {
return (uint8_t)c;
}
Char Char_from_MINUS_byte(uint8_t i) {
return (Char)i;
}
Char Char_copy(const Char *c) {
return *c;
}

View File

@ -134,4 +134,12 @@
(assert-true test
(alphanum? \0)
"alphanum? works as expected III")
(assert-equal test
48b
(to-byte \0)
"to-byte works as expected")
(assert-equal test
\A
(from-byte 65b)
"from-byte works as expected")
)