third_party_rust_unicode-ident/tests/static_size.rs
David Tolnay 90954572e0
Ignore let_underscore_untyped pedantic clippy lint
error: non-binding `let` without a type annotation
      --> generate/src/parse.rs:33:9
       |
    33 |         let _ = writeln!(io::stderr(), "{}: {err}\n{suggestion}", ucd_dir.display());
       |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = help: consider adding a type annotation or removing the `let` keyword
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_untyped
       = note: `-D clippy::let-underscore-untyped` implied by `-D clippy::pedantic`

    error: non-binding `let` without a type annotation
      --> generate/src/parse.rs:42:13
       |
    42 |             let _ = writeln!(io::stderr(), "{filename} line {i} is unexpected:\n{line}");
       |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = help: consider adding a type annotation or removing the `let` keyword
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_untyped

    error: non-binding `let` without a type annotation
       --> generate/src/main.rs:151:9
        |
    151 |         let _ = writeln!(io::stderr(), "{}: {err}", path.display());
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: consider adding a type annotation or removing the `let` keyword
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_untyped

    error: non-binding `let` without a type annotation
      --> tests/static_size.rs:28:5
       |
    28 |     let _ = tables::BY_NAME;
       |     ^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = help: consider adding a type annotation or removing the `let` keyword
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_untyped
       = note: `-D clippy::let-underscore-untyped` implied by `-D clippy::pedantic`

    error: non-binding `let` without a type annotation
      --> tests/static_size.rs:75:5
       |
    75 |     let _ = trie::BY_NAME;
       |     ^^^^^^^^^^^^^^^^^^^^^^
       |
       = help: consider adding a type annotation or removing the `let` keyword
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_untyped
2023-02-26 21:55:27 -07:00

96 lines
2.4 KiB
Rust

#![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!(10016, 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!(11528, 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!(10208, 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!(137749, 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);
}