mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
add unit test for updating teamranks
This commit is contained in:
parent
a38dea4454
commit
e75a763454
|
@ -255,6 +255,23 @@ struct TeamScore : public Score
|
|||
str_copy(m_PlayerRequest.m_aRequestingPlayer, "brainless tee", sizeof(m_PlayerRequest.m_aRequestingPlayer));
|
||||
m_PlayerRequest.m_Offset = 0;
|
||||
}
|
||||
|
||||
void InsertTeamRank(float Time = 100.0)
|
||||
{
|
||||
CSqlTeamScoreData teamScoreData;
|
||||
str_copy(teamScoreData.m_aMap, "Kobra 3", sizeof(teamScoreData.m_aMap));
|
||||
str_copy(teamScoreData.m_aGameUuid, "8d300ecf-5873-4297-bee5-95668fdff320", sizeof(teamScoreData.m_aGameUuid));
|
||||
teamScoreData.m_Size = 2;
|
||||
str_copy(teamScoreData.m_aaNames[0], "nameless tee", sizeof(teamScoreData.m_aaNames[0]));
|
||||
str_copy(teamScoreData.m_aaNames[1], "brainless tee", sizeof(teamScoreData.m_aaNames[1]));
|
||||
teamScoreData.m_Time = Time;
|
||||
str_copy(teamScoreData.m_aTimestamp, "2021-11-24 19:24:08", sizeof(teamScoreData.m_aTimestamp));
|
||||
ASSERT_FALSE(CScoreWorker::SaveTeamScore(m_pConn, &teamScoreData, Write::NORMAL, m_aError, sizeof(m_aError))) << m_aError;
|
||||
|
||||
str_copy(m_PlayerRequest.m_aMap, "Kobra 3", sizeof(m_PlayerRequest.m_aMap));
|
||||
str_copy(m_PlayerRequest.m_aRequestingPlayer, "brainless tee", sizeof(m_PlayerRequest.m_aRequestingPlayer));
|
||||
m_PlayerRequest.m_Offset = 0;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(TeamScore, All)
|
||||
|
@ -268,7 +285,7 @@ TEST_P(TeamScore, All)
|
|||
|
||||
TEST_P(TeamScore, PlayerExists)
|
||||
{
|
||||
str_copy(m_PlayerRequest.m_aName, "brainless tee", sizeof(m_PlayerRequest.m_aMap));
|
||||
str_copy(m_PlayerRequest.m_aName, "brainless tee", sizeof(m_PlayerRequest.m_aName));
|
||||
ASSERT_FALSE(CScoreWorker::ShowPlayerTeamTop5(m_pConn, &m_PlayerRequest, m_aError, sizeof(m_aError))) << m_aError;
|
||||
ExpectLines(m_pPlayerResult,
|
||||
{"------- Team Top 5 -------",
|
||||
|
@ -278,11 +295,22 @@ TEST_P(TeamScore, PlayerExists)
|
|||
|
||||
TEST_P(TeamScore, PlayerDoesntExist)
|
||||
{
|
||||
str_copy(m_PlayerRequest.m_aName, "foo", sizeof(m_PlayerRequest.m_aMap));
|
||||
str_copy(m_PlayerRequest.m_aName, "foo", sizeof(m_PlayerRequest.m_aName));
|
||||
ASSERT_FALSE(CScoreWorker::ShowPlayerTeamTop5(m_pConn, &m_PlayerRequest, m_aError, sizeof(m_aError))) << m_aError;
|
||||
ExpectLines(m_pPlayerResult, {"foo has no team ranks"});
|
||||
}
|
||||
|
||||
TEST_P(TeamScore, RankUpdates)
|
||||
{
|
||||
InsertTeamRank(98.0);
|
||||
str_copy(m_PlayerRequest.m_aName, "brainless tee", sizeof(m_PlayerRequest.m_aName));
|
||||
ASSERT_FALSE(CScoreWorker::ShowPlayerTeamTop5(m_pConn, &m_PlayerRequest, m_aError, sizeof(m_aError))) << m_aError;
|
||||
ExpectLines(m_pPlayerResult,
|
||||
{"------- Team Top 5 -------",
|
||||
"1. brainless tee & nameless tee Team Time: 01:38.00",
|
||||
"-------------------------------"});
|
||||
}
|
||||
|
||||
struct MapInfo : public Score
|
||||
{
|
||||
MapInfo()
|
||||
|
|
Loading…
Reference in a new issue