Give yourself a gift that will last longer than New Year's Eve. In many cases, you will be happy about it for many years.
There are still some grinches who don't believe in the satisfaction of unit tests and think: It's just a myth told at developer conferences.
To be honest, I program too few unit tests, but enough to find bugs I would never have discovered otherwise.
Just yesterday, a small change in my FDK would have caused numerous of my applications to stop working. However, since I use Stefan's Testinsight I got immediate feedback from my unit tests when I hit save...
Here for example:
before:
after:
Function FindSomeThing( const aName : String ) : boolean;
var
lShelp : String;
begin
lShelp := aName.ToLower;
Result := FindField('f'+lShelp,
lShelp,Nr,lShelp);
end;
My goal was just to do the .ToLower once. I already had this helper string for a not used param, so where is the problem?
Five tests failed after I hit save.
Let's have a look at the FindField method.
Function FindField(Const aName1, aName2; out ListNr : Integer; out Name : String) : boolean;
aName1 contains only the "f" and aName2 is empty, because of the out param. Did you know this "problem"?
So use the quiet time to write one or some unit test, maybe for a routine that has always caused problems or just to get a better source code coverage.
And if you haven't found the time to deal with unit tests yet, then use this quiet time and try it with simple examples.
Merry Christmas and a happy new year.
Frank
Dein Problem hat aber nicht zufällig hiermit was zu tun?
ReplyDeletehttps://blog.marcocantu.com/blog/2020-december-Delphi-const-string-params.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+marcocantublog+%28marcocantu.blog%29
ToLower benutzt eine implizite Temp-Variable (hoffentlich zwei, für die beiden Aufrufe)
und mit dieser Variable wird ein Const-Parameter gefüttert.