Skip to content

Commit

Permalink
[Enhancement] Add Further Test Case for PathBufLike IO (#71)
Browse files Browse the repository at this point in the history
* Added ::= tests for PathBufLikeTruncation

* Create summary of recent changes

---------

Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
kevinmatthes and github-actions[bot] authored Jan 25, 2024
1 parent ae6c5bc commit d766a31
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(
references: {},
changes: {
"Added": [
"tests for PathBufLikeTruncation",
],
},
)
50 changes: 50 additions & 0 deletions tests/writing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,56 @@
| |
\******************************************************************************/

mod path_buf_like_io {
use aeruginous_io::{PathBufLikeReader, PathBufLikeTruncation};

#[test]
fn asset_manipulation_truncate() {
let f = "path_buf_like_io_asset_manipulation_truncate.txt";

assert!("tests/assets/GPL-3.0.rs"
.read_silently()
.map(|s| {
s.lines()
.map(str::trim_start)
.filter(|l| (l.starts_with("///")))
.map(|l| {
if l.len() > 3 {
l.split_at(4).1.trim_end().to_string() + "\n"
} else {
"\n".to_string()
}
})
.collect::<String>()
})
.unwrap()
.truncate_silently(f)
.is_ok());

assert_eq!(
f.read_silently().unwrap(),
"\
Copyright (C) 2024 Kevin Matthes
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"
);

std::fs::remove_file(f).unwrap();
}
}

mod path_buf_like_truncation {
use aeruginous_io::{PathBufLikeReader, PathBufLikeTruncation};

Expand Down

0 comments on commit d766a31

Please sign in to comment.