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.
 
 
 

64 lines
1.3 KiB

  1. //
  2. // Lol Engine — Unit tests
  3. //
  4. // Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net>
  5. // © 2014—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com>
  6. //
  7. // Lol Engine is free software. It comes without any warranty, to
  8. // the extent permitted by applicable law. You can redistribute it
  9. // and/or modify it under the terms of the Do What the Fuck You Want
  10. // to Public License, Version 2, as published by the WTFPL Task Force.
  11. // See http://www.wtfpl.net/ for more details.
  12. //
  13. #include <lol/engine-internal.h>
  14. #include <string>
  15. #include <map>
  16. #include <lolunit.h>
  17. namespace lol
  18. {
  19. lolunit_declare_fixture(thread_test)
  20. {
  21. void setup()
  22. {
  23. }
  24. void teardown()
  25. {
  26. }
  27. lolunit_declare_test(queue_try_push)
  28. {
  29. queue<int, 1> q;
  30. bool b1 = q.try_push(0);
  31. lolunit_assert_equal(true, b1);
  32. bool b2 = q.try_push(1);
  33. lolunit_assert_equal(false, b2);
  34. }
  35. lolunit_declare_test(queue_try_pop)
  36. {
  37. queue<int, 1> q;
  38. int tmp;
  39. q.push(42);
  40. bool b1 = q.try_pop(tmp);
  41. lolunit_assert_equal(true, b1);
  42. lolunit_assert_equal(42, tmp);
  43. bool b2 = q.try_pop(tmp);
  44. lolunit_assert_equal(false, b2);
  45. lolunit_assert_equal(42, tmp);
  46. }
  47. };
  48. } /* namespace lol */