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

lan_discovery_test and version_test cleanup #967

Merged
merged 1 commit into from
Jul 6, 2018
Merged

lan_discovery_test and version_test cleanup #967

merged 1 commit into from
Jul 6, 2018

Conversation

hugbubby
Copy link
Member

@hugbubby hugbubby commented Jul 4, 2018

Another minor unit test PR. Big one coming up soon.

Removed a pointless declaration of a function in lan_discovery_test
and cleaned up the one error message there. Did an entire restructuring
of the version_test using macros that resulted in fewer lines of code but more
thorough testing.


This change is Reviewable

@iphydf iphydf added this to the v0.2.x milestone Jul 5, 2018
Copy link
Member

@iphydf iphydf left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 LGTMs obtained


auto_tests/version_test.c, line 13 at r1 (raw file):

           TOX_VERSION_IS_API_COMPATIBLE(major, minor, patch), argument)

#define FUZZ_VERSION \

This is not good.

This is adding logic to the tests, making them more complicated with no value added. The current test showcases exactly the situations we want to test. The changed tests need more thought to understand. Also, the macro you added here is a poorly behaved one. We will only allow well-behaved macros, i.e. ones that behave mostly like functions. This macro is a syntax extension (something like a new control structure) rather than an abbreviation of code.


auto_tests/version_test.c, line 23 at r1 (raw file):

                     bool actual, bool expected)
{
    ck_assert_msg(actual == expected,

This is good. Let's keep this change, but not the fuzz bit.

Copy link
Member

@iphydf iphydf left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 LGTMs obtained


auto_tests/version_test.c, line 24 at r1 (raw file):

{
    ck_assert_msg(actual == expected,
                  "Client version %d.%d.%d is %s compatible with library version %d.%d.%d, but it should %s be.\n",

There was a reason for this. Your change made it so that it says "... is compatible ..." (note the double space). Please revert that.

Copy link
Member

@iphydf iphydf left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 LGTMs obtained


auto_tests/version_test.c, line 24 at r1 (raw file):

Previously, iphydf wrote…

There was a reason for this. Your change made it so that it says "... is compatible ..." (note the double space). Please revert that.

Turns out, markdown doesn't show the two spaces.

"... is  compatible ..."
       ^^ two spaces here

Copy link
Member Author

@hugbubby hugbubby left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 LGTMs obtained


auto_tests/version_test.c, line 13 at r1 (raw file):

Previously, iphydf wrote…

This is not good.

This is adding logic to the tests, making them more complicated with no value added. The current test showcases exactly the situations we want to test. The changed tests need more thought to understand. Also, the macro you added here is a poorly behaved one. We will only allow well-behaved macros, i.e. ones that behave mostly like functions. This macro is a syntax extension (something like a new control structure) rather than an abbreviation of code.

I actually did this to make them more readable. Currently the tests are a bunch of unexplained specific comparisons. Now the test_api function is evaluated based on whether or not the output matches expected conditions, and under more inputs. I can see how the macro extension is a terrible idea though.

I'll send a new commit in attempting to revert the file back to its old method, but I'll be a dunce and add some comments for each section showcasing exactly what they're checking.


auto_tests/version_test.c, line 24 at r1 (raw file):

Previously, iphydf wrote…

Turns out, markdown doesn't show the two spaces.

"... is  compatible ..."
       ^^ two spaces here

Srry

Copy link
Member

@iphydf iphydf left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 LGTMs obtained


auto_tests/version_test.c, line 65 at r2 (raw file):

#define TOX_VERSION_MINOR 0
#define TOX_VERSION_PATCH 4
    //Beyond 0.*.* Tox is comfortable with any lower version within their major

Space after //.

Copy link
Member

@iphydf iphydf left a comment

Choose a reason for hiding this comment

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

:lgtm_strong:

Reviewable status: :shipit: complete! 1 of 1 LGTMs obtained

@iphydf
Copy link
Member

iphydf commented Jul 6, 2018

Squash all commits into one.

@hugbubby
Copy link
Member Author

hugbubby commented Jul 6, 2018

What did I do...

Edit:
It's fixed now?

@iphydf
Copy link
Member

iphydf commented Jul 6, 2018

Yes, but there is still a merge commit in there.

@hugbubby
Copy link
Member Author

hugbubby commented Jul 6, 2018

Fuck

I

I cant do it

@iphydf
Copy link
Member

iphydf commented Jul 6, 2018

I'll do it.

@hugbubby
Copy link
Member Author

hugbubby commented Jul 6, 2018

I'm so sorry you have to deal with the shit from people like me

Removed a pointless declaration of a function in lan_discovery_test
and cleaned up the one error message there. Did an entire restructuring
of the version_test using macros that resulted in fewer lines of code but more
thorough testing.

Formatting of version_test.c

back to old way, save comments and one change

Missing space
My greatest enemy

Add `#include <cstdio>` for `std::printf`.

Make tox.c unambiguously parseable.

Rules:
1. Constants are uppercase names: THE_CONSTANT.
2. SUE[1] types start with an uppercase letter and have at least one
   lowercase letter in it: The_Type, THE_Type.
3. Function types end in "_cb": tox_friend_connection_cb.
4. Variable and function names are all lowercase: the_function.

This makes it easier for humans reading the code to determine what an
identifier means. I'm not convinced by the enum type name change, but I
don't know a better rule. Currently, a lot of enum types are spelled like
constants, which is confusing.

[1] struct/union/enum

Use run_auto_test.h test fixture for some auto-tests.

Most of the auto-tests should use this fixture, but I've only done a few
to set an example.
@iphydf iphydf merged commit 47a5275 into TokTok:master Jul 6, 2018
@iphydf
Copy link
Member

iphydf commented Jul 6, 2018

No worries, thanks for the contribution :).

@iphydf iphydf modified the milestones: v0.2.x, v0.2.4 Jul 16, 2018
@iphydf iphydf changed the title lan_discovery_test and version_test cleanup lan_discovery_test and version_test cleanup Apr 30, 2020
This pull request was closed.
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