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.
 
 
 

74 regels
1.8 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. #include <lol/engine-internal.h>
  11. #include <lolunit.h>
  12. namespace lol
  13. {
  14. lolunit_declare_fixture(Array2DTest)
  15. {
  16. void SetUp() {}
  17. void TearDown() {}
  18. lolunit_declare_test(Array2DCreate)
  19. {
  20. array2d<int> a(ivec2(10, 10));
  21. a[0][0] = 2;
  22. a[9][0] = 4;
  23. a[0][9] = 6;
  24. a[9][9] = 8;
  25. lolunit_assert_equal(a[0][0], 2);
  26. lolunit_assert_equal(a[9][0], 4);
  27. lolunit_assert_equal(a[0][9], 6);
  28. lolunit_assert_equal(a[9][9], 8);
  29. array2d<int> const &b = a;
  30. lolunit_assert_equal(b[0][0], 2);
  31. lolunit_assert_equal(b[9][0], 4);
  32. lolunit_assert_equal(b[0][9], 6);
  33. lolunit_assert_equal(b[9][9], 8);
  34. }
  35. lolunit_declare_test(Array2DInit)
  36. {
  37. array2d<int> a = { { 1, 2, 3, 4 },
  38. { 5, 6, 7, 8 },
  39. { 9, 8, 7, 6 } };
  40. lolunit_assert_equal(a.GetSize().x, 4);
  41. lolunit_assert_equal(a.GetSize().y, 3);
  42. lolunit_assert_equal(a[0][0], 1);
  43. lolunit_assert_equal(a[1][0], 2);
  44. lolunit_assert_equal(a[2][0], 3);
  45. lolunit_assert_equal(a[3][0], 4);
  46. lolunit_assert_equal(a[0][1], 5);
  47. lolunit_assert_equal(a[1][1], 6);
  48. lolunit_assert_equal(a[2][1], 7);
  49. lolunit_assert_equal(a[3][1], 8);
  50. lolunit_assert_equal(a[0][2], 9);
  51. lolunit_assert_equal(a[1][2], 8);
  52. lolunit_assert_equal(a[2][2], 7);
  53. lolunit_assert_equal(a[3][2], 6);
  54. }
  55. };
  56. } /* namespace lol */