Skip to content

Add property tests#4

Draft
aszlig wants to merge 4 commits intoIngaFeick:mainfrom
aszlig:proptests
Draft

Add property tests#4
aszlig wants to merge 4 commits intoIngaFeick:mainfrom
aszlig:proptests

Conversation

@aszlig
Copy link
Copy Markdown
Contributor

@aszlig aszlig commented Jan 4, 2022

This adds a few tests based on some assumptions based on properties of roman numerals, for example that in subtractive notation we should never have more than three of the same consecutive characters.

Right now these tests are very basic because in order to get more exhaustive we need to have access to some kind of mapping between roman digits and its values. Our current tests only cover properties that hold true without knowing more intrinsic details.

At the moment, the encode_decode_symmetry test fails with:

thread 'tests::encode_decode_symmetry' panicked at 'Test failed: called `Result::unwrap()` on an `Err` value:
    "Unknown grapheme M\u{33f}"; minimal failing input: arabic = 37888189900000000

@aszlig aszlig force-pushed the proptests branch 2 times, most recently from 4e3e1a5 to 80a188c Compare January 4, 2022 06:08
aszlig added 4 commits January 4, 2022 20:57
First of all, the return type of the function is Result, which is not
needed because we can *always* generate a roman number from any u64.

Second, the input is allowed to be zero and since this is not
representable, the implementation so far has returned an empty string.

Given that the return value is Result and the input can be zero, one
could possibly assume that whenever we pass a zero we get an Err, which
is not the case.

All this is really not necessary since we now use the NonZeroU64 type
which removes possible failures by design in our function.

Signed-off-by: aszlig <aszlig@nix.build>
This is mainly to be in par with the changes to arabic2vinculum, which
has changed its argument from u64 to NonZeroU64. Since vinculum2arabic
is the inverse of the former, we should also reflect that in returning
the same type.

Signed-off-by: aszlig <aszlig@nix.build>
This adds a few tests based on some assumptions based on properties of
reman numerals, for example that in subtractive notation we should never
have more than three of the same consecutive characters.

Right now these tests are very basic because in order to get more
exhaustive we need to have access to some kind of mapping between roman
digits and its values. Our current tests only cover properties that hold
true without knowing more intrinsic details.

Signed-off-by: aszlig <aszlig@nix.build>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant