1 // This file is Copyright its original authors, visible in version control
4 // This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
5 // or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
7 // You may not use this file except in accordance with one or both of these
10 use lightning::util::zbase32;
12 use crate::utils::test_logger;
15 pub fn do_test(data: &[u8]) {
16 let res = zbase32::encode(data);
17 assert_eq!(&zbase32::decode(&res).unwrap()[..], data);
19 if let Ok(s) = std::str::from_utf8(data) {
20 if let Ok(decoded) = zbase32::decode(s) {
21 assert_eq!(&zbase32::encode(&decoded), &s.to_ascii_lowercase());
26 pub fn zbase32_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
31 pub extern "C" fn zbase32_run(data: *const u8, datalen: usize) {
32 do_test(unsafe { std::slice::from_raw_parts(data, datalen) });