Skip to content

Commit

Permalink
Add compile test for odd capacity BufEncoder
Browse files Browse the repository at this point in the history
Add two compile test crates that are identical except for the capacity
of `BufEncoder`.  Odd capacity in `fail/` that must not compile and even
capacity in `pass/` that must compile.
  • Loading branch information
jamillambert committed Feb 25, 2025
1 parent c7eb39e commit 82918e6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/compile-tests/fail/odd-capacity/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "odd-capacity"
version = "0.1.0"
edition = "2021"
rust-version = "1.63.0"

[workspace]

[dependencies]
hex = { package = "hex-conservative", path = "../../../../" }
6 changes: 6 additions & 0 deletions tests/compile-tests/fail/odd-capacity/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use hex::buf_encoder::BufEncoder;
use hex::Case;

// This should fail to compile because the capacity size is odd.
// The only difference to `even-capacity` is the capacity size.
fn main() { let _encoder = BufEncoder::<3>::new(Case::Lower); }
10 changes: 10 additions & 0 deletions tests/compile-tests/pass/even-capacity/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "even-capacity"
version = "0.1.0"
edition = "2021"
rust-version = "1.63.0"

[workspace]

[dependencies]
hex = { package = "hex-conservative", path = "../../../../" }
5 changes: 5 additions & 0 deletions tests/compile-tests/pass/even-capacity/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use hex::buf_encoder::BufEncoder;
use hex::Case;

// This should compile, ensuring that the compile error in odd-capacity is from the odd capacity.
fn main() { let _encoder = BufEncoder::<4>::new(Case::Lower); }

0 comments on commit 82918e6

Please sign in to comment.