115 lines
3.0 KiB
C++
115 lines
3.0 KiB
C++
#if GTEST
|
|
|
|
// #include <gmock/gmock.h>
|
|
// not supported using Visual Studio 2022 compiler...
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <chrono>
|
|
#include <thread>
|
|
// #include <ws2tcpip.h>
|
|
|
|
#include "Participant.h"
|
|
#include "SiteServer.h"
|
|
#include "Thing.h"
|
|
|
|
using namespace RoboidControl;
|
|
|
|
// Function to get the current time in milliseconds as unsigned long
|
|
unsigned long get_time_ms() {
|
|
auto now = std::chrono::steady_clock::now();
|
|
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
|
|
now.time_since_epoch());
|
|
return static_cast<unsigned long>(ms.count());
|
|
}
|
|
|
|
// class RoboidControlSuite : public ::testing::test {
|
|
// TEST_F(RoboidControlSuite, HiddenParticipant) {
|
|
// Thing thing = Thing();
|
|
|
|
// unsigned long milliseconds = get_time_ms();
|
|
// unsigned long startTime = milliseconds;
|
|
// while (milliseconds < startTime + 1000) {
|
|
// Thing.Update(milliseconds);
|
|
|
|
// milliseconds = get_time_ms();
|
|
// }
|
|
// ASSERT_EQ(1, 1);
|
|
// }
|
|
// }
|
|
|
|
class ParticipantSuite : public ::testing::Test {
|
|
protected:
|
|
// SetUp and TearDown can be used to set up and clean up before/after each
|
|
// test
|
|
void SetUp() override {
|
|
// Initialize test data here
|
|
}
|
|
|
|
void TearDown() override {
|
|
// Clean up test data here
|
|
}
|
|
};
|
|
|
|
|
|
|
|
// TEST_F(ParticipantSuite, LocalParticipant) {
|
|
// LocalParticipant* participant = new LocalParticipant("127.0.0.1", 7681);
|
|
|
|
// unsigned long milliseconds = get_time_ms();
|
|
// unsigned long startTime = milliseconds;
|
|
// while (milliseconds < startTime + 1000) {
|
|
// participant->Update(milliseconds);
|
|
|
|
// milliseconds = get_time_ms();
|
|
// }
|
|
// ASSERT_EQ(1, 1);
|
|
// }
|
|
|
|
// TEST_F(ParticipantSuite, SiteServer) {
|
|
// SiteServer site = SiteServer(7681);
|
|
|
|
// unsigned long milliseconds = get_time_ms();
|
|
// unsigned long startTime = milliseconds;
|
|
// while (milliseconds < startTime + 1000) {
|
|
// site.Update(milliseconds);
|
|
|
|
// milliseconds = get_time_ms();
|
|
// }
|
|
// ASSERT_EQ(1, 1);
|
|
// }
|
|
|
|
// TEST_F(ParticipantSuite, SiteParticipant) {
|
|
// SiteServer site = SiteServer(7681);
|
|
// LocalParticipant participant = LocalParticipant("127.0.0.1", 7681);
|
|
|
|
// unsigned long milliseconds = get_time_ms();
|
|
// unsigned long startTime = milliseconds;
|
|
// while (milliseconds < startTime + 1000) {
|
|
// site.Update(milliseconds);
|
|
// participant.Update(milliseconds);
|
|
|
|
// std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
// milliseconds = get_time_ms();
|
|
// }
|
|
// ASSERT_EQ(1, 1);
|
|
// }
|
|
|
|
// TEST_F(ParticipantSuite, Thing) {
|
|
// SiteServer site = SiteServer(7681);
|
|
// LocalParticipant participant = LocalParticipant("127.0.0.1", 7681);
|
|
// Thing thing = Thing(&participant);
|
|
|
|
// unsigned long milliseconds = get_time_ms();
|
|
// unsigned long startTime = milliseconds;
|
|
// while (milliseconds < startTime + 1000) {
|
|
// site.Update(milliseconds);
|
|
// participant.Update(milliseconds);
|
|
|
|
// std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
// milliseconds = get_time_ms();
|
|
// }
|
|
// ASSERT_EQ(1, 1);
|
|
// }
|
|
|
|
#endif
|