2020-05-07 17:58:16 +00:00
|
|
|
//
|
|
|
|
// Created by lukas on 06.05.20.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <FileLogger.h>
|
|
|
|
#include <api/IPAPI.h>
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test if default ip is 0.0.0.0 when last ip file doesn't exist.
|
|
|
|
*/
|
|
|
|
TEST(ReadIp, testzeroIpIfNotExists) {
|
|
|
|
FileLogger logger;
|
|
|
|
std::string oldip = logger.readip();
|
|
|
|
ASSERT_EQ(oldip, "0.0.0.0");
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Test if default ip is 0.0.0.0 when last ip file doesn't exist.
|
|
|
|
*/
|
|
|
|
TEST(IPAPI, testIpAPIcheckIPSyntax) {
|
|
|
|
IPAPI ipapi;
|
|
|
|
std::string ip = ipapi.getGlobalIp();
|
2020-05-26 14:51:29 +00:00
|
|
|
if (ip.find('.') == SIZE_MAX) {
|
2020-05-07 17:58:16 +00:00
|
|
|
// error when ip doesn't contain a .
|
|
|
|
ASSERT_TRUE(false);
|
|
|
|
} else {
|
|
|
|
ASSERT_TRUE(true);
|
|
|
|
}
|
|
|
|
}
|