Skip to content

Commit 0fed272

Browse files
authored
Merge pull request #114 from kornelski/cfgtest
Tests
2 parents ca7487a + 72efb9a commit 0fed272

File tree

8 files changed

+36
-26
lines changed

8 files changed

+36
-26
lines changed

src/simd_funcs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ cfg_if! {
349349
}
350350

351351
#[cfg(test)]
352+
#[cfg(feature = "alloc")]
352353
mod tests {
353354
use super::*;
354355
use alloc::vec::Vec;

tests/test_data.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#[cfg(feature = "alloc")]
2+
mod test_data {
3+
mod big5;
4+
mod euc_jp;
5+
mod euc_kr;
6+
mod gb18030;
7+
mod iso_2022_jp;
8+
mod shift_jis;
9+
}

tests/big5.rs renamed to tests/test_data/big5.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use encoding_rs::*;
33
#[test]
44
#[cfg_attr(miri, ignore)] // Miri is too slow
55
fn test_big5_decode_all() {
6-
let input = include_bytes!("test_data/big5_in.txt");
7-
let expectation = include_str!("test_data/big5_in_ref.txt");
6+
let input = include_bytes!("big5_in.txt");
7+
let expectation = include_str!("big5_in_ref.txt");
88
let (cow, had_errors) = BIG5.decode_without_bom_handling(input);
99
assert!(had_errors, "Should have had errors.");
1010
assert_eq!(&cow[..], expectation);
@@ -13,8 +13,8 @@ fn test_big5_decode_all() {
1313
#[test]
1414
#[cfg_attr(miri, ignore)] // Miri is too slow
1515
fn test_big5_encode_all() {
16-
let input = include_str!("test_data/big5_out.txt");
17-
let expectation = include_bytes!("test_data/big5_out_ref.txt");
16+
let input = include_str!("big5_out.txt");
17+
let expectation = include_bytes!("big5_out_ref.txt");
1818
let (cow, encoding, had_errors) = BIG5.encode(input);
1919
assert!(!had_errors, "Should not have had errors.");
2020
assert_eq!(encoding, BIG5);

tests/euc_jp.rs renamed to tests/test_data/euc_jp.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use encoding_rs::*;
33
#[test]
44
#[cfg_attr(miri, ignore)] // Miri is too slow
55
fn test_jis0208_decode_all() {
6-
let input = include_bytes!("test_data/jis0208_in.txt");
7-
let expectation = include_str!("test_data/jis0208_in_ref.txt");
6+
let input = include_bytes!("jis0208_in.txt");
7+
let expectation = include_str!("jis0208_in_ref.txt");
88
let (cow, had_errors) = EUC_JP.decode_without_bom_handling(input);
99
assert!(had_errors, "Should have had errors.");
1010
assert_eq!(&cow[..], expectation);
@@ -13,8 +13,8 @@ fn test_jis0208_decode_all() {
1313
#[test]
1414
#[cfg_attr(miri, ignore)] // Miri is too slow
1515
fn test_jis0208_encode_all() {
16-
let input = include_str!("test_data/jis0208_out.txt");
17-
let expectation = include_bytes!("test_data/jis0208_out_ref.txt");
16+
let input = include_str!("jis0208_out.txt");
17+
let expectation = include_bytes!("jis0208_out_ref.txt");
1818
let (cow, encoding, had_errors) = EUC_JP.encode(input);
1919
assert!(!had_errors, "Should not have had errors.");
2020
assert_eq!(encoding, EUC_JP);
@@ -24,8 +24,8 @@ fn test_jis0208_encode_all() {
2424
#[test]
2525
#[cfg_attr(miri, ignore)] // Miri is too slow
2626
fn test_jis0212_decode_all() {
27-
let input = include_bytes!("test_data/jis0212_in.txt");
28-
let expectation = include_str!("test_data/jis0212_in_ref.txt");
27+
let input = include_bytes!("jis0212_in.txt");
28+
let expectation = include_str!("jis0212_in_ref.txt");
2929
let (cow, had_errors) = EUC_JP.decode_without_bom_handling(input);
3030
assert!(had_errors, "Should have had errors.");
3131
assert_eq!(&cow[..], expectation);

tests/euc_kr.rs renamed to tests/test_data/euc_kr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use encoding_rs::*;
33
#[test]
44
#[cfg_attr(miri, ignore)] // Miri is too slow
55
fn test_euc_kr_decode_all() {
6-
let input = include_bytes!("test_data/euc_kr_in.txt");
7-
let expectation = include_str!("test_data/euc_kr_in_ref.txt");
6+
let input = include_bytes!("euc_kr_in.txt");
7+
let expectation = include_str!("euc_kr_in_ref.txt");
88
let (cow, had_errors) = EUC_KR.decode_without_bom_handling(input);
99
assert!(had_errors, "Should have had errors.");
1010
assert_eq!(&cow[..], expectation);
@@ -13,8 +13,8 @@ fn test_euc_kr_decode_all() {
1313
#[test]
1414
#[cfg_attr(miri, ignore)] // Miri is too slow
1515
fn test_euc_kr_encode_all() {
16-
let input = include_str!("test_data/euc_kr_out.txt");
17-
let expectation = include_bytes!("test_data/euc_kr_out_ref.txt");
16+
let input = include_str!("euc_kr_out.txt");
17+
let expectation = include_bytes!("euc_kr_out_ref.txt");
1818
let (cow, encoding, had_errors) = EUC_KR.encode(input);
1919
assert!(!had_errors, "Should not have had errors.");
2020
assert_eq!(encoding, EUC_KR);

tests/gb18030.rs renamed to tests/test_data/gb18030.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use encoding_rs::*;
33
#[test]
44
#[cfg_attr(miri, ignore)] // Miri is too slow
55
fn test_gb18030_decode_all() {
6-
let input = include_bytes!("test_data/gb18030_in.txt");
7-
let expectation = include_str!("test_data/gb18030_in_ref.txt");
6+
let input = include_bytes!("gb18030_in.txt");
7+
let expectation = include_str!("gb18030_in_ref.txt");
88
let (cow, had_errors) = GB18030.decode_without_bom_handling(input);
99
assert!(!had_errors, "Should not have had errors.");
1010
assert_eq!(&cow[..], expectation);
@@ -13,8 +13,8 @@ fn test_gb18030_decode_all() {
1313
#[test]
1414
#[cfg_attr(miri, ignore)] // Miri is too slow
1515
fn test_gb18030_encode_all() {
16-
let input = include_str!("test_data/gb18030_out.txt");
17-
let expectation = include_bytes!("test_data/gb18030_out_ref.txt");
16+
let input = include_str!("gb18030_out.txt");
17+
let expectation = include_bytes!("gb18030_out_ref.txt");
1818
let (cow, encoding, had_errors) = GB18030.encode(input);
1919
assert!(!had_errors, "Should not have had errors.");
2020
assert_eq!(encoding, GB18030);

tests/iso_2022_jp.rs renamed to tests/test_data/iso_2022_jp.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use encoding_rs::*;
33
#[test]
44
#[cfg_attr(miri, ignore)] // Miri is too slow
55
fn test_iso_2022_jp_decode_all() {
6-
let input = include_bytes!("test_data/iso_2022_jp_in.txt");
7-
let expectation = include_str!("test_data/iso_2022_jp_in_ref.txt");
6+
let input = include_bytes!("iso_2022_jp_in.txt");
7+
let expectation = include_str!("iso_2022_jp_in_ref.txt");
88
let (cow, had_errors) = ISO_2022_JP.decode_without_bom_handling(input);
99
assert!(had_errors, "Should have had errors.");
1010
assert_eq!(&cow[..], expectation);
@@ -13,8 +13,8 @@ fn test_iso_2022_jp_decode_all() {
1313
#[test]
1414
#[cfg_attr(miri, ignore)] // Miri is too slow
1515
fn test_iso_2022_jp_encode_all() {
16-
let input = include_str!("test_data/iso_2022_jp_out.txt");
17-
let expectation = include_bytes!("test_data/iso_2022_jp_out_ref.txt");
16+
let input = include_str!("iso_2022_jp_out.txt");
17+
let expectation = include_bytes!("iso_2022_jp_out_ref.txt");
1818
let (cow, encoding, had_errors) = ISO_2022_JP.encode(input);
1919
assert!(!had_errors, "Should not have had errors.");
2020
assert_eq!(encoding, ISO_2022_JP);

tests/shift_jis.rs renamed to tests/test_data/shift_jis.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use encoding_rs::*;
33
#[test]
44
#[cfg_attr(miri, ignore)] // Miri is too slow
55
fn test_shift_jis_decode_all() {
6-
let input = include_bytes!("test_data/shift_jis_in.txt");
7-
let expectation = include_str!("test_data/shift_jis_in_ref.txt");
6+
let input = include_bytes!("shift_jis_in.txt");
7+
let expectation = include_str!("shift_jis_in_ref.txt");
88
let (cow, had_errors) = SHIFT_JIS.decode_without_bom_handling(input);
99
assert!(had_errors, "Should have had errors.");
1010
assert_eq!(&cow[..], expectation);
@@ -13,8 +13,8 @@ fn test_shift_jis_decode_all() {
1313
#[test]
1414
#[cfg_attr(miri, ignore)] // Miri is too slow
1515
fn test_shift_jis_encode_all() {
16-
let input = include_str!("test_data/shift_jis_out.txt");
17-
let expectation = include_bytes!("test_data/shift_jis_out_ref.txt");
16+
let input = include_str!("shift_jis_out.txt");
17+
let expectation = include_bytes!("shift_jis_out_ref.txt");
1818
let (cow, encoding, had_errors) = SHIFT_JIS.encode(input);
1919
assert!(!had_errors, "Should not have had errors.");
2020
assert_eq!(encoding, SHIFT_JIS);

0 commit comments

Comments
 (0)