-
Notifications
You must be signed in to change notification settings - Fork 39
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
Add a format parameter to the Decimal type #715
base: master
Are you sure you want to change the base?
Conversation
LGTM. Can you fix the code sniffer issue and squash your commits? |
I hope that was all correct. My first question: What is squashing? 🙈 |
Great. One more thing: can you please extend the unit tests to cover your new setting? See https://github.com/cosmocode/dokuwiki-plugin-struct/blob/master/_test/types/DecimalTest.php |
OK, test failed:
I will fix that. |
The commit message is now total crap. Unfortunately, I have no idea whether it can still be changed... |
You can do a |
_test/types/DecimalTest.php
Outdated
['362525200', '3.625e+8' , '-1', '.', ' ', true, '', '', false, '%.3e'], | ||
['362525200', '3.625E+8' , '-1', '.', ' ', true, '', '', false, '%.3E'], | ||
['1', '1' , '-1', '.', ' ', true, '', '', false, '%u'], | ||
['-1', '18446744073709551615' , '-1', '.', ' ', true, '', '', false, '%u'], |
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.
can you also add tests for where the format string is wrong and thus ignored?
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.
You are right. The -
should be in the regex as a character and not as a range. By extending the test I realized that. Thank you!
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.
This last test looks interesting. I think it is dependent on the platform and would fail on a 32bit system
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.
Of course you're right again!
32bit:
php > printf('%u','-1');
4294967295
I will remove the last line of the test and adjust the penultimate one. It should only be checked whether %u
is recognized.
a0656b3
to
da0a1c3
Compare
refine regex and extend test remove test of negative value for %u adjust test for %u fix %s -> %u
A user on DokuWiki Forum need a special format for numbers.
https://forum.dokuwiki.org/d/22218-how-to-force-leading-zeroes-when-using-a-bureacuracy-form-with-struct
This add a new config parameter for the Decimal type:
format
If format is set and valid all other formatting parameters(
roundto, decpoint, thousands, trimzeros, engineering
) are ignored.format must be a valid format for sprintf and accepts the following number formats:
bdeEfFu