mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Add a unit test for Fragment size
This commit is contained in:
parent
37799a4025
commit
14e945f09a
6 changed files with 59 additions and 0 deletions
|
@ -100,3 +100,6 @@ mod text;
|
|||
mod traversal;
|
||||
mod webrender_helpers;
|
||||
mod wrapper;
|
||||
|
||||
// For unit tests:
|
||||
pub use fragment::Fragment;
|
||||
|
|
8
components/servo/Cargo.lock
generated
8
components/servo/Cargo.lock
generated
|
@ -22,6 +22,7 @@ dependencies = [
|
|||
"ipc-channel 0.2.1 (git+https://github.com/servo/ipc-channel)",
|
||||
"layers 0.2.4 (git+https://github.com/servo/rust-layers)",
|
||||
"layout 0.0.1",
|
||||
"layout_tests 0.0.1",
|
||||
"libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
|
@ -1083,6 +1084,13 @@ dependencies = [
|
|||
"webrender_traits 0.1.0 (git+https://github.com/servo/webrender_traits)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "layout_tests"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"layout 0.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "layout_traits"
|
||||
version = "0.0.1"
|
||||
|
|
|
@ -24,6 +24,9 @@ image = "0.7"
|
|||
[dev-dependencies.gfx_tests]
|
||||
path = "../../tests/unit/gfx"
|
||||
|
||||
[dev-dependencies.layout_tests]
|
||||
path = "../../tests/unit/layout"
|
||||
|
||||
[dev-dependencies.net_tests]
|
||||
path = "../../tests/unit/net"
|
||||
|
||||
|
|
12
tests/unit/layout/Cargo.toml
Normal file
12
tests/unit/layout/Cargo.toml
Normal file
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "layout_tests"
|
||||
version = "0.0.1"
|
||||
authors = ["The Servo Project Developers"]
|
||||
|
||||
[lib]
|
||||
name = "layout_tests"
|
||||
path = "lib.rs"
|
||||
doctest = false
|
||||
|
||||
[dependencies.layout]
|
||||
path = "../../../components/layout"
|
7
tests/unit/layout/lib.rs
Normal file
7
tests/unit/layout/lib.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
extern crate layout;
|
||||
|
||||
#[cfg(all(test, target_pointer_width = "64"))] mod size_of;
|
26
tests/unit/layout/size_of.rs
Normal file
26
tests/unit/layout/size_of.rs
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use layout::Fragment;
|
||||
use std::mem::size_of;
|
||||
|
||||
#[test]
|
||||
fn test_size_of_fragment() {
|
||||
let expected = 184;
|
||||
let actual = size_of::<Fragment>();
|
||||
|
||||
if actual < expected {
|
||||
panic!("Your changes have decreased the stack size of layout::fragment::Fragment \
|
||||
from {} to {}. Good work! Please update the size in tests/layout/size_of.rs",
|
||||
expected, actual);
|
||||
}
|
||||
|
||||
if actual > expected {
|
||||
panic!("Your changes have increased the stack size of layout::fragment::Fragment \
|
||||
from {} to {}. Please consider choosing a design which avoids this increase. \
|
||||
If you feel that the increase is necessary, update the size in \
|
||||
tests/layout/size_of.rs.",
|
||||
expected, actual);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue