protot/3rdparty/bx/tests/thread_test.cpp

39 lines
595 B
C++
Raw Normal View History

2016-11-10 21:53:08 +01:00
/*
2017-04-11 08:16:10 +02:00
* Copyright 2010-2017 Branimir Karadzic. All rights reserved.
2016-11-10 21:53:08 +01:00
* License: https://github.com/bkaradzic/bx#license-bsd-2-clause
*/
#include "test.h"
#include <bx/thread.h>
int32_t threadExit0(void*)
{
return 0;
}
int32_t threadExit1(void*)
{
return 1;
}
2017-04-11 08:16:10 +02:00
TEST_CASE("thread", "")
2016-11-10 21:53:08 +01:00
{
bx::Thread th;
2017-04-11 08:16:10 +02:00
REQUIRE(!th.isRunning() );
2016-11-10 21:53:08 +01:00
th.init(threadExit0);
2017-04-11 08:16:10 +02:00
REQUIRE(th.isRunning() );
2016-11-10 21:53:08 +01:00
th.shutdown();
2017-04-11 08:16:10 +02:00
REQUIRE(!th.isRunning() );
REQUIRE(th.getExitCode() == 0);
2016-11-10 21:53:08 +01:00
th.init(threadExit1);
2017-04-11 08:16:10 +02:00
REQUIRE(th.isRunning() );
2016-11-10 21:53:08 +01:00
th.shutdown();
2017-04-11 08:16:10 +02:00
REQUIRE(!th.isRunning() );
REQUIRE(th.getExitCode() == 1);
2016-11-10 21:53:08 +01:00
}