Debian Codegraph @

debian/missing-sources/gio/tests/std_io_copy.rs

raw
1 use gio::prelude::*;
2
3 #[test]
4 fn std_io_copy_with_gio() {
5 let bytes = glib::Bytes::from_owned([1, 2, 3]);
6 let mut read = gio::MemoryInputStream::from_bytes(&bytes).into_read();
7 let mut write = gio::MemoryOutputStream::new_resizable().into_write();
8
9 let result = std::io::copy(&mut read, &mut write);
10
11 let out_stream = write.into_output_stream();
12 out_stream.close(gio::Cancellable::NONE).unwrap();
13 assert_eq!(result.unwrap(), 3);
14 assert_eq!(out_stream.steal_as_bytes(), bytes);
15 }