mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #6591
6591: add unit test for updating teamranks r=def- a=edg-l add unit test for updating teamranks fixes #6113 ## Checklist - [ ] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [x] Written a unit test (especially base/) or added coverage to integration test - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Edgar Luque <git@edgarluque.com>
This commit is contained in:
commit
9161504253
|
@ -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