tests.generics.bugs.pas 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. {
  2. This file is part of the Free Pascal/NewPascal run time library.
  3. Copyright (c) 2018 by Maciej Izak (hnb),
  4. member of the NewPascal development team (http://newpascal.org)
  5. Copyright(c) 2004-2018 DaThoX
  6. It contains tests for the Free Pascal generics library
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. Acknowledgment
  13. Thanks to Sphere 10 Software (http://sphere10.com) for sponsoring
  14. many new types, tests and major refactoring of entire library
  15. **********************************************************************}
  16. unit tests.generics.bugs;
  17. {$mode delphi}
  18. interface
  19. uses
  20. fpcunit, testregistry, testutils,
  21. Classes, SysUtils, Generics.Collections, Generics.Defaults;
  22. type
  23. { TTestBugs }
  24. TTestBugs = class(TTestCase)
  25. published
  26. procedure Test_QuadraticProbing_InfinityLoop;
  27. procedure Test_GetEqualityComparer;
  28. end;
  29. implementation
  30. { TTestBugs }
  31. procedure TTestBugs.Test_QuadraticProbing_InfinityLoop;
  32. // https://github.com/maciej-izak/generics.collections/issues/4
  33. var
  34. LMap: TOpenAddressingQP<string, pointer, TDelphiHashFactory>;
  35. begin
  36. LMap := TOpenAddressingQP<string, pointer, TDelphiHashFactory>.Create();
  37. LMap.Add(#178#178#107#141#143#151#168#39#172#38#83#194#130#90#101, nil);
  38. LMap.Add(#193#190#172#41#144#231#52#62#45#117#108#45#217#71#77, nil);
  39. LMap.Add(#49#116#202#160#38#131#41#37#217#171#227#215#122#151#71, nil);
  40. LMap.Add(#148#159#199#71#198#97#69#201#116#45#195#184#178#129#200, nil);
  41. CheckEquals(false, LMap.ContainsKey(#$E6'h=fzb'#$E5#$B4#$A0#$C4#$E6'B6r>'));
  42. LMap.Free;
  43. end;
  44. procedure TTestBugs.Test_GetEqualityComparer;
  45. begin
  46. TDelphiQuadrupleHashFactory.GetHashService.LookupEqualityComparer(TypeInfo(Integer), SizeOf(Integer));
  47. end;
  48. begin
  49. RegisterTest(TTestBugs);
  50. end.