Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cspuz_solver_backend/src/puzzle/fillomino.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ pub fn solve(url: &str) -> Result<Board, &'static str> {
mod tests {
use super::solve;
use crate::board::*;
use crate::compare_board;
use crate::compare_board_and_check_no_solution_case;
use crate::uniqueness::Uniqueness;

#[test]
#[rustfmt::skip]
fn test_solve() {
compare_board!(
compare_board_and_check_no_solution_case!(
solve("https://puzz.link/p?fillomino/5/5/g1k34g2h5h4n"),
Board {
kind: BoardKind::OuterGrid,
Expand Down
30 changes: 29 additions & 1 deletion cspuz_solver_backend/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ macro_rules! compare_board_and_check_no_solution_case {
}
let actual = actual.unwrap();
let expected_no_solution = $crate::testing::expectation_no_solution(&$expected);
assert_eq!(actual, expected_no_solution);
if actual != expected_no_solution {
let expected_no_solution_wall_color_changed =
$crate::testing::expectation_no_solution_wall_color_changed(&$expected);
assert_eq!(actual, expected_no_solution_wall_color_changed);
}
};
}

Expand Down Expand Up @@ -174,6 +178,30 @@ pub fn expectation_no_solution(board: &Board) -> Board {
}
}

pub fn expectation_no_solution_wall_color_changed(board: &Board) -> Board {
let mut new_data = vec![];
for item in &board.data {
if item.color != "green" {
new_data.push(item.clone());
} else {
if item.kind == ItemKind::BoldWall {
let mut new_item = item.clone();
new_item.kind = ItemKind::Wall;
new_item.color = "#cccccc";
new_data.push(new_item);
}
}
}

Board {
kind: board.kind,
height: board.height,
width: board.width,
data: new_data,
uniqueness: Uniqueness::NoAnswer,
}
}

fn add_indent(s: &str, indent: &str) -> String {
s.lines()
.map(|line| format!("{}{}", indent, line))
Expand Down