2
0

thread.cpp 628 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright 2010-2015 Branimir Karadzic. All rights reserved.
  3. * License: http://www.opensource.org/licenses/BSD-2-Clause
  4. */
  5. #include "test.h"
  6. #include <bx/thread.h>
  7. int32_t threadExit0(void*)
  8. {
  9. return 0;
  10. }
  11. int32_t threadExit1(void*)
  12. {
  13. return 1;
  14. }
  15. TEST(thread)
  16. {
  17. bx::Thread th;
  18. CHECK_EQUAL(th.isRunning(), false);
  19. th.init(threadExit0);
  20. CHECK_EQUAL(th.isRunning(), true);
  21. th.shutdown();
  22. CHECK_EQUAL(th.isRunning(), false);
  23. CHECK_EQUAL(th.getExitCode(), 0);
  24. th.init(threadExit1);
  25. CHECK_EQUAL(th.isRunning(), true);
  26. th.shutdown();
  27. CHECK_EQUAL(th.isRunning(), false);
  28. CHECK_EQUAL(th.getExitCode(), 1);
  29. }