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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#![deny(missing_docs)]
pub mod bulk;
pub mod card;
pub mod card_searcher;
pub mod catalog;
pub mod error;
pub mod format;
pub mod ruling;
pub mod set;
pub mod util;
pub use error::Result;
#[cfg(test)]
mod tests {
use crate::{
card_searcher::{SearchBuilder, StringParam},
set::{set_code::SetCode, Set},
};
use rayon::prelude::*;
use serde_json::{from_str, to_string};
use std::convert::TryFrom;
#[test]
fn set_code_serde_test() {
let instance = SetCode::try_from("war").unwrap();
let new_instance: SetCode = from_str(&to_string(&instance).unwrap()).unwrap();
assert_eq!(new_instance, instance);
let instance = SetCode::try_from("wwar").unwrap();
let new_instance: SetCode = from_str(&to_string(&instance).unwrap()).unwrap();
assert_eq!(new_instance, instance)
}
#[test]
#[ignore]
fn all_sets() {
let mut page = 1;
for sets in Set::all() {
if let Err(e) = sets {
panic!("Couldn't parse sets at page {}. Error: {}", page, e);
}
page += 1;
}
}
#[test]
#[ignore]
fn lattest_cards() {
Set::all()
.map(Result::unwrap)
.flatten()
.take(30)
.par_bridge()
.for_each(|set| {
SearchBuilder::new()
.param(StringParam::Set(set.code))
.search()
.enumerate()
.for_each(|(i, c)| {
if let Err(e) = c {
panic!("Card {} in set {} couldn't be parsed: {}", i, set.name, e)
}
});
})
}
}