mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Add unit test for plugin
This commit is contained in:
parent
2551cce51e
commit
7bc88d541f
4 changed files with 41 additions and 0 deletions
1
components/servo/Cargo.lock
generated
1
components/servo/Cargo.lock
generated
|
@ -1280,6 +1280,7 @@ name = "util_tests"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
|
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
|
||||||
|
"plugins 0.0.1",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -11,5 +11,9 @@ doctest = false
|
||||||
[dependencies.util]
|
[dependencies.util]
|
||||||
path = "../../../components/util"
|
path = "../../../components/util"
|
||||||
|
|
||||||
|
|
||||||
|
[dependencies.plugins]
|
||||||
|
path = "../../../components/plugins"
|
||||||
|
|
||||||
[dependencies.geom]
|
[dependencies.geom]
|
||||||
git = "https://github.com/servo/rust-geom"
|
git = "https://github.com/servo/rust-geom"
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#![feature(plugin, custom_derive, custom_attributes)]
|
||||||
|
#![plugin(plugins)]
|
||||||
extern crate util;
|
extern crate util;
|
||||||
extern crate geom;
|
extern crate geom;
|
||||||
|
|
||||||
|
@ -9,3 +11,4 @@ extern crate geom;
|
||||||
#[cfg(test)] mod logical_geometry;
|
#[cfg(test)] mod logical_geometry;
|
||||||
#[cfg(test)] mod task;
|
#[cfg(test)] mod task;
|
||||||
#[cfg(test)] mod vec;
|
#[cfg(test)] mod vec;
|
||||||
|
#[cfg(test)] mod mem;
|
||||||
|
|
33
tests/unit/util/mem.rs
Normal file
33
tests/unit/util/mem.rs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/* 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 util::mem::HeapSizeOf;
|
||||||
|
|
||||||
|
|
||||||
|
struct Four;
|
||||||
|
impl HeapSizeOf for Four {
|
||||||
|
fn heap_size_of_children(&self) -> usize {
|
||||||
|
4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(HeapSizeOf)]
|
||||||
|
struct Eight(Four, Four, bool, bool, bool);
|
||||||
|
|
||||||
|
#[derive(HeapSizeOf)]
|
||||||
|
enum EightOrFour {
|
||||||
|
Eight(Eight),
|
||||||
|
Four(Four),
|
||||||
|
Zero(u8)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_heap_size() {
|
||||||
|
assert_eq!(Four.heap_size_of_children(), 4);
|
||||||
|
let eight = Eight(Four, Four, true, true, true);
|
||||||
|
assert_eq!(eight.heap_size_of_children(), 8);
|
||||||
|
assert_eq!(EightOrFour::Eight(eight).heap_size_of_children(), 8);
|
||||||
|
assert_eq!(EightOrFour::Four(Four).heap_size_of_children(), 4);
|
||||||
|
assert_eq!(EightOrFour::Zero(1).heap_size_of_children(), 0);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue