Skip to content

Commit f53fc21

Browse files
committed
libserialize: Unconfigure tests during normal build
1 parent e839ffe commit f53fc21

File tree

3 files changed

+46
-45
lines changed

3 files changed

+46
-45
lines changed

src/libserialize/leb128.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -138,47 +138,3 @@ pub fn read_signed_leb128(data: &[u8], start_position: usize) -> (i128, usize) {
138138

139139
(result, position - start_position)
140140
}
141-
142-
macro_rules! impl_test_unsigned_leb128 {
143-
($test_name:ident, $write_fn_name:ident, $read_fn_name:ident, $int_ty:ident) => (
144-
#[test]
145-
fn $test_name() {
146-
let mut stream = Vec::new();
147-
148-
for x in 0..62 {
149-
$write_fn_name(&mut stream, (3u64 << x) as $int_ty);
150-
}
151-
152-
let mut position = 0;
153-
for x in 0..62 {
154-
let expected = (3u64 << x) as $int_ty;
155-
let (actual, bytes_read) = $read_fn_name(&stream[position ..]);
156-
assert_eq!(expected, actual);
157-
position += bytes_read;
158-
}
159-
assert_eq!(stream.len(), position);
160-
}
161-
)
162-
}
163-
164-
impl_test_unsigned_leb128!(test_u16_leb128, write_u16_leb128, read_u16_leb128, u16);
165-
impl_test_unsigned_leb128!(test_u32_leb128, write_u32_leb128, read_u32_leb128, u32);
166-
impl_test_unsigned_leb128!(test_u64_leb128, write_u64_leb128, read_u64_leb128, u64);
167-
impl_test_unsigned_leb128!(test_u128_leb128, write_u128_leb128, read_u128_leb128, u128);
168-
impl_test_unsigned_leb128!(test_usize_leb128, write_usize_leb128, read_usize_leb128, usize);
169-
170-
#[test]
171-
fn test_signed_leb128() {
172-
let values: Vec<_> = (-500..500).map(|i| i * 0x12345789ABCDEF).collect();
173-
let mut stream = Vec::new();
174-
for &x in &values {
175-
write_signed_leb128(&mut stream, x);
176-
}
177-
let mut pos = 0;
178-
for &x in &values {
179-
let (value, bytes_read) = read_signed_leb128(&mut stream, pos);
180-
pos += bytes_read;
181-
assert_eq!(x, value);
182-
}
183-
assert_eq!(pos, stream.len());
184-
}

src/libserialize/tests/leb128.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
extern crate serialize as rustc_serialize;
2+
use rustc_serialize::leb128::*;
3+
4+
macro_rules! impl_test_unsigned_leb128 {
5+
($test_name:ident, $write_fn_name:ident, $read_fn_name:ident, $int_ty:ident) => (
6+
#[test]
7+
fn $test_name() {
8+
let mut stream = Vec::new();
9+
10+
for x in 0..62 {
11+
$write_fn_name(&mut stream, (3u64 << x) as $int_ty);
12+
}
13+
14+
let mut position = 0;
15+
for x in 0..62 {
16+
let expected = (3u64 << x) as $int_ty;
17+
let (actual, bytes_read) = $read_fn_name(&stream[position ..]);
18+
assert_eq!(expected, actual);
19+
position += bytes_read;
20+
}
21+
assert_eq!(stream.len(), position);
22+
}
23+
)
24+
}
25+
26+
impl_test_unsigned_leb128!(test_u16_leb128, write_u16_leb128, read_u16_leb128, u16);
27+
impl_test_unsigned_leb128!(test_u32_leb128, write_u32_leb128, read_u32_leb128, u32);
28+
impl_test_unsigned_leb128!(test_u64_leb128, write_u64_leb128, read_u64_leb128, u64);
29+
impl_test_unsigned_leb128!(test_u128_leb128, write_u128_leb128, read_u128_leb128, u128);
30+
impl_test_unsigned_leb128!(test_usize_leb128, write_usize_leb128, read_usize_leb128, usize);
31+
32+
#[test]
33+
fn test_signed_leb128() {
34+
let values: Vec<_> = (-500..500).map(|i| i * 0x12345789ABCDEF).collect();
35+
let mut stream = Vec::new();
36+
for &x in &values {
37+
write_signed_leb128(&mut stream, x);
38+
}
39+
let mut pos = 0;
40+
for &x in &values {
41+
let (value, bytes_read) = read_signed_leb128(&mut stream, pos);
42+
pos += bytes_read;
43+
assert_eq!(x, value);
44+
}
45+
assert_eq!(pos, stream.len());
46+
}

src/tools/tidy/src/unit_tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ pub fn check(root_path: &Path, bad: &mut bool) {
3434
"librustc_lexer/src",
3535
"librustc_target/spec",
3636
"librustdoc",
37-
"libserialize",
3837
"libstd",
3938
"libsyntax",
4039
"libsyntax_pos",

0 commit comments

Comments
 (0)