Doomseeker
Wadseeker
Download
Tracker
Git
Docs
Main Page
Plugin API
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Groups
Pages
src
core
tests
testplayer.cpp
1
//------------------------------------------------------------------------------
2
// testplayer.cpp
3
//------------------------------------------------------------------------------
4
//
5
// This library is free software; you can redistribute it and/or
6
// modify it under the terms of the GNU Lesser General Public
7
// License as published by the Free Software Foundation; either
8
// version 2.1 of the License, or (at your option) any later version.
9
//
10
// This library is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
// Lesser General Public License for more details.
14
//
15
// You should have received a copy of the GNU Lesser General Public
16
// License along with this library; if not, write to the Free Software
17
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
// 02110-1301 USA
19
//
20
//------------------------------------------------------------------------------
21
// Copyright (C) 2018 "Zalewa" <zalewapl@gmail.com>
22
//------------------------------------------------------------------------------
23
#include "testplayer.h"
24
25
#include "serverapi/player.h"
26
27
static
Player
mkPlayer(QString name)
28
{
29
return
Player
(name, 0, 0);
30
}
31
32
bool
TestPlayerNameColorStrip::executeTest()
33
{
34
{
35
// Plain.
36
Player
player = mkPlayer(
"Simple Joe '89"
);
37
if
(player.
nameColorTagsStripped
() !=
"Simple Joe '89"
)
38
{
39
testLog <<
"Plain player name changed after strip: "
<< player.
nameColorTagsStripped
();
40
return
false
;
41
}
42
}
43
44
{
45
// Predefined color.
46
Player
player = mkPlayer(
"[PRO] \034gHunter \034fKiller [PRO]"
);
47
if
(player.
nameColorTagsStripped
() !=
"[PRO] Hunter Killer [PRO]"
)
48
{
49
testLog <<
"Failed to strip predefined color codes: "
<< player.
nameColorTagsStripped
();
50
return
false
;
51
}
52
}
53
54
{
55
// Predefined color at end.
56
Player
player = mkPlayer(
"Haxxor\034"
);
57
if
(player.
nameColorTagsStripped
() !=
"Haxxor"
)
58
{
59
testLog <<
"Failed to handle invalid color code at end: "
<< player.
nameColorTagsStripped
();
60
return
false
;
61
}
62
}
63
64
{
65
// PWAD colors.
66
Player
player = mkPlayer(
"\034[e]Emmet \034[Brown]McFly\034[aqua]"
);
67
if
(player.
nameColorTagsStripped
() !=
"Emmet McFly"
)
68
{
69
testLog <<
"Failed to strip PWAD color codes: "
<< player.
nameColorTagsStripped
();
70
return
false
;
71
}
72
}
73
74
{
75
// PWAD color unclosed.
76
Player
player = mkPlayer(
"\034[eEmmet"
);
77
if
(player.
nameColorTagsStripped
() !=
"eEmmet"
)
78
{
79
testLog <<
"Unclosed PWAD color mishandled: "
<< player.
nameColorTagsStripped
();
80
return
false
;
81
}
82
}
83
84
{
85
// PWAD color unclosed at end.
86
Player
player = mkPlayer(
"McFly \034["
);
87
if
(player.
nameColorTagsStripped
() !=
"McFly "
)
88
{
89
testLog <<
"PWAD color unclosed at end mishandled: "
<< player.
nameColorTagsStripped
();
90
return
false
;
91
}
92
}
93
94
{
95
// PWAD color empty.
96
Player
player = mkPlayer(
"Mar\034[]ty"
);
97
if
(player.
nameColorTagsStripped
() !=
"Marty"
)
98
{
99
testLog <<
"PWAD color empty mishandled: "
<< player.
nameColorTagsStripped
();
100
return
false
;
101
}
102
}
103
104
return
true
;
105
}
Doomseeker © 2009-2024 The Doomseeker Team