-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test file that has an odd capacity BufEncoder. Add a test file that has an even capacity BufEncoder. Add a CI check that the even capacity compiles and the odd capacity does not.
- Loading branch information
1 parent
a57caeb
commit 5a70ac4
Showing
7 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
even_capacity() { | ||
cd even-capacity | ||
if cargo run > /dev/null 2>&1; then | ||
cd .. | ||
return 0 | ||
else | ||
cd .. | ||
return 1 | ||
fi | ||
} | ||
|
||
odd_capacity() { | ||
cd odd-capacity | ||
if cargo run > /dev/null 2>&1; then | ||
cd .. | ||
return 0 | ||
else | ||
cd .. | ||
return 1 | ||
fi | ||
} | ||
|
||
# Check that an even capacity BufEncoder compiles and an odd BufEncoder capacity fails to compile | ||
cd tests/compiletests | ||
if ! even_capacity; then | ||
echo "even-capacity BufEncoder failed to compile" | ||
exit 1 | ||
elif odd_capacity; then | ||
echo "odd-capacity BufEncoder compiled when it should not have" | ||
exit 1 | ||
else | ||
echo "BufEncoder capacity compile tests passed" | ||
exit 0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "../../../" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "../../../" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); } |