open_pql/functions/
min_hi_rating.rs1use super::*;
2#[pqlfn(arg, rtn, eval)]
3pub fn min_hi_rating(
4 hand: &Hand,
5 street: PQLStreet,
6 rating: PQLHiRating,
7 (game, board): (PQLGame, Board),
8) -> PQLBoolean {
9 hi_rating(hand, street, (game, board)) >= rating
10}
11
12#[cfg(test)]
13mod tests {
14 use super::*;
15 use crate::*;
16
17 #[quickcheck]
18 fn test_min_hi_rating(hbg: HandBoardGame) -> TestResult {
19 let HandBoardGame {
20 street,
21 game,
22 hand,
23 board,
24 ..
25 } = hbg;
26
27 let rating = hi_rating(&hand, street, (game, board));
28
29 let add1 = PQLHiRating::new(rating.to_i16() + 1);
30 let sub1 = PQLHiRating::new(rating.to_i16() - 1);
31
32 TestResult::from_bool(
33 !min_hi_rating(&hand, street, add1, (game, board))
34 && min_hi_rating(&hand, street, rating, (game, board))
35 && min_hi_rating(&hand, street, sub1, (game, board)),
36 )
37 }
38}