Skip to content

Commit 60d113b

Browse files
committed
Consider approx in idigest
1 parent 2dcdad4 commit 60d113b

4 files changed

Lines changed: 55 additions & 17 deletions

File tree

src/commands/check.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::commands::arguments::CommandCheckArgs;
2-
use pace26checker::digest::algo::{digest_instance, digest_solution};
2+
use pace26checker::digest::algo::{digest_instance_with_approx, digest_solution};
33
use pace26checker::{checks::checker::*, io::forest_dot_writer::ForestDotWriter};
44
use pace26remote::job_description::JobDescription;
55
use pace26remote::upload::{Upload, UploadError};
@@ -47,7 +47,9 @@ pub async fn command_check(args: &CommandCheckArgs) -> Result<(), CommandCheckEr
4747
.iter()
4848
.map(|(_, t)| t.clone())
4949
.collect::<Vec<_>>();
50-
let idigest = digest_instance(trees, instance.num_leaves);
50+
51+
let idigest =
52+
digest_instance_with_approx(trees, instance.num_leaves, instance.approx());
5153

5254
let trees = solution
5355
.trees()
@@ -91,7 +93,8 @@ pub async fn command_check(args: &CommandCheckArgs) -> Result<(), CommandCheckEr
9193
.iter()
9294
.map(|(_, t)| t.clone())
9395
.collect::<Vec<_>>();
94-
let idigest = digest_instance(trees, instance.num_leaves);
96+
let idigest =
97+
digest_instance_with_approx(trees, instance.num_leaves, instance.approx());
9598

9699
println!("#s idigest \"{idigest}\"");
97100
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#p 2 20
2+
#a 1.2 1337
3+
#s name "Test 01"
4+
#s description "This is a test instance"
5+
(((8,(5,(1,19))),17),(((10,16),((2,11),14)),(20,(9,((3,((4,(6,13)),(12,7))),(18,15))))));
6+
(((((8,10),(2,11)),(16,4)),((3,(12,(13,19))),((6,(9,18)),(14,20)))),(((1,7),(15,5)),17));
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(((5,1),17),((10,16),(20,(9,18))));
2+
6;
3+
4;
4+
7;
5+
19;
6+
15;
7+
8;
8+
(2,11);
9+
(3,(13,12));
10+
14;

tests/command_check.rs

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,7 @@ fn invalid_cases() {
150150
}
151151
}
152152

153-
#[test]
154-
fn digest() {
155-
let instance_path = testcase_dir()
156-
.join("valid_solutions")
157-
.join("score10_n07l_lkc.in");
158-
let solution_path = testcase_dir()
159-
.join("valid_solutions")
160-
.join("score10_n07l_lkc.out");
161-
162-
const IDIGEST: &str = "015e2a313c3470afe151d1ac2a20b0f3";
163-
const SDIGEST: &str = "000a5d234052384b8fd9ea7bac0d3c17";
164-
153+
fn test_digest(instance_path: &Path, idigest: &str, solution_path: &Path, sdigest: &str) {
165154
for with_solution in [false, true] {
166155
let mut args = vec![
167156
String::from("check"),
@@ -178,10 +167,40 @@ fn digest() {
178167
assert!(output.status.success());
179168
let stdout = String::from_utf8(output.stdout).unwrap();
180169

181-
assert!(stdout.contains(format!("#s idigest \"{IDIGEST}\"").as_str()));
170+
assert!(stdout.contains(format!("#s idigest \"{idigest}\"").as_str()));
182171

183172
if with_solution {
184-
assert!(stdout.contains(format!("#s sdigest \"{SDIGEST}\"").as_str()));
173+
assert!(stdout.contains(format!("#s sdigest \"{sdigest}\"").as_str()));
185174
}
186175
}
187176
}
177+
178+
#[test]
179+
fn digest() {
180+
let instance_path = testcase_dir()
181+
.join("valid_solutions")
182+
.join("score10_n07l_lkc.in");
183+
let solution_path = testcase_dir()
184+
.join("valid_solutions")
185+
.join("score10_n07l_lkc.out");
186+
187+
const IDIGEST: &str = "015e2a313c3470afe151d1ac2a20b0f3";
188+
const SDIGEST: &str = "000a5d234052384b8fd9ea7bac0d3c17";
189+
190+
test_digest(&instance_path, IDIGEST, &solution_path, SDIGEST);
191+
}
192+
193+
#[test]
194+
fn digest_with_approx() {
195+
let instance_path = testcase_dir()
196+
.join("valid_solutions")
197+
.join("score10_n07l_lkc_with_approx.in");
198+
let solution_path = testcase_dir()
199+
.join("valid_solutions")
200+
.join("score10_n07l_lkc.out");
201+
202+
const IDIGEST: &str = "014a7e1e21661a4913f46daa871f53a3";
203+
const SDIGEST: &str = "000a5d234052384b8fd9ea7bac0d3c17";
204+
205+
test_digest(&instance_path, IDIGEST, &solution_path, SDIGEST);
206+
}

0 commit comments

Comments
 (0)