Skip to content
Snippets Groups Projects
Commit 5c5b866a authored by Sergey Yakubov's avatar Sergey Yakubov
Browse files

update source with google style

parent bb259832
No related branches found
No related tags found
No related merge requests found
......@@ -4,41 +4,40 @@
#include <cstdint>
#include "os.h"
namespace HIDRA2
{
enum OP_CODE : uint8_t {
OP_CODE__HELLO,
};
enum ERROR_CODE : uint16_t {
ERR__NO_ERROR,
ERR__UNSUPPORTED_VERSION,
ERR__INTERNAL_SERVER_ERROR = 65535,
};
struct NetworkRequest {
OP_CODE op_code;
uint64_t request_id;
char data[];
};
struct NetworkResponse {
OP_CODE op_code;
uint64_t request_id;
ERROR_CODE error_code;
char data[];
};
struct OP_HelloRequest {
uint32_t client_version;
OS_TYPE os : 4;
bool is_x64 : 1;
};
struct OP_HelloResponse {
uint32_t server_version;
};
namespace HIDRA2 {
enum OP_CODE : uint8_t {
OP_CODE__HELLO,
};
enum ERROR_CODE : uint16_t {
ERR__NO_ERROR,
ERR__UNSUPPORTED_VERSION,
ERR__INTERNAL_SERVER_ERROR = 65535,
};
struct NetworkRequest {
OP_CODE op_code;
uint64_t request_id;
char data[];
};
struct NetworkResponse {
OP_CODE op_code;
uint64_t request_id;
ERROR_CODE error_code;
char data[];
};
struct OP_HelloRequest {
uint32_t client_version;
OS_TYPE os : 4;
bool is_x64 : 1;
};
struct OP_HelloResponse {
uint32_t server_version;
};
}
#endif //HIDRA2__COMMON_NETWORKING_H
......@@ -3,15 +3,14 @@
#include <cstdint>
namespace HIDRA2
{
enum OS_TYPE : uint8_t {
OS_UNKOWN,
OS_LINUX,
OS_WINDOWS,
namespace HIDRA2 {
enum OS_TYPE : uint8_t {
OS_UNKOWN,
OS_LINUX,
OS_WINDOWS,
OS_INVALID = 16, /* Never use more then 4 bit */
};
OS_INVALID = 16, /* Never use more then 4 bit */
};
}
#endif //HIDRA2__COMMON_OS_H
#include <gtest/gtest.h>
TEST(EMPTY, REMOVEME)
{
EXPECT_EQ(1, 1);
TEST(EMPTY, REMOVEME) {
EXPECT_EQ(1, 1);
}
......@@ -3,21 +3,19 @@
#include <string>
namespace HIDRA2
{
class Producer
{
private:
static unsigned long kinit_count_;
Producer();
public:
static const uint32_t VERSION;
namespace HIDRA2 {
class Producer {
private:
static unsigned long kinit_count_;
Producer();
public:
static const uint32_t VERSION;
Producer(const Producer&) = delete;
Producer& operator=(const Producer&) = delete;
Producer(const Producer&) = delete;
Producer& operator=(const Producer&) = delete;
static Producer* CreateProducer(std::string receiver_address);
};
static Producer* CreateProducer(std::string receiver_address);
};
}
#endif //HIDRA2__PRODUCER_PRODUCER_H
......@@ -3,12 +3,10 @@
unsigned long HIDRA2::Producer::kinit_count_ = 0;
const uint32_t HIDRA2::Producer::VERSION = 1;
HIDRA2::Producer::Producer()
{
kinit_count_++;
HIDRA2::Producer::Producer() {
kinit_count_++;
}
HIDRA2::Producer *HIDRA2::Producer::CreateProducer(std::string receiver_address)
{
return new Producer();
HIDRA2::Producer *HIDRA2::Producer::CreateProducer(std::string receiver_address) {
return new Producer();
}
#include <gtest/gtest.h>
#include <producer/producer.h>
namespace
{
TEST(VERSION, VersionAboveZero)
{
EXPECT_GE(HIDRA2::Producer::VERSION, 0);
}
namespace {
TEST(VERSION, VersionAboveZero) {
EXPECT_GE(HIDRA2::Producer::VERSION, 0);
}
TEST(CreateProducer, PointerIsNotNullptr)
{
HIDRA2::Producer* prod = HIDRA2::Producer::CreateProducer("127.0.0.1");
EXPECT_NE(prod, nullptr);
}
TEST(CreateProducer, PointerIsNotNullptr) {
HIDRA2::Producer* prod = HIDRA2::Producer::CreateProducer("127.0.0.1");
EXPECT_NE(prod, nullptr);
}
}
#include <producer/producer.h>
#include <iostream>
int main (int argc, char* argv[])
{
std::cout << "Running producer version: " << HIDRA2::Producer::VERSION << std::endl;
int main (int argc, char* argv[]) {
std::cout << "Running producer version: " << HIDRA2::Producer::VERSION << std::endl;
HIDRA2::Producer* producer = HIDRA2::Producer::CreateProducer("127.0.0.1");
if(!producer) {
std::cerr << "Fail to create producer" << std::endl;
return 1;
}
HIDRA2::Producer* producer = HIDRA2::Producer::CreateProducer("127.0.0.1");
if(!producer) {
std::cerr << "Fail to create producer" << std::endl;
return 1;
}
std::cout << "Successfully create producer " << std::hex << producer << std::endl;
std::cout << "Successfully create producer " << std::hex << producer << std::endl;
return 0;
return 0;
}
#include <gtest/gtest.h>
TEST(EMPTY, REMOVEME)
{
EXPECT_EQ(1, 1);
TEST(EMPTY, REMOVEME) {
EXPECT_EQ(1, 1);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment