43 #include <gtest/gtest.h> 45 #include <initializer_list> 58 class StartingFiber :
public Fiber 67 ASSERT_FALSE(fiber.started());
71 ASSERT_TRUE(fiber.started());
102 const char *
name, std::initializer_list<Fiber *>
l) :
109 ASSERT_NE(expectedIt,
expected.end());
111 EXPECT_EQ(e,
this) <<
"Expected " << e->name <<
", got " <<
name;
118 for (
auto &
n :
next) {
143 "Didn't exactly use up the expected Fiber sequence";
void run()
Start executing the fiber represented by this object.
bool finished() const
Returns whether the "main" function of this fiber has finished.
std::vector< SwitchingFiber * >::iterator expectedIt
const std::string & name()
static Fiber * primaryFiber()
Get a pointer to the primary Fiber.
std::vector< Fiber * > next
int main(int argc, char **argv)
SwitchingFiber(const char *name, std::initializer_list< Fiber *> l)
#define EXPECT_TRUE(expr)
A macro which verifies that expr evaluates to true.
std::vector< SwitchingFiber * > expected({ &a, &b, &a, &a, &a, &b, &c, &a, &c, &c, &c })
void main()
This method is called when this fiber is first run.
#define EXPECT_FALSE(expr)
A macro which verifies that expr evaluates to false.
This class represents a fiber, which is a light weight sort of thread which is cooperatively schedule...
void main()
This method is called when this fiber is first run.
Fiber(size_t stack_size=DefaultStackSize)
stack_size is the size of the stack available to this fiber.
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...
#define EXPECT_EQ(lhs, rhs)
A macro which verifies that lhs and rhs are equal to each other.
LinkedFiber(Fiber *link, int index)