-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
108 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use bio_seq::prelude::*; | ||
|
||
#[derive(Codec)] | ||
struct NotEnum { | ||
a: (), | ||
c: (), | ||
g: (), | ||
t: (), | ||
} | ||
|
||
#[derive(Codec)] | ||
enum NoDiscriminants { | ||
A, | ||
C, | ||
G, | ||
T, | ||
} | ||
|
||
#[derive(Codec, PartialEq, Debug, Hash)] | ||
#[bits(2)] | ||
enum BadWidth { | ||
A = 0b000, | ||
C = 0b001, | ||
G = 0b010, | ||
T = 0b100, | ||
X = 0b011, | ||
} | ||
|
||
#[derive(Codec, PartialEq, Debug, Hash, Eq, Copy, Clone)] | ||
#[bits(3)] | ||
enum BadDiscriminant { | ||
A = 0b000, | ||
C = 3, | ||
G = 0b010, | ||
T = 0x04, | ||
X = 1.0, | ||
} | ||
|
||
// Test whether codec is #[repr(u8)] | ||
/* | ||
#[derive(Codec, Eq, Debug, Hash, PartialEq, Copy, Clone)] | ||
enum NoRepr { | ||
A = 0b11, | ||
C = 0b01, | ||
G = 0b00, | ||
T = 0b10, | ||
} | ||
*/ | ||
|
||
fn main() { | ||
let _c = NotEnum { | ||
a: (), | ||
c: (), | ||
g: (), | ||
t: (), | ||
}; | ||
} |
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,34 @@ | ||
error: Codec can only be derived for enums | ||
--> tests/fail/invalid_codec.rs:4:1 | ||
| | ||
4 | / struct NotEnum { | ||
5 | | a: (), | ||
6 | | c: (), | ||
7 | | g: (), | ||
8 | | t: (), | ||
9 | | } | ||
| |_^ | ||
|
||
error: Codec derivations require discriminants | ||
--> tests/fail/invalid_codec.rs:13:5 | ||
| | ||
13 | A, | ||
| ^ | ||
|
||
error: Bit width is not large enough encode all variants (min: 3) | ||
--> tests/fail/invalid_codec.rs:20:1 | ||
| | ||
20 | #[bits(2)] | ||
| ^^^^^^^^^^ | ||
|
||
error: Codec derivations require byte or integer discriminants | ||
--> tests/fail/invalid_codec.rs:36:5 | ||
| | ||
36 | X = 1.0, | ||
| ^ | ||
|
||
error[E0308]: mismatched types | ||
--> tests/fail/invalid_codec.rs:36:9 | ||
| | ||
36 | X = 1.0, | ||
| ^^^ expected `isize`, found floating-point number |
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 bio_seq::prelude::*; | ||
|
||
fn main() { | ||
let _seq = iupac!("ACNSWGT🤬"); | ||
let _seq = dna!("ACG🫣T"); | ||
} |
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,11 @@ | ||
error: Non-ASCII characters in IUPAC string | ||
--> tests/fail/non_ascii.rs:4:23 | ||
| | ||
4 | let _seq = iupac!("ACNSWGT🤬"); | ||
| ^^^^^^^^^^^ | ||
|
||
error: Non-ASCII characters in DNA string | ||
--> tests/fail/non_ascii.rs:5:21 | ||
| | ||
5 | let _seq = dna!("ACG🫣T"); | ||
| ^^^^^^^^ |