Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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://sam.zoy.org/projects/COPYING.WTFPL 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(ArrayTest)
  18. {
  19. void SetUp() {}
  20. void TearDown() {}
  21. LOLUNIT_TEST(ArrayFill)
  22. {
  23. Array<int> a;
  24. a.Append(0);
  25. a.Append(1);
  26. a.Append(2);
  27. a.Append(3);
  28. LOLUNIT_ASSERT_EQUAL(a[0], 0);
  29. LOLUNIT_ASSERT_EQUAL(a[1], 1);
  30. LOLUNIT_ASSERT_EQUAL(a[2], 2);
  31. LOLUNIT_ASSERT_EQUAL(a[3], 3);
  32. }
  33. LOLUNIT_TEST(ArrayCopy)
  34. {
  35. Array<int> a;
  36. a.Append(0);
  37. a.Append(1);
  38. a.Append(2);
  39. a.Append(3);
  40. Array<int> b = a;
  41. LOLUNIT_ASSERT_EQUAL(b[0], 0);
  42. LOLUNIT_ASSERT_EQUAL(b[1], 1);
  43. LOLUNIT_ASSERT_EQUAL(b[2], 2);
  44. LOLUNIT_ASSERT_EQUAL(b[3], 3);
  45. }
  46. LOLUNIT_TEST(EightElements)
  47. {
  48. Array<int, long, float, double, unsigned, char, bool, void *> a;
  49. a.Append(1, 2, 3.f, 4.0, 5, 'a', true, 0);
  50. LOLUNIT_ASSERT_EQUAL(a[0].m1, 1);
  51. LOLUNIT_ASSERT_EQUAL(a[0].m2, 2);
  52. LOLUNIT_ASSERT_EQUAL(a[0].m3, 3.f);
  53. LOLUNIT_ASSERT_EQUAL(a[0].m4, 4.0);
  54. LOLUNIT_ASSERT_EQUAL(a[0].m5, 5);
  55. LOLUNIT_ASSERT_EQUAL(a[0].m6, 'a');
  56. LOLUNIT_ASSERT_EQUAL(a[0].m7, true);
  57. LOLUNIT_ASSERT_EQUAL(a[0].m8, 0);
  58. }
  59. };
  60. } /* namespace lol */