Skip to content

KF-25 add tests for encoding#36

Closed
Kellesi wants to merge 7 commits into
mainfrom
KF-25-test-encoding
Closed

KF-25 add tests for encoding#36
Kellesi wants to merge 7 commits into
mainfrom
KF-25-test-encoding

Conversation

@Kellesi
Copy link
Copy Markdown
Collaborator

@Kellesi Kellesi commented Aug 5, 2025

Task: https://jira.dev.local/jira/browse/KF-25
Added tests for Hex, Base64, EncodingDetector, TextDetector
Added comments for tested classes

Comment thread test/Base64.cpp
Comment thread test/EncodingDetector.cpp
Comment thread include/kf/Base64.h Outdated
uint8_t a3[3];
uint8_t a4[4];

if (output.size() < decodeLen(input))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

identation is wrong

Comment thread test/EncodingDetector.cpp Outdated
}

GIVEN("Empty buffer")
GIVEN("Empty buffer small buffer (<kMaximumBomLength)")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Empty buffer, (comma) small buffer...?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Corrected

Comment thread test/EncodingDetector.cpp Outdated
}
}

GIVEN("Empty buffer big buffer (>kMaximumBomLength)")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just Big buffer?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Renamed to 'Empty big buffer', because there is a different behavoir for buffer bigger than kMaximumBomLength and smaller

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The word empty has conflict with big. If empty means that it is filled with zeroes, then it is just not right word for it.

Comment thread test/EncodingDetector.cpp

THEN("Encoding is set to ANSI")
{
REQUIRE(detector.getEncoding() == kf::EncodingDetector::ANSI);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ANSI that contains nulls? It looks like Unknown

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ANSI is used as fallback type if no BOM and no UTF-16-like null byte pattern was detected.
So I guess we should add some ANSI pattern check

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sure, and as for me, ANSI should not be used as a fallback, Unknown is the right value for it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

So, should I change it in this PR?
It doesn't seem related to the current task. Also, an ANSI check will need to be added because simply replacing it with Unknown will break the function

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@SergiusTheBest what do you think about my proposal and the impact?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@SergiusTheBest what do you think about my proposal and the impact?

@belyshevdenis Yes, it makes sense. But let's create an issue for it and a separate PR with the fix.
@Kellesi I searched for usage of that function and we can change the defaults to Unknown without breaking things.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Changed to Unknown in PR #43
Also removed test for ANSI to prevent test fail, until such check would be implemented

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Changed to Unknown in PR #43 Also removed test for ANSI to prevent test fail, until such check would be implemented

@Kellesi Oh, no! We can't change the defaults without adding a proper check for ANSI. Now ANSI is never returned that is bad :(

Comment thread include/kf/Base64.h
@SergiusTheBest
Copy link
Copy Markdown
Member

SergiusTheBest commented Aug 7, 2025

@Kellesi @belyshevdenis Guys, let's do small PRs, so we can merge code quickly, have less discussions and follow the principle "If you want to eat an elephant, do it with a teaspoon". Here we should have 4 PRs instead of 1. Actually it will make everyone happier as things will move instead of stalling for days.

@belyshevdenis
Copy link
Copy Markdown
Collaborator

@Kellesi @belyshevdenis Guys, let's do small PRs, so we can merge code quickly, have less discussions and follow the principle "If you want to eat an elephant, do it with a teaspoon". Here we should have 4 PRs instead of 1. Actually it will make everyone happier as things will move instead of stalling for days.

@Kellesi please split it to 4 PRs: 1 per class test, and remove changes from UString, they will be added in another PR

@Kellesi
Copy link
Copy Markdown
Collaborator Author

Kellesi commented Aug 11, 2025

@Kellesi @belyshevdenis Guys, let's do small PRs, so we can merge code quickly, have less discussions and follow the principle "If you want to eat an elephant, do it with a teaspoon". Here we should have 4 PRs instead of 1. Actually it will make everyone happier as things will move instead of stalling for days.

@Kellesi please split it to 4 PRs: 1 per class test, and remove changes from UString, they will be added in another PR

Base64:
#41
TextDetector:
#42
EncodingDetector:
#43
Hex (build fails without UString warning disable):
#44

@SergiusTheBest
Copy link
Copy Markdown
Member

Closing it as we have separate PRs now.

@SergiusTheBest SergiusTheBest deleted the KF-25-test-encoding branch August 13, 2025 14:48
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.

3 participants