Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
karrin0chka committed May 3, 2024
1 parent 5a0c26f commit c944b09
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 36 deletions.
52 changes: 26 additions & 26 deletions include/TimedDoor.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,44 @@ class Door;
class TimedDoor;

class TimerClient {
public:
virtual void Timeout() = 0;
public:
virtual void Timeout() = 0;
};

class Door {
public:
virtual void lock() = 0;
virtual void unlock() = 0;
virtual bool isDoorOpened() = 0;
public:
virtual void lock() = 0;
virtual void unlock() = 0;
virtual bool isDoorOpened() = 0;
};

class DoorTimerAdapter : public TimerClient {
private:
TimedDoor& door;
public:
explicit DoorTimerAdapter(TimedDoor&);
void Timeout();
private:
TimedDoor& door;
public:
explicit DoorTimerAdapter(TimedDoor&);
void Timeout();
};

class TimedDoor : public Door {
private:
DoorTimerAdapter* adapter;
int iTimeout;
bool isOpened;
public:
explicit TimedDoor(int);
bool isDoorOpened();
void unlock();
void lock();
int getTimeOut() const;
void throwState();
private:
DoorTimerAdapter* adapter;
int iTimeout;
bool isOpened;
public:
explicit TimedDoor(int);
bool isDoorOpened();
void unlock();
void lock();
int getTimeOut() const;
void throwState();
};

class Timer {
TimerClient* client;
void sleep(int);
public:
void tregister(int, TimerClient*);
TimerClient* client;
void sleep(int);
public:
void tregister(int, TimerClient*);
};

#endif // INCLUDE_TIMEDDOOR_H_
7 changes: 3 additions & 4 deletions src/TimedDoor.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2024 Tushentsova Karina

#include <stdexcept>
#include <thread>
#include <chrono>
#include <thread> // NOLINT [build/c++11]
#include <chrono> // NOLINT [build/c++11]

#include "TimedDoor.h"

Expand Down Expand Up @@ -54,8 +54,7 @@ int TimedDoor::getTimeOut() const {
void TimedDoor::throwState() {
if (isOpened) {
throw std::runtime_error("Door is opened!");
}
else {
} else {
throw std::runtime_error("Door is closed!");
}
}
12 changes: 6 additions & 6 deletions test/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <cstdint>
#include <thread>
#include <chrono>
#include <thread> // NOLINT [build/c++11]
#include <chrono> // NOLINT [build/c++11]

#include "TimedDoor.h"

class MockTimerClient : public TimerClient {
public:
public:
MOCK_METHOD(void, Timeout, (), (override));
};

class TimedDoorTest : public ::testing::Test {
protected:
protected:
TimedDoor door;
MockTimerClient* mockClient;
Timer timer;
public:
public:
TimedDoorTest() : door(1), timer() {}
protected:
protected:
void SetUp() override {
mockClient = new MockTimerClient();
}
Expand Down

0 comments on commit c944b09

Please sign in to comment.