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.7 KiB

  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 */