1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
extern crate mpd;
mod helpers;
use helpers::connect;
use std::time::Duration;
#[test]
fn status() {
let mut mpd = connect();
let status = mpd.status().unwrap();
println!("{:?}", status);
}
#[test]
fn stats() {
let mut mpd = connect();
let stats = mpd.stats().unwrap();
println!("{:?}", stats);
}
macro_rules! test_options_impl {
($name:ident, $val1:expr, $tval1:expr, $val2:expr, $tval2:expr) => {
#[test]
fn $name() {
let mut mpd = connect();
mpd.$name($val1).unwrap();
assert_eq!(mpd.status().unwrap().$name, $tval1);
mpd.$name($val2).unwrap();
assert_eq!(mpd.status().unwrap().$name, $tval2);
}
}
}
macro_rules! test_option {
($name:ident, $val1:expr, $val2:expr) => {
test_options_impl!($name, $val1, $val1, $val2, $val2);
};
($name:ident, $val1:expr => $tval1:expr, $val2:expr => $tval2:expr) => {
test_options_impl!($name, $val1, $tval1, $val2, $tval2);
};
}
test_option!(consume, true, false);
test_option!(single, true, false);
test_option!(random, true, false);
test_option!(repeat, true, false);
// test_option!(mixrampdb, 1.0f32, 0.0f32);
// test_option!(mixrampdelay, 1 => Some(Duration::from_secs(1)), 0 => None);
#[test]
fn volume() {
let mut mpd = connect();
if mpd.status().unwrap().volume >= 0 {
mpd.volume(100).unwrap();
assert_eq!(mpd.status().unwrap().volume, 100);
mpd.volume(0).unwrap();
assert_eq!(mpd.status().unwrap().volume, 0);
}
}
#[test]
fn crossfade() {
let mut mpd = connect();
mpd.crossfade(1000).unwrap();
assert_eq!(mpd.status().unwrap().crossfade, Some(Duration::from_secs(1000)));
mpd.crossfade(0).unwrap();
assert_eq!(mpd.status().unwrap().crossfade,
if mpd.version >= mpd::Version(0, 19, 0) {
None
} else {
Some(Duration::from_secs(0))
});
}
|