mirror of
https://github.com/Naios/continuable.git
synced 2025-12-07 17:26:47 +08:00
some more tests
This commit is contained in:
parent
3878f49b6f
commit
9d56e301d5
@ -63,8 +63,25 @@ fluent_step make_waterfall()
|
||||
}
|
||||
|
||||
|
||||
struct Continueable
|
||||
{
|
||||
template <typename Callback>
|
||||
Continueable then(Callback&& callback)
|
||||
{
|
||||
return Continueable();
|
||||
}
|
||||
|
||||
template <typename Container>
|
||||
Continueable weak(Container& container)
|
||||
{
|
||||
return Continueable();
|
||||
}
|
||||
|
||||
Continueable strong()
|
||||
{
|
||||
return Continueable();
|
||||
}
|
||||
};
|
||||
|
||||
void do_export();
|
||||
|
||||
|
||||
44
test.cpp
44
test.cpp
@ -7,6 +7,22 @@
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
||||
Continueable CastSpell(int id)
|
||||
{
|
||||
std::cout << "Cast " << id << std::endl;
|
||||
|
||||
// on success call true
|
||||
return Continueable();
|
||||
}
|
||||
|
||||
Continueable MoveTo(int point)
|
||||
{
|
||||
std::cout << "Move to point " << point << std::endl;
|
||||
|
||||
// on success call true
|
||||
return Continueable();
|
||||
}
|
||||
|
||||
void CastSpell(int id, Callback<bool> const& callback)
|
||||
{
|
||||
std::cout << "Cast " << id << std::endl;
|
||||
@ -26,7 +42,7 @@ void MoveTo(int point, Callback<bool> const& callback)
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
make_waterfall<Callback<bool>>()
|
||||
.then(std::bind(&CastSpell, 71382, std::placeholders::_1))
|
||||
// .then(std::bind(&CastSpell, 71382, std::placeholders::_1))
|
||||
.then([](bool success, Callback<bool> const& callback)
|
||||
{
|
||||
MoveTo(1, callback);
|
||||
@ -37,6 +53,14 @@ int main(int argc, char** argv)
|
||||
std::cout << "finish everything" << std::endl;
|
||||
});
|
||||
|
||||
|
||||
|
||||
auto cabt = []()
|
||||
{
|
||||
// Do something
|
||||
return MoveTo(2);
|
||||
};
|
||||
|
||||
typedef Callback<bool> cbd1;
|
||||
typedef WeakCallback<int> cbd2;
|
||||
typedef SharedCallback<std::string> cbd3;
|
||||
@ -55,6 +79,24 @@ int main(int argc, char** argv)
|
||||
{
|
||||
WeakCallbackContainer callback;
|
||||
|
||||
// Some tests
|
||||
CastSpell(22872)
|
||||
.weak(callback)
|
||||
.then([](bool success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
// do something
|
||||
}
|
||||
|
||||
// Do something
|
||||
/*return*/ MoveTo(2);
|
||||
})
|
||||
.then([]
|
||||
{
|
||||
|
||||
});
|
||||
|
||||
std::shared_ptr<int> dealloc_test(new int{2}, [](int* me)
|
||||
{
|
||||
std::cout << "dealloc ok" << std::endl;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user