Skip to content

Commit

Permalink
Deduplicate some repeated tests
Browse files Browse the repository at this point in the history
This removes one of each pair of equivalent tests duplicated within
`gix-index` and (separately) within `gix-pack`. See GitoxideLabs#1685.
  • Loading branch information
EliahKagan committed Nov 18, 2024
1 parent daf9990 commit dc0a73a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 71 deletions.
33 changes: 0 additions & 33 deletions gix-index/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,36 +237,3 @@ pub(crate) mod util {
data.split_at(pos).into()
}
}

// FIXME: Probably remove these in favor of the equivalent tests in `gix-index/tests/index/mod.rs`.
#[cfg(test)]
mod tests {
use gix_testtools::size_ok;

#[test]
fn size_of_entry() {
let actual = std::mem::size_of::<crate::Entry>();
let expected = 80;
assert!(
size_ok(actual, expected),
"the size of this structure should not change unexpectedly: {actual} <~ {expected}"
);
}

#[test]
fn size_of_entry_time() {
// The reason we have our own time is that it is half the size.
let ent_actual = std::mem::size_of::<crate::entry::stat::Time>();
let ent_expected = 8;
assert!(
size_ok(ent_actual, ent_expected),
"the size of this structure should not change unexpectedly: {ent_actual} <~ {ent_expected}"
);
let ft_actual = std::mem::size_of::<filetime::FileTime>();
let ft_expected = 16;
assert!(
size_ok(ft_actual, ft_expected),
"we will want to know if the size of this structure changes: {ft_actual} <~ {ft_expected}"
);
}
}
37 changes: 0 additions & 37 deletions gix-pack/src/cache/delta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,3 @@ pub mod from_offsets;
mod tree;

pub use tree::{Item, Tree};

// FIXME: Probably remove this pair of tests or the equivalent pair in `gix-pack/src/cache/delta/tree.rs`.
#[cfg(test)]
mod tests {
use super::Item;
use gix_testtools::size_ok;

#[test]
fn size_of_pack_tree_item() {
let actual = std::mem::size_of::<[Item<()>; 7_500_000]>();
let expected = 300_000_000;
assert!(
size_ok(actual, expected),
"we don't want these to grow unnoticed: {actual} <~ {expected}"
);
}

#[test]
fn size_of_pack_verify_data_structure() {
pub struct EntryWithDefault {
_index_entry: crate::index::Entry,
_kind: gix_object::Kind,
_object_size: u64,
_decompressed_size: u64,
_compressed_size: u64,
_header_size: u16,
_level: u16,
}

let actual = std::mem::size_of::<[Item<EntryWithDefault>; 7_500_000]>();
let expected = 840_000_000;
assert!(
size_ok(actual, expected),
"we don't want these to grow unnoticed: {actual} <~ {expected}"
);
}
}
1 change: 0 additions & 1 deletion gix-pack/src/cache/delta/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ mod tests {
}
}

// FIXME: Probably remove this pair of tests or the equivalent pair in `gix-pack/src/cache/delta/mod.rs`.
mod size {
use super::super::Item;
use gix_testtools::size_ok;
Expand Down

0 comments on commit dc0a73a

Please sign in to comment.