diff options
author | Valentin Popov <valentin@popov.link> | 2024-01-08 00:21:28 +0300 |
---|---|---|
committer | Valentin Popov <valentin@popov.link> | 2024-01-08 00:21:28 +0300 |
commit | 1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch) | |
tree | 7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/unicode-ident/tests/static_size.rs | |
parent | 5ecd8cf2cba827454317368b68571df0d13d7842 (diff) | |
download | fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip |
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/unicode-ident/tests/static_size.rs')
-rw-r--r-- | vendor/unicode-ident/tests/static_size.rs | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/vendor/unicode-ident/tests/static_size.rs b/vendor/unicode-ident/tests/static_size.rs new file mode 100644 index 0000000..2df3537 --- /dev/null +++ b/vendor/unicode-ident/tests/static_size.rs @@ -0,0 +1,95 @@ +#![allow(clippy::let_underscore_untyped, clippy::unreadable_literal)] + +use std::mem::size_of_val; + +#[test] +fn test_size() { + #[allow(dead_code)] + #[path = "../src/tables.rs"] + mod tables; + + let size = size_of_val(&tables::ASCII_START) + + size_of_val(&tables::ASCII_CONTINUE) + + size_of_val(&tables::TRIE_START) + + size_of_val(&tables::TRIE_CONTINUE) + + size_of_val(&tables::LEAF); + assert_eq!(10080, size); +} + +#[test] +fn test_xid_size() { + #[deny(dead_code)] + #[path = "tables/mod.rs"] + mod tables; + + let size = size_of_val(tables::XID_START) + size_of_val(tables::XID_CONTINUE); + assert_eq!(11544, size); + + let _ = tables::BY_NAME; +} + +#[cfg(target_pointer_width = "64")] +#[test] +fn test_trieset_size() { + #[deny(dead_code)] + #[allow(clippy::redundant_static_lifetimes)] + #[path = "trie/trie.rs"] + mod trie; + + let ucd_trie::TrieSet { + tree1_level1, + tree2_level1, + tree2_level2, + tree3_level1, + tree3_level2, + tree3_level3, + } = *trie::XID_START; + + let start_size = size_of_val(trie::XID_START) + + size_of_val(tree1_level1) + + size_of_val(tree2_level1) + + size_of_val(tree2_level2) + + size_of_val(tree3_level1) + + size_of_val(tree3_level2) + + size_of_val(tree3_level3); + + let ucd_trie::TrieSet { + tree1_level1, + tree2_level1, + tree2_level2, + tree3_level1, + tree3_level2, + tree3_level3, + } = *trie::XID_CONTINUE; + + let continue_size = size_of_val(trie::XID_CONTINUE) + + size_of_val(tree1_level1) + + size_of_val(tree2_level1) + + size_of_val(tree2_level2) + + size_of_val(tree3_level1) + + size_of_val(tree3_level2) + + size_of_val(tree3_level3); + + assert_eq!(10200, start_size + continue_size); + + let _ = trie::BY_NAME; +} + +#[test] +fn test_fst_size() { + let xid_start_fst = include_bytes!("fst/xid_start.fst"); + let xid_continue_fst = include_bytes!("fst/xid_continue.fst"); + let size = xid_start_fst.len() + xid_continue_fst.len(); + assert_eq!(138736, size); +} + +#[test] +fn test_roaring_size() { + #[path = "roaring/mod.rs"] + mod roaring; + + let xid_start_bitmap = roaring::xid_start_bitmap(); + let xid_continue_bitmap = roaring::xid_continue_bitmap(); + let size = xid_start_bitmap.serialized_size() + xid_continue_bitmap.serialized_size(); + assert_eq!(66104, size); +} |