mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Separated tests into different files, added ResetInstance() method to EventManager
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#include "icsneo/icsneocpp.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace icsneo;
|
||||
|
||||
class EventManagerTest : public ::testing::Test {
|
||||
protected:
|
||||
void TearDown() override {
|
||||
EventManager::ResetInstance();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(EventManagerTest, GetLastErrorTest) {
|
||||
EventManager::GetInstance().add(APIEvent(APIEvent::Type::OutputTruncated, APIEvent::Severity::Error));
|
||||
EXPECT_EQ(GetLastError().getType(), APIEvent::Type::OutputTruncated);
|
||||
auto err = GetLastError();
|
||||
EXPECT_EQ(err.getType(), APIEvent::Type::NoErrorFound);
|
||||
EXPECT_EQ(err.getSeverity(), APIEvent::Severity::EventInfo);
|
||||
}
|
||||
|
||||
TEST_F(EventManagerTest, CountTest) {
|
||||
EventManager::GetInstance().add(APIEvent(APIEvent::Type::OutputTruncated, APIEvent::Severity::Error));
|
||||
EXPECT_EQ(EventCount(), 0);
|
||||
EventManager::GetInstance().add(APIEvent(APIEvent::Type::OutputTruncated, APIEvent::Severity::EventWarning));
|
||||
EXPECT_EQ(EventCount(), 1);
|
||||
EventManager::GetInstance().add(APIEvent(APIEvent::Type::OutputTruncated, APIEvent::Severity::EventInfo));
|
||||
EXPECT_EQ(EventCount(), 2);
|
||||
GetEvents(EventFilter(APIEvent::Severity::EventInfo));
|
||||
EXPECT_EQ(EventCount(), 1);
|
||||
GetEvents();
|
||||
EXPECT_EQ(EventCount(), 0);
|
||||
}
|
||||
@@ -1,22 +1,5 @@
|
||||
#include "icsneo/api/eventmanager.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace icsneo;
|
||||
|
||||
class EventManagerTest : public ::testing::Test {
|
||||
|
||||
};
|
||||
|
||||
TEST_F(EventManagerTest, GetLastErrorTest) {
|
||||
EventManager::GetInstance().add(APIEvent(APIEvent::Type::OutputTruncated, APIEvent::Severity::Error));
|
||||
EXPECT_EQ(EventManager::GetInstance().getLastError().getType(), APIEvent::Type::OutputTruncated);
|
||||
}
|
||||
|
||||
TEST_F(EventManagerTest, CountTest) {
|
||||
EventManager::GetInstance().add(APIEvent(APIEvent::Type::OutputTruncated, APIEvent::Severity::Error));
|
||||
EXPECT_EQ(EventManager::GetInstance().count(), 1);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
||||
Reference in New Issue
Block a user