-
Notifications
You must be signed in to change notification settings - Fork 543
Expand file tree
/
Copy pathtest_template.tera
More file actions
31 lines (30 loc) · 922 Bytes
/
test_template.tera
File metadata and controls
31 lines (30 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{% macro bucket(label) -%}
{% if label == 'one' -%}
Bucket::One
{%- else -%}
Bucket::Two
{%- endif %}
{%- endmacro bucket -%}
use two_bucket::{Bucket, BucketStats};
{% for test in cases %}
#[test]
{% if loop.index != 1 -%}
#[ignore]
{% endif -%}
fn {{ test.description | slugify | replace(from="-", to="_") }}() {
let output = {{ crate_name }}::{{ fn_names[0] }}(
{{ test.input.bucketOne }}, {{ test.input.bucketTwo }}, {{ test.input.goal }},
&{{ self::bucket(label=test.input.startBucket) }},
);
let expected = {% if 'error' in test.expected -%}
None
{%- else -%}
Some(BucketStats {
moves: {{ test.expected.moves }},
goal_bucket: {{ self::bucket(label=test.expected.goalBucket) }},
other_bucket: {{ test.expected.otherBucket }},
})
{%- endif %};
assert_eq!(output, expected);
}
{% endfor -%}