-
Notifications
You must be signed in to change notification settings - Fork 98
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
New methods copyValueOf, is(Not)Empty and capitalise #323
base: master
Are you sure you want to change the base?
Conversation
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 the new methods to the documentation/examples?
src/test/java/nl/hsac/fitnesse/fixture/slim/StringFixtureTest.java
Outdated
Show resolved
Hide resolved
Update to latest master
main/java: -renamed copyValueOf to getValueOf -new methods for checking undefined symbols: isUndefined, isEmptyOrUndefined -updated methods: isEmpty, isNotEmpty, capitalise -additional method setNullValue. test/java: -reverted import wildcard -updated unit tests -added unit tests for new methods wiki: -added examples for usage of new methods. -new example without regex for replaceAllInWith
Hi Fried, I've made quite a lot of changes and added a couple of new methods for checking undefined symbols (based on the symbol name definition). Let me know if further changes are needed. |
* @param value value to capitalise. | ||
* @return capitalised value. | ||
*/ | ||
public String capitalise (String value) { |
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.
public String capitalise (String value) { | |
public String capitalise(String value) { |
* | ||
* @return null value. | ||
*/ | ||
public String setNullValue() { return null;} |
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.
public String setNullValue() { return null;} | |
public String setNullValue() { | |
return null; | |
} |
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.
How do you use this method in your tests? Is there added value (over just assigning an empty string)?
* @param value value to check. | ||
* @return {@code true} if undefined (value is symbol name-like), {@code false} otherwise. | ||
*/ | ||
public boolean isUndefined(String value) { |
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 seems like an unreliable way to check for an undefined symbol. It will also match a string that happens to conform to the regular expression. Is there a better way to check whether a symbol is known in Slim? Maybe it can be checked by having a special Slim table...
If this is a really important thing to check in your tests you could just check this regular expression using standard Slim regex matching and valueOf
or getValueOf
wrapped in a scenario...
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.
Having a symbol in your tests that may or may not be assigned a value sounds like a code smell of your tests.
If you worry a symbol may have been assigned a value in a previous test in a suite, just ensure you assign a known (empty, or otherwise not occurring value) in your SetUp.
* @param value value to check. | ||
* @return {@code true} if empty, or {@code false} otherwise. | ||
*/ | ||
public boolean isEmpty(String value) { return StringUtils.isEmpty(value); } |
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.
Does this really add value on top of a regular Slim regex check (possibly wrapped in a scenario)?
* @param value value to check. | ||
* @return {@code true} if filled (not empty), {@code false} otherwise. | ||
*/ | ||
public boolean isNotEmpty(String value) { return !isEmpty(value); } |
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.
idem
No description provided.