Changeset 68 for trunk/NewView
- Timestamp:
- Feb 6, 2007, 9:00:43 PM (19 years ago)
- Location:
- trunk/NewView
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NewView/StringUtilsUnit.pas
r65 r68 61 61 // this is case INsensitive 62 62 Function StrEndsWithIgnoringCase(const aString: String; const anEndString: String): Boolean; 63 64 // the IntToStr generates wrong results 65 // in normal cases IntToStr returns a negative value 66 // and somtimes completly wrong values 67 Function LongWordToStr(const aLongWord: LongWord) : String; 63 68 64 69 Function BoolToStr(const aBoolean : boolean ): string; … … 288 293 end; 289 294 295 Function LongWordToStr(const aLongWord: LongWord) : String; 296 Var 297 l : LongWord; 298 i : Integer; 299 Begin 300 Result := ''; 301 l := aLongWord; 302 303 if l = 0 then 304 begin 305 result := '0'; 306 exit; 307 end; 308 309 while l > 0 do 310 begin 311 i := l mod 10; 312 l := l div 10; 313 Case i of 314 0 : result := '0' + result; 315 1 : result := '1' + result; 316 2 : result := '2' + result; 317 3 : result := '3' + result; 318 4 : result := '4' + result; 319 5 : result := '5' + result; 320 6 : result := '6' + result; 321 7 : result := '7' + result; 322 8 : result := '8' + result; 323 9 : result := '9' + result; 324 end; 325 end; 326 327 end; 328 329 290 330 Function BoolToStr(const aBoolean : boolean ): string; 291 331 begin -
trunk/NewView/unittests/StringUtilsUnitTests.pas
r65 r68 636 636 assertTrue('testStrEndsWithIgnoringCase_StringMatchCaseSensitive', tmpResult); 637 637 END; 638 639 640 PROCEDURE testLongWordToStr_Zero; 641 VAR 642 tmpResult : String; 643 BEGIN 644 tmpResult := LongWordToStr(0); 645 646 assertEqualsString('testLongWordToStr_Zero', '0', tmpResult); 647 END; 648 649 650 PROCEDURE testLongWordToStr_Four; 651 VAR 652 tmpResult : String; 653 BEGIN 654 tmpResult := LongWordToStr(4); 655 656 assertEqualsString('testLongWordToStr_Four', '4', tmpResult); 657 END; 658 659 PROCEDURE testLongWordToStr_Max; 660 VAR 661 tmpResult : String; 662 BEGIN 663 tmpResult := LongWordToStr(4294967295); 664 665 assertEqualsString('testLongWordToStr_Max', '4294967295', tmpResult); 666 END; 667 638 668 639 669 … … 720 750 result.add(@testStrEndsWithIgnoringCase_StringMatchCaseInSensitive); 721 751 752 result.add(@testLongWordToStr_Zero); 753 result.add(@testLongWordToStr_Four); 754 result.add(@testLongWordToStr_Max); 755 722 756 result.add(@testBoolToStr_true); 723 757 result.add(@testBoolToStr_false); -
trunk/NewView/unittests/testassert.pas
r27 r68 10 10 PROCEDURE assertEqualsString(aTestDescription : String; anExpectedValue : String; aRealValue : String); 11 11 PROCEDURE assertEqualsInt(aTestDescription : String; anExpectedValue : INTEGER; aRealValue : INTEGER); 12 PROCEDURE assertEqualsLongWord(aTestDescription : String; anExpectedValue : LongWord; aRealValue : LongWord); 12 13 PROCEDURE assertTrue(aTestDescription : String; aRealValue : Boolean); 13 14 PROCEDURE assertFalse(aTestDescription : String; aRealValue : Boolean); … … 33 34 34 35 PROCEDURE assertEqualsInt(aTestDescription : String; anExpectedValue : INTEGER; aRealValue : INTEGER); 36 VAR 37 tmpMessage : String; 38 tmpIntString : String; 39 BEGIN 40 if (aRealValue <> anExpectedValue) then 41 begin 42 tmpMessage := 'Failed: ' + aTestDescription + ' Expected: '''; 43 Str(anExpectedValue, tmpIntString); 44 tmpMessage := tmpMessage + tmpIntString; 45 tmpMessage := tmpMessage + ''' but it was: '''; 46 Str(aRealValue, tmpIntString); 47 tmpMessage := tmpMessage + tmpIntString; 48 tmpMessage := tmpMessage + ''''; 49 raise EAssertFailed.Create(tmpMessage); 50 end; 51 END; 52 53 54 PROCEDURE assertEqualsLongWord(aTestDescription : String; anExpectedValue : LongWord; aRealValue : LongWord); 35 55 VAR 36 56 tmpMessage : String;
Note:
See TracChangeset
for help on using the changeset viewer.