mirror of https://github.com/rwf2/Rocket.git
58 lines
1.7 KiB
Rust
58 lines
1.7 KiB
Rust
#[cfg(any(test, doctest))] rocket::internal_guide_tests!("../guide/*.md");
|
|
#[cfg(any(test, doctest))] rocket::internal_guide_tests!("../../../README.md");
|
|
|
|
#[macro_export]
|
|
macro_rules! map {
|
|
($($key:expr => $value:expr),* $(,)?) => ({
|
|
let mut map = std::collections::HashMap::new();
|
|
$(map.insert($key.into(), $value.into());)*
|
|
map
|
|
});
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! bmap {
|
|
($($key:expr => $value:expr),* $(,)?) => ({
|
|
let mut map = std::collections::BTreeMap::new();
|
|
$(map.insert($key.into(), $value.into());)*
|
|
map
|
|
});
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! assert_form_parses {
|
|
($T:ty, $form:expr => $value:expr) => (
|
|
let v = rocket::form::Form::<$T>::parse($form).unwrap();
|
|
assert_eq!(v, $value, "{}", $form);
|
|
);
|
|
|
|
($T:ty, $($form:expr => $value:expr),+ $(,)?) => (
|
|
$(assert_form_parses!($T, $form => $value);)+
|
|
);
|
|
|
|
($T:ty, $($form:expr),+ $(,)? => $value:expr) => (
|
|
$(assert_form_parses!($T, $form => $value);)+
|
|
);
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! assert_not_form_parses {
|
|
($T:ty, $($form:expr),* $(,)?) => ($(
|
|
rocket::form::Form::<$T>::parse($form).unwrap_err();
|
|
)*);
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! assert_form_parses_ok {
|
|
($T:ty, $($form:expr),* $(,)?) => ($(
|
|
rocket::form::Form::<$T>::parse($form).expect("form to parse");
|
|
)*);
|
|
}
|
|
|
|
pub fn client(routes: Vec<rocket::Route>) -> rocket::local::blocking::Client {
|
|
let mut config = rocket::Config::debug_default();
|
|
config.log_level = rocket::config::LogLevel::Debug;
|
|
let rocket = rocket::custom(config).mount("/", routes);
|
|
rocket::local::blocking::Client::tracked(rocket).unwrap()
|
|
}
|