runnable_ut.cc 379 B

12345678910111213141516171819202122
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include "gtest/gtest.h"
  4. #include "alibabacloud/core/Runnable.h"
  5. using namespace std;
  6. using namespace AlibabaCloud;
  7. static int nbr = 0;
  8. void foo() {
  9. nbr = 1;
  10. }
  11. // there should be no exception
  12. TEST(Runnable, basic) {
  13. std::function<void()> func(foo);
  14. Runnable f(func);
  15. EXPECT_TRUE(nbr == 0);
  16. f.run();
  17. EXPECT_TRUE(nbr == 1);
  18. }