40#include <gtest/gtest.h>
42#include <initializer_list>
57 class StartingFiber :
public Fiber
66 ASSERT_FALSE(fiber.started());
70 ASSERT_TRUE(fiber.started());
101 const char *
name, std::initializer_list<Fiber *>
l) :
110 EXPECT_EQ(
e,
this) <<
"Expected " <<
e->
name <<
", got " <<
name;
117 for (
auto &
n :
next) {
136 EXPECT_FALSE(
a.finished());
137 EXPECT_FALSE(
b.finished());
138 EXPECT_FALSE(
c.finished());
142 "Didn't exactly use up the expected Fiber sequence";
144 EXPECT_TRUE(
c.finished());
LinkedFiber(Fiber *link, int index)
void main()
This method is called when this fiber is first run.
std::vector< Fiber * > next
void main()
This method is called when this fiber is first run.
SwitchingFiber(const char *name, std::initializer_list< Fiber * > l)
This class represents a fiber, which is a light weight sort of thread which is cooperatively schedule...
virtual void main()=0
This method is called when this fiber is first run.
TEST(Fiber, Starting)
This test is checking if the "started" member has its expected value before and after the fiber runs.
std::vector< SwitchingFiber * >::iterator expectedIt
std::vector< SwitchingFiber * > expected({ &a, &b, &a, &a, &a, &b, &c, &a, &c, &c, &c })
static Fiber * primaryFiber()
Get a pointer to the primary Fiber.
Fiber(size_t stack_size=DefaultStackSize)
void run()
Start executing the fiber represented by this object.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
const std::string & name()