Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor encoding tests #11

Merged
merged 3 commits into from
Jul 30, 2020
Merged

refactor encoding tests #11

merged 3 commits into from
Jul 30, 2020

Conversation

japaric
Copy link
Member

@japaric japaric commented Jul 30, 2020

to use the mocked interner
see comments in tests/encode.rs for details
the tests that were in /src/tests.rs have been moved into tests/encode.rs

to use the mocked interner
see comments in `tests/encode.rs` for details
the tests that were in `/src/tests.rs` have been moved into `tests/encode.rs`
tests/encode.rs Outdated
// CFI = Check Format Implementation
fn cfi(val: impl Format, bytes: &[u8]) {
let mut f = Formatter::new();
let index = fetch_string_index();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering if not implicitly checking the index inside cfi may make things easier to read.
instead of that index would need to be included in the bytes argument
1/3

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reading the tests I think I agree that this would be better

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I'll change this later

tests/encode.rs Outdated
cfi(
X { y: 1, z: 2 },
&[
1, // x
Copy link
Member Author

@japaric japaric Jul 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one would change for example and require an index at the start so it would look like this:

     cfi(
         X { y: 1, z: 2 },
         &[
+            index, // "X { y: {{:u8}}, z: {{:u16}} }"
             1, // x
             2, // y.low
             0, // y.high
         ],
     )

2/3

tests/encode.rs Outdated

#[test]
fn format_primitives() {
cfi(42u8, &[42]);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these tests would become way longer with that change though 3/3

@japaric
Copy link
Member Author

japaric commented Jul 30, 2020

Updated with explicit index in the expected bytes argument.

@japaric japaric merged commit 2bc956f into main Jul 30, 2020
@Lotterleben Lotterleben deleted the encoder-tests branch December 1, 2020 16:00
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.

2 participants