您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://www.wtfpl.net/ for more details.
  9. //
  10. #if defined HAVE_CONFIG_H
  11. # include "config.h"
  12. #endif
  13. #include "core.h"
  14. #include "lol/unit.h"
  15. namespace lol
  16. {
  17. LOLUNIT_FIXTURE(MapTest)
  18. {
  19. void SetUp() {}
  20. void TearDown() {}
  21. LOLUNIT_TEST(MapDeclare)
  22. {
  23. Map<uint8_t, uint8_t> m1;
  24. Map<int, int> m2;
  25. Map<float, float> m3;
  26. Map<char const *, char const *> m4;
  27. }
  28. LOLUNIT_TEST(MapSet)
  29. {
  30. Map<int, int> map;
  31. for (int i = 0; i < 100000; i++)
  32. map[i] = -1;
  33. for (int i = 0; i < 100000; i++)
  34. map[i] = i;
  35. for (int i = 0; i < 100000; i++)
  36. LOLUNIT_ASSERT_EQUAL(map[i], i);
  37. }
  38. LOLUNIT_TEST(MapHasKey)
  39. {
  40. Map<int, int> map;
  41. map[0] = 1;
  42. map[2] = 2;
  43. LOLUNIT_ASSERT(map.HasKey(0));
  44. LOLUNIT_ASSERT(!map.HasKey(1));
  45. LOLUNIT_ASSERT(map.HasKey(2));
  46. }
  47. };
  48. } /* namespace lol */