29 lines
764 B
C++
29 lines
764 B
C++
/*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*
|
|
* Copyright 2019 Danny Robson <danny@nerdcruft.net>
|
|
*/
|
|
|
|
#include "thread/thread.hpp"
|
|
#include "tap.hpp"
|
|
|
|
#include <atomic>
|
|
|
|
static void run (std::atomic<int> &val) { ++val; }
|
|
|
|
|
|
int main ()
|
|
{
|
|
cruft::TAP::logger tap;
|
|
|
|
// Get the thread to increment an int. If it's been incremented once after
|
|
// joining then we assume the thread ran successfully.
|
|
std::atomic<int> val = 0;
|
|
cruft::thread::thread dude (run, std::ref (val));
|
|
dude.join ();
|
|
tap.expect_eq (val.load (), 1, "thread appears to have run");
|
|
|
|
return tap.status ();
|
|
} |