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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2013 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 <lol/main.h>
  14. #include "lol/unit.h"
  15. namespace lol
  16. {
  17. LOLUNIT_FIXTURE(ThreadTest)
  18. {
  19. void SetUp() {}
  20. void TearDown() {}
  21. LOLUNIT_TEST(QueueTryPush)
  22. {
  23. Queue<int, 1> q;
  24. bool b1 = q.TryPush(0);
  25. LOLUNIT_ASSERT_EQUAL(true, b1);
  26. bool b2 = q.TryPush(1);
  27. LOLUNIT_ASSERT_EQUAL(false, b2);
  28. }
  29. LOLUNIT_TEST(QueueTryPop)
  30. {
  31. Queue<int, 1> q;
  32. int tmp;
  33. q.Push(42);
  34. bool b1 = q.TryPop(tmp);
  35. LOLUNIT_ASSERT_EQUAL(true, b1);
  36. LOLUNIT_ASSERT_EQUAL(42, tmp);
  37. bool b2 = q.TryPop(tmp);
  38. LOLUNIT_ASSERT_EQUAL(false, b2);
  39. LOLUNIT_ASSERT_EQUAL(42, tmp);
  40. }
  41. };
  42. } /* namespace lol */