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.
 
 
 

52 regels
1.1 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2014 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(Array3DTest)
  18. {
  19. void SetUp() {}
  20. void TearDown() {}
  21. LOLUNIT_TEST(Array3DCreate)
  22. {
  23. Array3D<int> a(ivec3(10, 10, 10));
  24. a[0][0][0] = 2;
  25. a[9][0][0] = 4;
  26. a[0][9][9] = 6;
  27. a[9][9][9] = 8;
  28. LOLUNIT_ASSERT_EQUAL(a[0][0][0], 2);
  29. LOLUNIT_ASSERT_EQUAL(a[9][0][0], 4);
  30. LOLUNIT_ASSERT_EQUAL(a[0][9][9], 6);
  31. LOLUNIT_ASSERT_EQUAL(a[9][9][9], 8);
  32. Array3D<int> const &b = a;
  33. LOLUNIT_ASSERT_EQUAL(b[0][0][0], 2);
  34. LOLUNIT_ASSERT_EQUAL(b[9][0][0], 4);
  35. LOLUNIT_ASSERT_EQUAL(b[0][9][9], 6);
  36. LOLUNIT_ASSERT_EQUAL(b[9][9][9], 8);
  37. }
  38. };
  39. } /* namespace lol */