formatted file using clang-format with _haiku-format formatting options
Change-Id: Iac91219ac10be70bc5b4ae2ffc0d4e44893d8a44 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3864 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
parent
8f5700bc46
commit
5685473e0c
@ -1,58 +1,69 @@
|
|||||||
#include "ExampleTest.h"
|
#include "ExampleTest.h"
|
||||||
|
|
||||||
|
#include <TestUtils.h>
|
||||||
#include <ThreadedTestCaller.h>
|
#include <ThreadedTestCaller.h>
|
||||||
#include <cppunit/Test.h>
|
#include <cppunit/Test.h>
|
||||||
#include <cppunit/TestCaller.h>
|
#include <cppunit/TestCaller.h>
|
||||||
#include <cppunit/TestSuite.h>
|
#include <cppunit/TestSuite.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <kernel/OS.h>
|
#include <kernel/OS.h>
|
||||||
#include <TestUtils.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
ExampleTest::ExampleTest(std::string name)
|
ExampleTest::ExampleTest(std::string name)
|
||||||
: BThreadedTestCase(name)
|
: BThreadedTestCase(name), fLocker(new BLocker())
|
||||||
, fLocker(new BLocker())
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CppUnit::Test*
|
CppUnit::Test*
|
||||||
ExampleTest::Suite() {
|
ExampleTest::Suite()
|
||||||
|
{
|
||||||
CppUnit::TestSuite* suite = new CppUnit::TestSuite("Yo");
|
CppUnit::TestSuite* suite = new CppUnit::TestSuite("Yo");
|
||||||
BThreadedTestCaller<ExampleTest>* caller;
|
BThreadedTestCaller<ExampleTest>* caller;
|
||||||
|
|
||||||
// Add a multithreaded test
|
// Add a multithreaded test
|
||||||
ExampleTest *test = new ExampleTest("This name is never used, just so you know :-)");
|
ExampleTest* test
|
||||||
caller = new BThreadedTestCaller<ExampleTest>("ExampleTests::MultiThreaded Test #1", test);
|
= new ExampleTest("This name is never used, just so you know :-)");
|
||||||
|
caller = new BThreadedTestCaller<ExampleTest>(
|
||||||
|
"ExampleTests::MultiThreaded Test #1", test);
|
||||||
caller->addThread("A", &ExampleTest::TestFunc1);
|
caller->addThread("A", &ExampleTest::TestFunc1);
|
||||||
caller->addThread("B", &ExampleTest::TestFunc2);
|
caller->addThread("B", &ExampleTest::TestFunc2);
|
||||||
caller->addThread("C", &ExampleTest::TestFunc3);
|
caller->addThread("C", &ExampleTest::TestFunc3);
|
||||||
suite->addTest(caller);
|
suite->addTest(caller);
|
||||||
|
|
||||||
// And another
|
// And another
|
||||||
caller = new BThreadedTestCaller<ExampleTest>("ExampleTests::MultiThreaded Test #2");
|
caller = new BThreadedTestCaller<ExampleTest>(
|
||||||
|
"ExampleTests::MultiThreaded Test #2");
|
||||||
caller->addThread("Thread1", &ExampleTest::TestFunc1);
|
caller->addThread("Thread1", &ExampleTest::TestFunc1);
|
||||||
caller->addThread("Thread2", &ExampleTest::TestFunc1);
|
caller->addThread("Thread2", &ExampleTest::TestFunc1);
|
||||||
caller->addThread("Thread3", &ExampleTest::TestFunc1);
|
caller->addThread("Thread3", &ExampleTest::TestFunc1);
|
||||||
suite->addTest(caller);
|
suite->addTest(caller);
|
||||||
|
|
||||||
// And one that fails, if you're so inclined
|
// And one that fails, if you're so inclined
|
||||||
caller = new BThreadedTestCaller<ExampleTest>("ExampleTests::MultiThreaded Failing Test");
|
caller = new BThreadedTestCaller<ExampleTest>(
|
||||||
|
"ExampleTests::MultiThreaded Failing Test");
|
||||||
caller->addThread("GoodThread1", &ExampleTest::TestFunc1);
|
caller->addThread("GoodThread1", &ExampleTest::TestFunc1);
|
||||||
caller->addThread("GoodThread2", &ExampleTest::TestFunc2);
|
caller->addThread("GoodThread2", &ExampleTest::TestFunc2);
|
||||||
caller->addThread("BadThread", &ExampleTest::FailureFunc);
|
caller->addThread("BadThread", &ExampleTest::FailureFunc);
|
||||||
suite->addTest(caller);
|
suite->addTest(caller);
|
||||||
|
|
||||||
// And some single threaded ones
|
// And some single threaded ones
|
||||||
suite->addTest(new CppUnit::TestCaller<ExampleTest>("ExampleTests::SingleThreaded Test #1", &ExampleTest::TestFunc1));
|
suite->addTest(new CppUnit::TestCaller<ExampleTest>(
|
||||||
suite->addTest(new CppUnit::TestCaller<ExampleTest>("ExampleTests::SingleThreaded Test #2", &ExampleTest::TestFunc2));
|
"ExampleTests::SingleThreaded Test #1", &ExampleTest::TestFunc1));
|
||||||
|
suite->addTest(new CppUnit::TestCaller<ExampleTest>(
|
||||||
|
"ExampleTests::SingleThreaded Test #2", &ExampleTest::TestFunc2));
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const int sleeptime = 10000;
|
const int sleeptime = 10000;
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ExampleTest::TestFunc1() {
|
ExampleTest::TestFunc1()
|
||||||
|
{
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
// Get the lock and do our business
|
// Get the lock and do our business
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
@ -64,8 +75,10 @@ ExampleTest::TestFunc1() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ExampleTest::TestFunc2() {
|
ExampleTest::TestFunc2()
|
||||||
|
{
|
||||||
for (int i = 0; i < 13; i++) {
|
for (int i = 0; i < 13; i++) {
|
||||||
// Get the lock and do our business
|
// Get the lock and do our business
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
@ -77,8 +90,10 @@ ExampleTest::TestFunc2() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ExampleTest::TestFunc3() {
|
ExampleTest::TestFunc3()
|
||||||
|
{
|
||||||
for (int i = 0; i < 15; i++) {
|
for (int i = 0; i < 15; i++) {
|
||||||
// Get the lock and do our business
|
// Get the lock and do our business
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
@ -90,8 +105,9 @@ ExampleTest::TestFunc3() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ExampleTest::FailureFunc() {
|
ExampleTest::FailureFunc()
|
||||||
|
{
|
||||||
CHK(true == false);
|
CHK(true == false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user