In a comment to the Day 4 installment, Richard Rose pointed out that WD17 is in fact out of beta. I need to crawl out from under my rock more often. Thanks Richard! I'm downloading the update now, but today's hour will still be with WD16.
Yesterday I got sidetracked by my wish to do some unit testing, and today I feel the itch to run just one more little test. I'd like to find out a bit more about how WinDev handles strings.
Here's my first attempt a test procedure.
Code Block | ||
---|---|---|
| ||
PROCEDURE ReplaceCharactersInAString_VerifyResult(baseString,newCharacters,startPos)
endPos is int
endPos = startPos + newCharacters..TextLength - 1
baseString[[startPos TO endPos]] = newCharacters
RESULT baseString |
After writing this procedure I right-clicked on the procedure in the Project Explorer and chose Run the procedure test. This isn't an automated test, it's a handy way to manually test the code.
I set some values and hit the Go button. And the procedure crashed:
It turns out that although TextLength is a property, I'm not allowed to use it on strings. But just for fun I decided to hit the Debug button, which brought up the debugger window so I could step through the code.
It's easy to set break points in WinDev - just click in the far left column. When you run the code (or at least a procedure, as in this example) you're automatically in debug mode.
As you can see from the screen shot, I rewrote my code to use the Length() function and that worked. Here are the results of the procedure call:
Automated testing
I don't want to have to run manual tests all the time. But as I've previously noted, it's easy to create automated tests. Again, from the Project Explorer I added a new test:
At this point I realized that I'd named my global procedure as if it were the test. So I renamed it to