/
size_of.rs
47 lines (40 loc) · 1.79 KB
/
size_of.rs
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
/* 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 layout::ServoThreadSafeLayoutNode;
use std::mem::size_of;
#[test]
fn test_size_of_fragment() {
let expected = 160;
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/unit/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/unit/layout/size_of.rs.",
expected, actual);
}
}
#[test]
fn test_size_of_layout_node() {
let expected = 16;
let actual = size_of::<ServoThreadSafeLayoutNode>();
if actual < expected {
panic!("Your changes have decreased the stack size of layout::wrapper::ServoThreadSafeLayoutNode \
from {} to {}. Good work! Please update the size in tests/layout/unit/size_of.rs",
expected, actual);
}
if actual > expected {
panic!("Your changes have increased the stack size of layout::wrapper::ServoThreadSafeLayoutNode \
from {} to {}. Please consider choosing a design which avoids this increase. \
If you feel that the increase is necessary, update the size in \
tests/unit/layout/size_of.rs.",
expected, actual);
}
}