Skip to content

Commit

Permalink
Cover more codes and fix Clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
EFanZh committed Apr 27, 2024
1 parent 5a8483e commit 48d55ae
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/problem_0869_reordered_power_of_2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod tests {
(16, true),
(24, false),
(46, true),
(124, false),
(821, true),
(1_420, true),
(14_683, true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ impl super::Solution for Solution {

#[cfg(test)]
mod tests {
use super::Item;

#[test]
fn test_item_partial_eq() {
assert!(Item { size: 2, index: 3 } == Item { size: 2, index: 5 });
}

#[test]
fn test_solution() {
super::super::tests::run::<super::Solution>();
Expand Down
12 changes: 12 additions & 0 deletions src/problem_1857_largest_color_value_in_a_directed_graph/dfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ impl super::Solution for Solution {

#[cfg(test)]
mod tests {
#[test]
#[should_panic(expected = "internal error: entered unreachable code")]
fn test_unwrap_visited_failure_1() {
super::Solution::unwrap_visited(&super::State::NotVisited);
}

#[test]
#[should_panic(expected = "internal error: entered unreachable code")]
fn test_unwrap_visited_failure_2() {
super::Solution::unwrap_visited(&super::State::Visiting);
}

#[test]
fn test_solution() {
super::super::tests::run::<super::Solution>();
Expand Down
2 changes: 1 addition & 1 deletion xtask/src/coverage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl FromStr for OutputType {
}

impl Display for OutputType {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
f.write_str(self.value())
}
}
Expand Down
9 changes: 1 addition & 8 deletions xtask/src/tools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ mod windows;

pub struct RustVersionMeta {
pub host: String,
pub commit_hash: String,
}

pub fn find_rust_version_meta() -> RustVersionMeta {
let mut host = None;
let mut commit_hash = None;

utilities::run_command_and_stream_output(Command::new("rustc").arg("-vV"), |stdout| {
for line in BufReader::new(stdout).lines() {
Expand All @@ -22,16 +20,11 @@ pub fn find_rust_version_meta() -> RustVersionMeta {
#[allow(clippy::option_if_let_else)] // False positive.
if let Some(host_value) = line.strip_prefix("host: ") {
host = Some(host_value.to_string());
} else if let Some(commit_hash_value) = line.strip_prefix("commit-hash: ") {
commit_hash = Some(commit_hash_value.to_string());
}
}
});

RustVersionMeta {
host: host.unwrap(),
commit_hash: commit_hash.unwrap(),
}
RustVersionMeta { host: host.unwrap() }
}

pub fn find_rust_sysroot() -> PathBuf {
Expand Down

0 comments on commit 48d55ae

Please sign in to comment.