-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync variable-length-quantity with problem-specifications (#1731)
Notably, this removes any tests about overflow as well as the overflow variant from the error enum in the stub. Overflow handling is a valuable thing to learn and practice, but there are other exercises which do that. So it seems unnecesary to expand the case only on the Rust track and maintain our own additional tests. This is a backwards compatible change, submissions which choose to handle overflow should still work fine.
- Loading branch information
Showing
5 changed files
with
315 additions
and
92 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
33 changes: 33 additions & 0 deletions
33
exercises/practice/variable-length-quantity/.meta/test_template.tera
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,33 @@ | ||
use variable_length_quantity as vlq; | ||
{% for test in cases %} | ||
#[test] | ||
{% if loop.index != 1 -%} | ||
#[ignore] | ||
{% endif -%} | ||
fn {{ test.description | slugify | replace(from="-", to="_") }}() { | ||
{%- if test.property == "encode" %} | ||
let input = &{{ test.input.integers | json_encode() }}; | ||
let output = vlq::{{ fn_names[0] }}(input); | ||
let expected = vec![ | ||
{%- for byte in test.expected -%} | ||
0x{{ byte | to_hex }}, | ||
{%- endfor -%} | ||
]; | ||
{%- elif test.property == "decode" %} | ||
let input = &[ | ||
{%- for byte in test.input.integers -%} | ||
0x{{ byte | to_hex }}, | ||
{%- endfor -%} | ||
]; | ||
let output = vlq::{{ fn_names[1] }}(input); | ||
let expected = {% if test.expected is object -%} | ||
Err(vlq::Error::IncompleteNumber) | ||
{%- else -%} | ||
Ok(vec!{{ test.expected | json_encode() }}) | ||
{%- endif %}; | ||
{%- else %} | ||
panic!("unknown property: {{ test.property }}"); | ||
{%- endif %} | ||
assert_eq!(output, expected); | ||
} | ||
{% endfor -%} |
91 changes: 88 additions & 3 deletions
91
exercises/practice/variable-length-quantity/.meta/tests.toml
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 |
---|---|---|
@@ -1,3 +1,88 @@ | ||
# This is an auto-generated file. Regular comments will be removed when this | ||
# file is regenerated. Regenerating will not touch any manually added keys, | ||
# so comments can be added in a "comment" key. | ||
# This is an auto-generated file. | ||
# | ||
# Regenerating this file via `configlet sync` will: | ||
# - Recreate every `description` key/value pair | ||
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications | ||
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) | ||
# - Preserve any other key/value pair | ||
# | ||
# As user-added comments (using the # character) will be removed when this file | ||
# is regenerated, comments can be added via a `comment` key. | ||
|
||
[35c9db2e-f781-4c52-b73b-8e76427defd0] | ||
description = "Encode a series of integers, producing a series of bytes. -> zero" | ||
|
||
[be44d299-a151-4604-a10e-d4b867f41540] | ||
description = "Encode a series of integers, producing a series of bytes. -> arbitrary single byte" | ||
|
||
[ea399615-d274-4af6-bbef-a1c23c9e1346] | ||
description = "Encode a series of integers, producing a series of bytes. -> largest single byte" | ||
|
||
[77b07086-bd3f-4882-8476-8dcafee79b1c] | ||
description = "Encode a series of integers, producing a series of bytes. -> smallest double byte" | ||
|
||
[63955a49-2690-4e22-a556-0040648d6b2d] | ||
description = "Encode a series of integers, producing a series of bytes. -> arbitrary double byte" | ||
|
||
[29da7031-0067-43d3-83a7-4f14b29ed97a] | ||
description = "Encode a series of integers, producing a series of bytes. -> largest double byte" | ||
|
||
[3345d2e3-79a9-4999-869e-d4856e3a8e01] | ||
description = "Encode a series of integers, producing a series of bytes. -> smallest triple byte" | ||
|
||
[5df0bc2d-2a57-4300-a653-a75ee4bd0bee] | ||
description = "Encode a series of integers, producing a series of bytes. -> arbitrary triple byte" | ||
|
||
[f51d8539-312d-4db1-945c-250222c6aa22] | ||
description = "Encode a series of integers, producing a series of bytes. -> largest triple byte" | ||
|
||
[da78228b-544f-47b7-8bfe-d16b35bbe570] | ||
description = "Encode a series of integers, producing a series of bytes. -> smallest quadruple byte" | ||
|
||
[11ed3469-a933-46f1-996f-2231e05d7bb6] | ||
description = "Encode a series of integers, producing a series of bytes. -> arbitrary quadruple byte" | ||
|
||
[d5f3f3c3-e0f1-4e7f-aad0-18a44f223d1c] | ||
description = "Encode a series of integers, producing a series of bytes. -> largest quadruple byte" | ||
|
||
[91a18b33-24e7-4bfb-bbca-eca78ff4fc47] | ||
description = "Encode a series of integers, producing a series of bytes. -> smallest quintuple byte" | ||
|
||
[5f34ff12-2952-4669-95fe-2d11b693d331] | ||
description = "Encode a series of integers, producing a series of bytes. -> arbitrary quintuple byte" | ||
|
||
[7489694b-88c3-4078-9864-6fe802411009] | ||
description = "Encode a series of integers, producing a series of bytes. -> maximum 32-bit integer input" | ||
|
||
[f9b91821-cada-4a73-9421-3c81d6ff3661] | ||
description = "Encode a series of integers, producing a series of bytes. -> two single-byte values" | ||
|
||
[68694449-25d2-4974-ba75-fa7bb36db212] | ||
description = "Encode a series of integers, producing a series of bytes. -> two multi-byte values" | ||
|
||
[51a06b5c-de1b-4487-9a50-9db1b8930d85] | ||
description = "Encode a series of integers, producing a series of bytes. -> many multi-byte values" | ||
|
||
[baa73993-4514-4915-bac0-f7f585e0e59a] | ||
description = "Decode a series of bytes, producing a series of integers. -> one byte" | ||
|
||
[72e94369-29f9-46f2-8c95-6c5b7a595aee] | ||
description = "Decode a series of bytes, producing a series of integers. -> two bytes" | ||
|
||
[df5a44c4-56f7-464e-a997-1db5f63ce691] | ||
description = "Decode a series of bytes, producing a series of integers. -> three bytes" | ||
|
||
[1bb58684-f2dc-450a-8406-1f3452aa1947] | ||
description = "Decode a series of bytes, producing a series of integers. -> four bytes" | ||
|
||
[cecd5233-49f1-4dd1-a41a-9840a40f09cd] | ||
description = "Decode a series of bytes, producing a series of integers. -> maximum 32-bit integer" | ||
|
||
[e7d74ba3-8b8e-4bcb-858d-d08302e15695] | ||
description = "Decode a series of bytes, producing a series of integers. -> incomplete sequence causes error" | ||
|
||
[aa378291-9043-4724-bc53-aca1b4a3fcb6] | ||
description = "Decode a series of bytes, producing a series of integers. -> incomplete sequence causes error, even if value is zero" | ||
|
||
[a91e6f5a-c64a-48e3-8a75-ce1a81e0ebee] | ||
description = "Decode a series of bytes, producing a series of integers. -> multiple values" |
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
Oops, something went wrong.