Kaynağa Gözat

test: scheduler - close #1257

skypjack 7 ay önce
ebeveyn
işleme
17e88e506c
2 değiştirilmiş dosya ile 14 ekleme ve 1 silme
  1. 0 1
      TODO
  2. 14 0
      test/entt/process/scheduler.cpp

+ 0 - 1
TODO

@@ -38,4 +38,3 @@ TODO:
 * avoid copying meta_type/data/func nodes
 * paged vector as a standalone class
 * operator bool to meta custom
-* test process and scheduler with allocators

+ 14 - 0
test/entt/process/scheduler.cpp

@@ -107,6 +107,20 @@ TEST(Scheduler, Swap) {
     ASSERT_EQ(counter, 2);
 }
 
+TEST(Scheduler, SharedFromThis) {
+    entt::scheduler scheduler{};
+    auto &process = scheduler.attach<succeeded_process>();
+    const auto &then = process.then<failed_process>();
+    auto other = process.shared_from_this();
+
+    ASSERT_TRUE(other);
+    ASSERT_NE(&process, &then);
+    ASSERT_EQ(&process, other.get());
+    ASSERT_EQ(process.get_allocator(), scheduler.get_allocator());
+    ASSERT_EQ(process.get_allocator(), other->get_allocator());
+    ASSERT_EQ(then.get_allocator(), scheduler.get_allocator());
+}
+
 TEST(Scheduler, AttachThen) {
     entt::scheduler scheduler{};
     std::pair<int, int> counter{};