-
Notifications
You must be signed in to change notification settings - Fork 13
/
KrakenBattleTest.cpp
63 lines (44 loc) · 2.29 KB
/
KrakenBattleTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* File: KrakenBattleTest.cpp
* Author: Kjell Hedstrom
*
* Created on February 9, 2015
*/
#include "KrakenBattleTest.h"
#include "Kraken.h"
#include "KrakenBattle.h"
#include "Harpoon.h"
#include "KrakenIntegrationHelper.h"
using namespace KrakenIntegrationHelper;
namespace {
const std::string gUuid = "734a83c7-9435-4605-b1f9-4724c81faf21";
const std::string gEmptyUuid = "00000000-0000-0000-0000-000000000000";
const Kraken::Chunks gEmptyData = {};
const Kraken::Chunks gData = {1, 2, 128, 'k', 'j', '2', '1'};
}
TEST_F(KrakenBattleTest, MergeDataTypes_ErrorType) {
auto failed = MergeData("123", KrakenBattle::SendType::Error, gEmptyData, "bad stuff");
std::vector<uint8_t> expected {'1', '2', '3', '<', 'E', 'R', 'R', 'O', 'R', '>', 'b', 'a', 'd', ' ', 's', 't', 'u', 'f', 'f'};
EXPECT_TRUE((failed == expected)) << "\nfailed: [" << vectorToString(failed) << "]\nexpected: [" << vectorToString(expected) << "]";
}
TEST_F(KrakenBattleTest, MergeDataTypes_DataType) {
auto send = MergeData("321", KrakenBattle::SendType::Data, gData, "ignored");
std::vector<uint8_t> expected {'3', '2', '1', '<', 'D', 'A', 'T', 'A', '>', 1, 2, 128, 'k', 'j', '2', '1'};
EXPECT_TRUE((send == expected)) << "\nfailed: [" << vectorToString(send) << "]\nexpected: [" << vectorToString(expected) << "]";
}
TEST_F(KrakenBattleTest, MergeDataTypes_DoneType) {
auto send = MergeData(gUuid, KrakenBattle::SendType::Done, gData, "ignored");
std::string sendStatus = "<DONE>";
std::vector<uint8_t> expected;
std::copy(gUuid.begin(), gUuid.end(), std::back_inserter(expected));
std::copy(sendStatus.begin(), sendStatus.end(), std::back_inserter(expected));
EXPECT_TRUE((send == expected)) << "\nfailed: [" << vectorToString(send) << "]\nexpected: [" << vectorToString(expected) << "]";
}
TEST_F(KrakenBattleTest, MergeDataTypes_EndType) {
auto send = MergeData("ignored_uuid", KrakenBattle::SendType::End, gData, "ignored");
std::string sendStatus = "<END>";
std::vector<uint8_t> expected;
std::copy(gEmptyUuid.begin(), gEmptyUuid.end(), std::back_inserter(expected));
std::copy(sendStatus.begin(), sendStatus.end(), std::back_inserter(expected));
EXPECT_TRUE((send == expected)) << "\nfailed: [" << vectorToString(send) << "]\nexpected: [" << vectorToString(expected) << "]";
}