thread_test.cpp 595 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright 2010-2017 Branimir Karadzic. All rights reserved.
  3. * License: https://github.com/bkaradzic/bx#license-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_CASE("thread", "")
  16. {
  17. bx::Thread th;
  18. REQUIRE(!th.isRunning() );
  19. th.init(threadExit0);
  20. REQUIRE(th.isRunning() );
  21. th.shutdown();
  22. REQUIRE(!th.isRunning() );
  23. REQUIRE(th.getExitCode() == 0);
  24. th.init(threadExit1);
  25. REQUIRE(th.isRunning() );
  26. th.shutdown();
  27. REQUIRE(!th.isRunning() );
  28. REQUIRE(th.getExitCode() == 1);
  29. }