code format
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "pithreadnotifier.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
|
||||
TEST(PIThreadNotifierTest, One) {
|
||||
PIThreadNotifier n;
|
||||
int cnt = 0;
|
||||
PIThread t1([&n, &cnt](){n.wait(); cnt++;}, true);
|
||||
PIThread t1(
|
||||
[&n, &cnt]() {
|
||||
n.wait();
|
||||
cnt++;
|
||||
},
|
||||
true);
|
||||
piMSleep(10);
|
||||
n.notifyOnce();
|
||||
piMSleep(10);
|
||||
@@ -21,14 +27,31 @@ TEST(PIThreadNotifierTest, Two) {
|
||||
int cnt1 = 0;
|
||||
int cnt2 = 0;
|
||||
int cnt3 = 0;
|
||||
PIThread t1([&n, &cnt1](){n.wait(); cnt1++; piMSleep(2);}, true);
|
||||
PIThread t2([&n, &cnt2](){n.wait(); cnt2++; piMSleep(2);}, true);
|
||||
PIThread t3([&n, &cnt3](){n.notifyOnce(); cnt3++; piMSleep(1);}, true);
|
||||
PIThread t1(
|
||||
[&n, &cnt1]() {
|
||||
n.wait();
|
||||
cnt1++;
|
||||
piMSleep(2);
|
||||
},
|
||||
true);
|
||||
PIThread t2(
|
||||
[&n, &cnt2]() {
|
||||
n.wait();
|
||||
cnt2++;
|
||||
piMSleep(2);
|
||||
},
|
||||
true);
|
||||
PIThread t3(
|
||||
[&n, &cnt3]() {
|
||||
n.notifyOnce();
|
||||
cnt3++;
|
||||
piMSleep(1);
|
||||
},
|
||||
true);
|
||||
piMSleep(20);
|
||||
t3.stop(true);
|
||||
piMSleep(100);
|
||||
t1.stop();
|
||||
t2.stop();
|
||||
ASSERT_EQ(cnt1+cnt2, cnt3);
|
||||
ASSERT_EQ(cnt1 + cnt2, cnt3);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user