Skip to content

Commit d62bdfa

Browse files
committed
test: oid length sanity check
1 parent a9ba7a0 commit d62bdfa

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/oid.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,18 @@ impl AsRef<[u8]> for Oid {
387387
}
388388
}
389389

390+
// Sanity-check libgit2's OID size constants to keep the docs and the
391+
// public API surface honest. If any of these break, the doc comments on
392+
// `Oid::as_bytes` / `Oid::raw_bytes` need to be revisited.
393+
#[cfg(not(feature = "unstable-sha256"))]
394+
const _: () = assert!(raw::GIT_OID_MAX_SIZE == 20);
395+
#[cfg(feature = "unstable-sha256")]
396+
const _: () = {
397+
assert!(raw::GIT_OID_SHA1_SIZE == 20);
398+
assert!(raw::GIT_OID_SHA256_SIZE == 32);
399+
assert!(raw::GIT_OID_MAX_SIZE == 32);
400+
};
401+
390402
#[cfg(test)]
391403
mod tests {
392404
use std::fs::File;

0 commit comments

Comments
 (0)