-
Notifications
You must be signed in to change notification settings - Fork 445
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
[FEATURE] Create unit test for rust code #1615
[FEATURE] Create unit test for rust code #1615
Conversation
ab89a54
to
fea9774
Compare
The decoder moulde's unit test done @PunitLodha |
63388bb
to
657cf3b
Compare
@IshanGrover2004 Can you also add a github CI check for running the unit tests |
Sure @PunitLodha |
This comment was marked as outdated.
This comment was marked as outdated.
2b2eb7a
to
17355f2
Compare
@PunitLodha @cfsmp3 You can proceed for merging. I have added CI + all modules unit test cases |
decoder.is_header_parsed = true; | ||
decoder.is_active = true; | ||
decoder.report_enabled = true; | ||
decoder.packet = vec![0xC2, 0x23, 0x45, 0x67, 0x00, 0x00]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you find some time, you can add comments here explaining what exactly the packet is here, the header the data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not possible tbh, bcs these are based on random values resulting of manipulation done in the functions & parameters passed as inputs. On based on that the resulted values are tested, I did not planned for any particular data.
assert_eq!(decoder.packet[0], 0x01); | ||
assert_eq!(decoder.packet[1], 0x02); | ||
assert_eq!(decoder.packet_length, 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, you could explain why we do these asserts. For example, why should decoder.packet[0] be equal to 0x01
decoder.windows[0].attribs.print_direction = | ||
dtvcc_window_pd::DTVCC_WINDOW_PD_RIGHT_LEFT as i32; | ||
decoder.process_cr(&mut encoder, &mut timing, no_rollup); | ||
assert_eq!(decoder.windows[0].pen_row, 3); | ||
assert_eq!(decoder.windows[0].pen_column, 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same in this file, some comments would help
If you find time you can write the extra comments, otherwise it's fine |
Refactor the code and use Default where needed Implement `PartialEq` also
5bd3327
to
8ffab1d
Compare
@PunitLodha Added the CI & fixed the warnings as well |
* feat: Add new function to allocate any object to heap with zero allocated * feat: Add unit tests for `decoder/commands.rs` * docs: Mention about PR in changelogs * feat: Add unit tests for `decoder/windows.rs` Refactor the code and use Default where needed Implement `PartialEq` also * fix: Intialise tmp extern C values for easy mocking * feat: Add unit tests for `decoder/timing.rs` * feat: Add unit tests for `decoder/output.rs` * feat: Add unit tests for `decoder/mod.rs` * feat: Add unit tests for `decoder/tv_screen.rs` * feat: Add unit tests for `lib.rs` * fix: Failing test * feat: [WIP] Add unit tests for `decoder/service_decoder.rs` * feat: Add unit tests for `decoder/service_decoder.rs` * feat: Add unit tests for `hardsubx/imgops.rs` * feat: Add unit tests for `hardsubx/utility.rs` * fix: cargo clippy * fix: doctest for `lib_ccxr` module * feat: Add test `lib_ccxr/util/mod.rs` * feat: Add test `lib_ccxr/util/levenshtein.rs` * feat: Add test `lib_ccxr/util/bits.rs` * feat: Add test `lib_ccxr/time/units.rs` * chore: Change function name * fix: Failing of missing values `tlt_config` * ci: Run unit test cases in `lib_ccxr` module also * ci: Run clippy & fmt in `lib_ccxr` module also * chore(clippy): Fix clippy warnings
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
Creating Unit test cases for rust modules(
decoder
+hardsubx
).Closes #911