mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
wrap tests with #[cfg(test)]
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
This commit is contained in:
parent
d18000fee8
commit
be6105a202
6 changed files with 455 additions and 431 deletions
|
@ -130,6 +130,10 @@ impl From<PrefValue> for [f64; 4] {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::PrefValue;
|
||||
|
||||
#[test]
|
||||
fn test_pref_value_from_str() {
|
||||
let value = PrefValue::from_booleanish_str("21");
|
||||
|
@ -147,3 +151,4 @@ fn test_pref_value_from_str() {
|
|||
let value = PrefValue::from_booleanish_str("true");
|
||||
assert_eq!(value, PrefValue::Bool(true));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,6 +81,8 @@ impl DevtoolsOuterWindowId {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
pub(crate) fn test_id_map() {
|
||||
use std::thread;
|
||||
|
@ -173,3 +175,4 @@ pub(crate) fn test_id_map() {
|
|||
|id_map: &mut IdMap, id| id_map.outer_window_id(id)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@ impl LineBreaker {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn test_linebreaker_ranges() {
|
||||
let linebreaker = LineBreaker::new("abc def");
|
||||
|
@ -118,3 +120,4 @@ fn test_linebreaker_stateful_advance() {
|
|||
})
|
||||
.expect_err("Reversed range should cause an assertion failure.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -277,6 +277,8 @@ impl ProgressiveWebMetrics {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn test_metrics() -> ProgressiveWebMetrics {
|
||||
let (sender, _) = ipc_channel::ipc::channel().unwrap();
|
||||
let profiler_chan = ProfilerChan(sender);
|
||||
|
@ -369,3 +371,4 @@ fn test_first_contentful_paint_setter() {
|
|||
metrics.set_first_contentful_paint(CrossProcessInstant::now(), false);
|
||||
assert!(metrics.first_contentful_paint().is_some());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -590,6 +590,8 @@ pub trait WebViewDelegate {
|
|||
pub(crate) struct DefaultWebViewDelegate;
|
||||
impl WebViewDelegate for DefaultWebViewDelegate {}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn test_allow_deny_request() {
|
||||
use ipc_channel::ipc;
|
||||
|
@ -714,7 +716,9 @@ fn test_web_resource_load() {
|
|||
is_redirect: false,
|
||||
};
|
||||
let web_resource_response = || {
|
||||
WebResourceResponse::new(Url::parse("https://diffie.test").expect("Guaranteed by argument"))
|
||||
WebResourceResponse::new(
|
||||
Url::parse("https://diffie.test").expect("Guaranteed by argument"),
|
||||
)
|
||||
.status_code(StatusCode::IM_A_TEAPOT)
|
||||
};
|
||||
|
||||
|
@ -786,3 +790,4 @@ fn test_web_resource_load() {
|
|||
drop(request);
|
||||
assert!(errors.try_recv().is_none());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,10 @@ pub fn is_cjk(codepoint: char) -> bool {
|
|||
unicode_plane(codepoint) == 2 || unicode_plane(codepoint) == 3
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::is_cjk;
|
||||
|
||||
#[test]
|
||||
fn test_is_cjk() {
|
||||
// Test characters from different CJK blocks
|
||||
|
@ -62,3 +66,4 @@ fn test_is_cjk() {
|
|||
assert_eq!(is_cjk('🙂'), false);
|
||||
assert_eq!(is_cjk('©'), false);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue