Skip to content

Commit 0302c05

Browse files
committed
chore: add copyright information
1 parent 21696b9 commit 0302c05

File tree

6 files changed

+94
-1
lines changed

6 files changed

+94
-1
lines changed

i18n/iconv.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
//
2+
// Copyright (c) 2024 Jeff Garzik
3+
//
4+
// This file is part of the posixutils-rs project covered under
5+
// the MIT License. For the full license text, please see the LICENSE
6+
// file in the root directory of this project.
7+
// SPDX-License-Identifier: MIT
8+
//
9+
110
use clap::Parser;
211
use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory};
312
use iconv_lib::{

i18n/iconv_lib/utf_32.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
//
2+
// Copyright (c) 2024 Jeff Garzik
3+
//
4+
// This file is part of the posixutils-rs project covered under
5+
// the MIT License. For the full license text, please see the LICENSE
6+
// file in the root directory of this project.
7+
// SPDX-License-Identifier: MIT
8+
//
9+
110
use byteorder::{BigEndian, ByteOrder, LittleEndian};
211

312
#[derive(Debug, Clone, Copy, PartialEq, Eq)]

i18n/iconv_lib/utf_8.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
//
2+
// Copyright (c) 2024 Jeff Garzik
3+
//
4+
// This file is part of the posixutils-rs project covered under
5+
// the MIT License. For the full license text, please see the LICENSE
6+
// file in the root directory of this project.
7+
// SPDX-License-Identifier: MIT
8+
//
9+
110
/// Convert UTF-8 to UCS-4
211
pub fn to_ucs4(input: &[u8], omit_invalid: bool, supress_error: bool) -> (u32, Vec<u32>) {
312
let mut result = Vec::new();

i18n/tests/i18n-tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
//
99

1010
mod gencat;
11+
mod iconv;

i18n/tests/iconv/mod.rs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//
2+
// Copyright (c) 2024 Jeff Garzik
3+
//
4+
// This file is part of the posixutils-rs project covered under
5+
// the MIT License. For the full license text, please see the LICENSE
6+
// file in the root directory of this project.
7+
// SPDX-License-Identifier: MIT
8+
//
9+
10+
use plib::{run_test_u8, TestPlanU8};
11+
use std::env;
12+
use std::path::PathBuf;
13+
use std::{fs::File, io::Read};
14+
15+
fn iconv_test(args: &[&str], input: Vec<u8>, expected_output: Vec<u8>, expected_error: Vec<u8>) {
16+
let str_args: Vec<String> = args.iter().map(|s| String::from(*s)).collect();
17+
run_test_u8(TestPlanU8 {
18+
cmd: String::from("iconv"),
19+
args: str_args,
20+
stdin_data: input,
21+
expected_out: expected_output,
22+
expected_err: expected_error,
23+
expected_exit_code: 0,
24+
})
25+
}
26+
27+
#[test]
28+
fn iconv_no_flag_data_input() {
29+
let input = "Hello world".as_bytes().to_vec();
30+
iconv_test(&[], input.clone(), input.clone(), Vec::new());
31+
}
32+
33+
#[test]
34+
fn iconv_utf8_to_ascii_conversion_with_c_flag() {
35+
let cargo_manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
36+
37+
let input_file = cargo_manifest_dir.join("tests/iconv/test_data_utf8");
38+
let mut input: Vec<u8> = Vec::new();
39+
File::open(&input_file)
40+
.unwrap()
41+
.read_to_end(&mut input)
42+
.unwrap();
43+
44+
let expected_output_file =
45+
cargo_manifest_dir.join("tests/iconv/test_data_utf8_to_ascii_with_c_flag");
46+
47+
let mut expected_output: Vec<u8> = Vec::new();
48+
File::open(&expected_output_file)
49+
.unwrap()
50+
.read_to_end(&mut expected_output)
51+
.unwrap();
52+
53+
iconv_test(
54+
&["-c", "-f", "UTF-8", "-t", "ASCII", "-"],
55+
input.clone(),
56+
expected_output.clone(),
57+
Vec::new(),
58+
);
59+
60+
iconv_test(
61+
&["-c", "-f", "UTF-8", "-t", "ASCII"],
62+
input,
63+
expected_output,
64+
Vec::new(),
65+
);
66+
}

i18n/tests/iconv/test_data_utf8_to_ascii

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)