Debian Codegraph @

debian/patches/fix-tests.diff

raw
1 Index: cobs/tests/test.rs
2 ===================================================================
3 --- a/tests/test.rs
4 +++ b/tests/test.rs
5 @@ -2,8 +2,9 @@ extern crate cobs;
6 extern crate quickcheck;
7
8 use quickcheck::{quickcheck, TestResult};
9 -use cobs::{max_encoding_length, encode, decode, encode_vec, decode_vec};
10 -use cobs::{encode_vec_with_sentinel, decode_vec_with_sentinel};
11 +use cobs::{max_encoding_length, encode, decode};
12 +#[cfg(feature="use_std")]
13 +use cobs::{encode_vec, decode_vec, encode_vec_with_sentinel, decode_vec_with_sentinel};
14 use cobs::{CobsEncoder, CobsDecoder};
15
16 fn test_pair(source: Vec<u8>, encoded: Vec<u8>) {
17 @@ -22,6 +23,7 @@ fn test_pair(source: Vec<u8>, encoded: Vec<u8>) {
18 assert_eq!(source, test_decoded);
19 }
20
21 +#[cfg(feature="use_std")]
22 fn test_roundtrip(source: Vec<u8>) {
23 let encoded = encode_vec(&source);
24 let decoded = decode_vec(&encoded).expect("decode_vec");
25 @@ -114,11 +116,13 @@ fn test_encode_4() {
26 test_pair(vec![1], vec![2, 1])
27 }
28
29 +#[cfg(feature="use_std")]
30 #[test]
31 fn test_roundtrip_1() {
32 test_roundtrip(vec![1,2,3]);
33 }
34
35 +#[cfg(feature="use_std")]
36 #[test]
37 fn test_roundtrip_2() {
38 for i in 0..5usize {
39 @@ -130,6 +134,7 @@ fn test_roundtrip_2() {
40 }
41 }
42
43 +#[cfg(feature="use_std")]
44 fn identity(source: Vec<u8>, sentinel: u8) -> TestResult {
45 let encoded = encode_vec_with_sentinel(&source[..], sentinel);
46
47 @@ -153,11 +158,13 @@ fn identity(source: Vec<u8>, sentinel: u8) -> TestResult {
48 }
49 }
50
51 +#[cfg(feature="use_std")]
52 #[test]
53 fn test_encode_decode_with_sentinel() {
54 quickcheck(identity as fn(Vec<u8>, u8) -> TestResult);
55 }
56
57 +#[cfg(feature="use_std")]
58 #[test]
59 fn test_encode_decode() {
60 fn identity_default_sentinel(source: Vec<u8>) -> TestResult {
61 @@ -246,6 +253,7 @@ fn wikipedia_ex_10() {
62 test_pair(unencoded, encoded);
63 }
64
65 +#[cfg(feature="use_std")]
66 #[test]
67 fn issue_15() {
68 // Reported: https://github.com/awelkie/cobs.rs/issues/15
69