Sfoglia il codice sorgente

Replace namespace usages by dedicated using in event test module

Patrick-Christopher Mattulat 1 anno fa
parent
commit
dcab377860

+ 3 - 3
test/cases/event/EventHandlerTest.cpp

@@ -11,9 +11,9 @@
 #include <ls-std/ls-std-core.hpp>
 #include <ls-std/ls-std-event.hpp>
 
-using namespace ls::std::core;
-using namespace ls::std::event;
-using namespace ::testing;
+using ls::std::core::IllegalArgumentException;
+using ls::std::event::EventHandler;
+using testing::Test;
 
 namespace
 {

+ 15 - 6
test/cases/event/EventManagerTest.cpp

@@ -11,12 +11,21 @@
 #include <ls-std-event-test.hpp>
 #include <ls-std/ls-std-event.hpp>
 
-using namespace ls::std::core;
-using namespace ls::std::core::type;
-using namespace ls::std::event;
-using namespace ::std;
-using namespace test::event;
-using namespace ::testing;
+using ls::std::core::EventNotHandledException;
+using ls::std::core::EventNotSubscribedException;
+using ls::std::core::IllegalArgumentException;
+using ls::std::core::type::event_id;
+using ls::std::event::Event;
+using ls::std::event::EventHandler;
+using ls::std::event::EventManager;
+using std::make_shared;
+using std::shared_ptr;
+using std::string;
+using test::event::DailyNewsAgency;
+using test::event::GossipNewsAgency;
+using test::event::GossipNewsEvent;
+using test::event::SeriousNewsEvent;
+using testing::Test;
 
 namespace
 {

+ 4 - 4
test/cases/event/EventTest.cpp

@@ -11,10 +11,10 @@
 #include <ls-std/ls-std-core.hpp>
 #include <ls-std/ls-std-event.hpp>
 
-using namespace ls::std::core;
-using namespace ls::std::core::type;
-using namespace ls::std::event;
-using namespace ::testing;
+using ls::std::core::IllegalArgumentException;
+using ls::std::core::type::event_parameter;
+using ls::std::event::Event;
+using testing::Test;
 
 namespace
 {

+ 23 - 20
test/cases/event/NarratorTest.cpp

@@ -12,12 +12,15 @@
 #include <ls-std/ls-std-core.hpp>
 #include <ls-std/ls-std-event.hpp>
 
-using namespace ls::std::core;
-using namespace ls::std::core::interface_type;
-using namespace ls::std::event;
-using namespace ::std;
-using namespace test::event;
-using namespace ::testing;
+using ls::std::core::Class;
+using ls::std::core::IllegalArgumentException;
+using ls::std::core::interface_type::IListener;
+using ls::std::event::Narrator;
+using std::make_shared;
+using std::shared_ptr;
+using test::event::Colour;
+using test::event::TestDataMercedesCar;
+using testing::Test;
 
 namespace
 {
@@ -54,9 +57,9 @@ namespace
     this->createCars();
     Narrator paintingMachine{};
 
-    ASSERT_TRUE(paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes1)));
-    ASSERT_TRUE(paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes2)));
-    ASSERT_TRUE(paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes3)));
+    ASSERT_TRUE(paintingMachine.addListener(this->mercedes1));
+    ASSERT_TRUE(paintingMachine.addListener(this->mercedes2));
+    ASSERT_TRUE(paintingMachine.addListener(this->mercedes3));
   }
 
   TEST_F(NarratorTest, addListener_listener_already_exists)
@@ -64,8 +67,8 @@ namespace
     this->createCars();
     Narrator paintingMachine{};
 
-    ASSERT_TRUE(paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes1)));
-    ASSERT_FALSE(paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes1)));
+    ASSERT_TRUE(paintingMachine.addListener(this->mercedes1));
+    ASSERT_FALSE(paintingMachine.addListener(this->mercedes1));
   }
 
   TEST_F(NarratorTest, addListener_no_reference)
@@ -89,9 +92,9 @@ namespace
   {
     this->createCars();
     Narrator paintingMachine{};
-    paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes1));
-    paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes2));
-    paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes3));
+    paintingMachine.addListener(this->mercedes1);
+    paintingMachine.addListener(this->mercedes2);
+    paintingMachine.addListener(this->mercedes3);
 
     ASSERT_FALSE(paintingMachine.getListeners().empty());
     paintingMachine.clear();
@@ -108,9 +111,9 @@ namespace
   {
     this->createCars();
     Narrator paintingMachine{};
-    paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes1));
-    paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes2));
-    paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes3));
+    paintingMachine.addListener(this->mercedes1);
+    paintingMachine.addListener(this->mercedes2);
+    paintingMachine.addListener(this->mercedes3);
 
     ASSERT_TRUE(paintingMachine.removeListener(this->mercedes2));
     ASSERT_TRUE(paintingMachine.removeListener(this->mercedes1));
@@ -146,9 +149,9 @@ namespace
   {
     this->createCars();
     Narrator paintingMachine{};
-    paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes1));
-    paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes2));
-    paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes3));
+    paintingMachine.addListener(this->mercedes1);
+    paintingMachine.addListener(this->mercedes2);
+    paintingMachine.addListener(this->mercedes3);
 
     ASSERT_STREQ("pink", this->mercedes1->getColor().c_str());
     ASSERT_STREQ("blue", this->mercedes2->getColor().c_str());

+ 9 - 5
test/cases/event/serialization/SerializableJsonEventTest.cpp

@@ -11,11 +11,15 @@
 #include <ls-std/ls-std-core.hpp>
 #include <ls-std/ls-std-event.hpp>
 
-using namespace ls::std::core;
-using namespace ls::std::core::type;
-using namespace ls::std::event;
-using namespace ::std;
-using namespace ::testing;
+using ls::std::core::IllegalArgumentException;
+using ls::std::core::type::byte_field;
+using ls::std::core::type::event_parameter;
+using ls::std::core::type::event_parameter_list;
+using ls::std::event::Event;
+using ls::std::event::SerializableJsonEvent;
+using std::make_shared;
+using std::string;
+using testing::Test;
 
 namespace
 {