Add a test to check the size of PropertyDeclaration

This commit is contained in:
Nazım Can Altınova 2017-02-08 23:46:33 +03:00 committed by Simon Sapin
parent 9eaf96b737
commit 9204f2aaad
2 changed files with 25 additions and 0 deletions

View file

@ -32,6 +32,7 @@ mod owning_handle;
mod parsing;
mod properties;
mod rule_tree;
mod size_of;
mod str;
mod stylesheets;
mod stylist;

View file

@ -0,0 +1,24 @@
/* 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 std::mem::size_of;
use style::properties::PropertyDeclaration;
#[test]
fn size_of_property_declaration() {
let old = 240;
let new = size_of::<PropertyDeclaration>();
if new < old {
panic!("Your changes have decreased the stack size of PropertyDeclaration enum from {} to {}. \
Good work! Please update the size in tests/unit/style/size_of.rs.",
old, new)
} else if new > old {
panic!("Your changes have increased the stack size of PropertyDeclaration enum from {} to {}. \
These enum is present in large quantities in the style, and increasing the size \
may dramatically affect our memory footprint. Please consider using `boxed=\"True\"` in \
the longhand If you feel that the increase is necessary, update to the new size in \
tests/unit/style/size_of.rs.",
old, new)
}
}