@@ -219,7 +219,7 @@ TEST_F(EventManagerSpec, ConcurrentPublishing)
219219
220220TEST_F (EventManagerSpec, ConcurrentSubscribeAndPublish)
221221{
222- constexpr int kDuration = 100 ; // milliseconds
222+ constexpr int kDuration = 100 ;
223223 std::atomic<bool > running { true };
224224 std::atomic<int > publishCount { 0 };
225225 std::atomic<int > receiveCount { 0 };
@@ -296,12 +296,12 @@ TEST_F(EventManagerSpec, ConcurrentUnsubscribe)
296296 }
297297
298298 manager.Send (SimpleEvent { .value = 1 });
299- EXPECT_EQ (count.load (), 0 ); // All unsubscribed
299+ EXPECT_EQ (count.load (), 0 );
300300}
301301
302302TEST_F (EventManagerSpec, ConcurrentMixedOperations)
303303{
304- constexpr int kDuration = 200 ; // milliseconds
304+ constexpr int kDuration = 200 ;
305305 std::atomic<bool > running { true };
306306 std::atomic<int > eventCount { 0 };
307307 std::vector<Ref<fr::ListenerHandle>> handles;
@@ -314,18 +314,18 @@ TEST_F(EventManagerSpec, ConcurrentMixedOperations)
314314 {
315315 int op = threadId % 3 ;
316316
317- if (op == 0 ) // Subscribe
317+ if (op == 0 )
318318 {
319319 auto handle = manager.Subscribe <SimpleEvent>([&eventCount](const SimpleEvent&) {
320320 eventCount.fetch_add (1 , std::memory_order_relaxed);
321321 });
322322 localHandles.push_back (handle);
323323 }
324- else if (op == 1 ) // Publish
324+ else if (op == 1 )
325325 {
326326 manager.Send (SimpleEvent { .value = threadId });
327327 }
328- else // Unsubscribe
328+ else
329329 {
330330 if (!localHandles.empty ())
331331 {
@@ -352,14 +352,9 @@ TEST_F(EventManagerSpec, ConcurrentMixedOperations)
352352 thread.join ();
353353 }
354354
355- // Just verify no crashes occurred
356355 EXPECT_GE (eventCount.load (), 0 );
357356}
358357
359- // ============================================================================
360- // Performance and Cache Efficiency Tests
361- // ============================================================================
362-
363358TEST_F (EventManagerSpec, ManyListenersPerformance)
364359{
365360 constexpr int kListenerCount = 1000 ;
@@ -380,7 +375,7 @@ TEST_F(EventManagerSpec, ManyListenersPerformance)
380375 auto duration = std::chrono::duration_cast<std::chrono::microseconds>(end - start);
381376
382377 EXPECT_EQ (count.load (), kListenerCount );
383- EXPECT_LT (duration.count (), 10000 ); // Should complete in less than 10ms
378+ EXPECT_LT (duration.count (), 10000 );
384379}
385380
386381TEST_F (EventManagerSpec, ManyEventsPerformance)
@@ -401,7 +396,7 @@ TEST_F(EventManagerSpec, ManyEventsPerformance)
401396 auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
402397
403398 EXPECT_EQ (count.load (), kEventCount );
404- EXPECT_LT (duration.count (), 1000 ); // Should complete in less than 1 second
399+ EXPECT_LT (duration.count (), 1000 );
405400}
406401
407402TEST_F (EventManagerSpec, CleanupRemovesInactiveListeners)
@@ -509,21 +504,16 @@ TEST_F(EventManagerSpec, SubscribeInCallback)
509504
510505 auto handle = manager.Subscribe <SimpleEvent>([&](const SimpleEvent&) {
511506 count++;
512- // Subscribe another listener during callback
513507 callBackHandle = manager.Subscribe <SimpleEvent>([&](const SimpleEvent&) { count++; });
514508 });
515509
516510 manager.Send (SimpleEvent { .value = 1 });
517- EXPECT_EQ (count.load (), 1 ); // New listener should not be called yet
511+ EXPECT_EQ (count.load (), 1 );
518512
519513 manager.Send (SimpleEvent { .value = 2 });
520- EXPECT_GE (count.load (), 2 ); // Now both should be called
514+ EXPECT_GE (count.load (), 2 );
521515}
522516
523- // ============================================================================
524- // Stress Tests
525- // ============================================================================
526-
527517TEST_F (EventManagerSpec, StressTestManyEventsAndListeners)
528518{
529519 constexpr int kEventTypeCount = 50 ;
@@ -565,7 +555,6 @@ TEST_F(EventManagerSpec, StressTestConcurrentAllOperations)
565555
566556 while (running.load (std::memory_order_acquire))
567557 {
568- // Subscribe
569558 if (handles.size () < 20 )
570559 {
571560 auto handle = manager.Subscribe <SimpleEvent>([&eventCount](const SimpleEvent&) {
@@ -575,11 +564,9 @@ TEST_F(EventManagerSpec, StressTestConcurrentAllOperations)
575564 subscribeCount.fetch_add (1 , std::memory_order_relaxed);
576565 }
577566
578- // Publish
579567 manager.Send (SimpleEvent { .value = 1 });
580568 publishCount.fetch_add (1 , std::memory_order_relaxed);
581569
582- // Unsubscribe
583570 if (!handles.empty () && (rand () % 10 ) < 3 )
584571 {
585572 handles.back ().reset ();
@@ -605,11 +592,6 @@ TEST_F(EventManagerSpec, StressTestConcurrentAllOperations)
605592 thread.join ();
606593 }
607594
608- std::cout << " Subscribe count: " << subscribeCount.load () << std::endl;
609- std::cout << " Publish count: " << publishCount.load () << std::endl;
610- std::cout << " Unsubscribe count: " << unsubscribeCount.load () << std::endl;
611- std::cout << " Event count: " << eventCount.load () << std::endl;
612-
613595 EXPECT_GT (subscribeCount.load (), 0 );
614596 EXPECT_GT (publishCount.load (), 0 );
615597 EXPECT_GT (eventCount.load (), 0 );
0 commit comments