Debian Codegraph @

tests/quickchecks.rs

raw symbols SCIP
1 use leb128;
2 use quickcheck;
3
4 use std::io;
5
6 #[test]
7 fn can_write_any_unsigned_int() {
8 fn f(x: u64) -> io::Result<()> {
9 let mut v = vec![];
10 leb128::write::unsigned(&mut v, x)?;
11 Ok(())
12 }
13 quickcheck::quickcheck(f as fn(u64) -> io::Result<()>);
14 }
15
16 #[test]
17 fn can_round_trip_any_unsigned_int() {
18 fn f(x: u64) -> io::Result<bool> {
19 let mut v = vec![];
20 leb128::write::unsigned(&mut v, x)?;
21 let y = leb128::read::unsigned(&mut &v[..])
22 .map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
23 Ok(x == y)
24 }
25 quickcheck::quickcheck(f as fn(u64) -> io::Result<bool>);
26 }
27
28 #[test]
29 fn can_write_any_signed_int() {
30 fn f(x: i64) -> io::Result<()> {
31 let mut v = vec![];
32 leb128::write::signed(&mut v, x)?;
33 Ok(())
34 }
35 quickcheck::quickcheck(f as fn(i64) -> io::Result<()>);
36 }
37
38 #[test]
39 fn can_round_trip_any_signed_int() {
40 fn f(x: i64) -> io::Result<bool> {
41 let mut v = vec![];
42 leb128::write::signed(&mut v, x)?;
43 let y = leb128::read::signed(&mut &v[..])
44 .map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
45 Ok(x == y)
46 }
47 quickcheck::quickcheck(f as fn(i64) -> io::Result<bool>);
48 }