summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bx/tests/thread.cpp
blob: f0ee772aeba59828aec33eb3f2663741458a6646 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * Copyright 2010-2016 Branimir Karadzic. All rights reserved.
 * 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;
}

TEST(thread)
{
	bx::Thread th;

	CHECK_EQUAL(th.isRunning(), false);

	th.init(threadExit0);
	CHECK_EQUAL(th.isRunning(), true);
	th.shutdown();

	CHECK_EQUAL(th.isRunning(), false);
	CHECK_EQUAL(th.getExitCode(), 0);

	th.init(threadExit1);
	CHECK_EQUAL(th.isRunning(), true);
	th.shutdown();

	CHECK_EQUAL(th.isRunning(), false);
	CHECK_EQUAL(th.getExitCode(), 1);
}