-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
96 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use allyourbase as ayb; | ||
|
||
{% for test in cases %} | ||
#[test] | ||
#[ignore] | ||
fn {{ test.description | make_test_ident }}() { | ||
let input_base = {{ test.input.inputBase }}; | ||
let input_digits = &{{ test.input.digits | json_encode() }}; | ||
let output_base = {{ test.input.outputBase }}; | ||
{%- if not test.expected is object %} | ||
let output_digits = vec!{{ test.expected | json_encode() }}; | ||
{%- endif %} | ||
assert_eq!( | ||
ayb::convert(input_digits, input_base, output_base), | ||
{%- if not test.expected is object %} | ||
Ok(output_digits) | ||
{%- elif test.expected.error == "input base must be >= 2" %} | ||
Err(ayb::Error::InvalidInputBase) | ||
{%- elif test.expected.error == "all digits must satisfy 0 <= d < input base" %} | ||
Err(ayb::Error::InvalidDigit(2)) | ||
{%- elif test.expected.error == "output base must be >= 2" %} | ||
Err(ayb::Error::InvalidOutputBase) | ||
{%- endif %} | ||
); | ||
} | ||
{% endfor -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters