|
1 | | -use std::{collections::BTreeSet, fs}; |
| 1 | +use std::collections::BTreeSet; |
2 | 2 |
|
3 | | -use crate::utils::TwoFaceAsset; |
| 3 | +use crate::utils::{Asset, AssetFingerprint, SyntectAsset, TwoFaceAsset}; |
4 | 4 |
|
5 | 5 | #[test] |
6 | 6 | fn embedded_asset_sizes() { |
7 | 7 | #[track_caller] |
8 | | - fn kib(gen: TwoFaceAsset) -> usize { |
9 | | - let meta = fs::metadata(gen.rel_path()).unwrap(); |
10 | | - (meta.len() as f64 / 1_024.0).round() as usize |
| 8 | + fn kib(gen: Asset) -> usize { |
| 9 | + let fingerprint: AssetFingerprint = gen.into(); |
| 10 | + (fingerprint.size as f64 / 1_024.0).round() as usize |
11 | 11 | } |
12 | 12 |
|
13 | | - assert_eq!(10, kib(TwoFaceAsset::AckFull)); |
| 13 | + let tf_ack = kib(TwoFaceAsset::AckFull.into()); |
| 14 | + let tf_son = kib(TwoFaceAsset::SynOnigNewlines.into()); |
| 15 | + let tf_sfn = kib(TwoFaceAsset::SynFancyNewlines.into()); |
| 16 | + let tf_sonn = kib(TwoFaceAsset::SynOnigNoNewlines.into()); |
| 17 | + let tf_sfnn = kib(TwoFaceAsset::SynFancyNoNewlines.into()); |
| 18 | + let tf_themes = kib(TwoFaceAsset::Themes.into()); |
14 | 19 |
|
15 | | - assert_eq!(939, kib(TwoFaceAsset::SynOnigNewlines)); |
16 | | - assert_eq!(884, kib(TwoFaceAsset::SynFancyNewlines)); |
| 20 | + let syn_sn = kib(SyntectAsset::SynNewlines.into()); |
| 21 | + let syn_snn = kib(SyntectAsset::SynNoNewlines.into()); |
| 22 | + let syn_themes = kib(SyntectAsset::Themes.into()); |
17 | 23 |
|
18 | | - assert_eq!(938, kib(TwoFaceAsset::SynOnigNoNewlines)); |
19 | | - assert_eq!(883, kib(TwoFaceAsset::SynFancyNoNewlines)); |
| 24 | + let table = format!( |
| 25 | + "\ |
| 26 | + | function | `two-face` (KiB) | `syntect` (KiB) |\n\ |
| 27 | + | ---: | ---: | ---: |\n\ |
| 28 | + | [`acknowledgement::listing()`] | {tf_ack} | - |\n\ |
| 29 | + | [`syntax::extra_newlines()`] (onig) | {tf_son} | {syn_sn} |\n\ |
| 30 | + | ^^ (fancy) | {tf_sfn} | ^^ |\n\ |
| 31 | + | [`syntax::extra_no_newlines()`] (onig) | {tf_sonn} | {syn_snn} |\n\ |
| 32 | + | ^^ (fancy) | {tf_sfnn} | ^^ |\n\ |
| 33 | + | [`theme::extra()`] | {tf_themes} | {syn_themes} |\n\ |
| 34 | + " |
| 35 | + ); |
20 | 36 |
|
21 | | - assert_eq!(62, kib(TwoFaceAsset::Themes)); |
| 37 | + insta::assert_snapshot!( |
| 38 | + table, |
| 39 | + @r" |
| 40 | + | function | `two-face` (KiB) | `syntect` (KiB) | |
| 41 | + | ---: | ---: | ---: | |
| 42 | + | [`acknowledgement::listing()`] | 10 | - | |
| 43 | + | [`syntax::extra_newlines()`] (onig) | 939 | 360 | |
| 44 | + | ^^ (fancy) | 884 | ^^ | |
| 45 | + | [`syntax::extra_no_newlines()`] (onig) | 938 | 359 | |
| 46 | + | ^^ (fancy) | 883 | ^^ | |
| 47 | + | [`theme::extra()`] | 62 | 5 | |
| 48 | + " |
| 49 | + ); |
22 | 50 | } |
23 | 51 |
|
24 | 52 | #[rustfmt::skip] |
|
0 commit comments