Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.2 KiB

  1. /* Test driver for class HashTable */
  2. /* Author: Paul Larson, [email protected] */
  3. /* Much hacked upon by George V. Reilly, [email protected] */
  4. #include <windows.h>
  5. #include <stdlib.h>
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include "numset.h"
  9. LK_RETCODE
  10. InsertRecord(
  11. CNumberTestHashTable* pntht,
  12. int n)
  13. {
  14. return pntht->InsertRecord((const int*) (DWORD_PTR) n);
  15. }
  16. LK_RETCODE
  17. FindKey(
  18. CNumberTestHashTable* pntht,
  19. int nKey,
  20. int** pptOut)
  21. {
  22. return pntht->FindKey(nKey, pptOut);
  23. }
  24. LK_RETCODE
  25. DeleteKey(
  26. CNumberTestHashTable* pntht,
  27. int nKey)
  28. {
  29. return pntht->DeleteKey(nKey);
  30. }
  31. void Test(
  32. CNumberTestHashTable* pntht,
  33. int n)
  34. {
  35. int* pt2 = NULL;
  36. LK_RETCODE lkrc;
  37. lkrc = InsertRecord(pntht, n);
  38. IRTLASSERT(LK_SUCCESS == lkrc);
  39. lkrc = FindKey(pntht, n, &pt2);
  40. IRTLASSERT(LK_SUCCESS == lkrc);
  41. printf("FK = %d\n", (int) (DWORD_PTR) pt2);
  42. lkrc = DeleteKey(pntht, n);
  43. IRTLASSERT(LK_SUCCESS == lkrc);
  44. }
  45. int __cdecl
  46. main(
  47. int argc,
  48. char **argv)
  49. {
  50. CNumberTestHashTable ntht;
  51. int n = 1965;
  52. Test(&ntht, n);
  53. Test(&ntht, 0);
  54. return(0) ;
  55. } /* main */