Skip to content

Commit 5c26942

Browse files
committed
Refactoring
Signed-off-by: Vitalii Koshura <lestat.de.lionkur@gmail.com>
1 parent ccb4a80 commit 5c26942

41 files changed

Lines changed: 116 additions & 110 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

clientsetup/win/boinccas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// You should have received a copy of the GNU Lesser General Public License
1616
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
1717

18-
#pragma once
18+
#pragma once
1919

2020
class BOINCCABase
2121
{

clientsetup/win/stdafx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
1717
//
1818

19-
#pragma once
19+
#pragma once
2020

2121
// Modify the following defines if you have to target a platform prior to the ones specified below.
2222
// Refer to MSDN for the latest info on corresponding values for different platforms.

tests/unit-tests/boinccas/test_boinccas_CAAnnounceUpgrade.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "boinccas_helper.h"
1919
#include "registry_helper.h"
2020

21-
namespace test_boinccas_CAAnnounceUpgrade {
21+
namespace test_boinccas {
2222
class test_boinccas_CAAnnounceUpgrade : public test_boinccas_TestBase {
2323
protected:
2424
test_boinccas_CAAnnounceUpgrade() :

tests/unit-tests/boinccas/test_boinccas_CACleanupOldBinaries.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include "boinccas_helper.h"
1919

20-
namespace test_boinccas_CACleanupOldBinaries {
20+
namespace test_boinccas {
2121
class test_boinccas_CACleanupOldBinaries : public test_boinccas_TestBase {
2222
protected:
2323
test_boinccas_CACleanupOldBinaries() :

tests/unit-tests/boinccas/test_boinccas_CACreateAcctMgrLoginFile.cpp

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@
1717

1818
#include "boinccas_helper.h"
1919

20-
namespace test_boinccas_CACreateAcctMgrLoginFile {
21-
class test_boinccas_CACreateAcctMgrLoginFile : public test_boinccas_TestBase {
20+
namespace test_boinccas {
21+
struct AccountData {
22+
std::string login;
23+
std::string passwordHash;
24+
};
25+
26+
class test_boinccas_CACreateAcctMgrLoginFile :
27+
public test_boinccas_TestBase {
2228
protected:
2329
test_boinccas_CACreateAcctMgrLoginFile() :
2430
test_boinccas_TestBase("CreateAcctMgrLoginFile") {
@@ -36,41 +42,38 @@ namespace test_boinccas_CACreateAcctMgrLoginFile {
3642
ofs.close();
3743
}
3844

39-
std::filesystem::path testDir;
40-
};
41-
42-
struct AccountData {
43-
std::string login;
44-
std::string passwordHash;
45-
};
45+
std::pair<bool, AccountData> parseAccountXml(
46+
const std::string& filename)
47+
{
48+
AccountData result;
4649

47-
std::pair<bool, AccountData> parseAccountXml(const std::string& filename)
48-
{
49-
AccountData result;
50+
tinyxml2::XMLDocument doc;
51+
const auto err = doc.LoadFile(filename.c_str());
52+
if (err != tinyxml2::XML_SUCCESS) {
53+
return { false, result };
54+
}
5055

51-
tinyxml2::XMLDocument doc;
52-
const auto err = doc.LoadFile(filename.c_str());
53-
if (err != tinyxml2::XML_SUCCESS) {
54-
return { false, result };
55-
}
56+
auto* root = doc.FirstChildElement("acct_mgr_login");
57+
if (!root) {
58+
return { false, result };
59+
}
5660

57-
auto* root = doc.FirstChildElement("acct_mgr_login");
58-
if (!root) {
59-
return { false, result };
60-
}
61+
const auto* const loginElem = root->FirstChildElement("login");
62+
if (loginElem && loginElem->GetText()) {
63+
result.login = loginElem->GetText();
64+
}
6165

62-
const auto* const loginElem = root->FirstChildElement("login");
63-
if (loginElem && loginElem->GetText()) {
64-
result.login = loginElem->GetText();
65-
}
66+
const auto* const hashElem =
67+
root->FirstChildElement("password_hash");
68+
if (hashElem && hashElem->GetText()) {
69+
result.passwordHash = hashElem->GetText();
70+
}
6671

67-
const auto* const hashElem = root->FirstChildElement("password_hash");
68-
if (hashElem && hashElem->GetText()) {
69-
result.passwordHash = hashElem->GetText();
72+
return { true, result };
7073
}
7174

72-
return { true, result };
73-
}
75+
std::filesystem::path testDir;
76+
};
7477

7578
#ifdef BOINCCAS_TEST
7679
TEST_F(test_boinccas_CACreateAcctMgrLoginFile,

tests/unit-tests/boinccas/test_boinccas_CACreateBOINCAccounts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "boinccas_helper.h"
1919
#include "user_group_helper.h"
2020

21-
namespace test_boinccas_CACreateBOINCAccounts {
21+
namespace test_boinccas {
2222
constexpr auto masterAccountName = "boinc_master";
2323
constexpr auto projectAccountName = "boinc_project";
2424
constexpr auto masterAccountPassword = "qwerty123456!@#$%^";

tests/unit-tests/boinccas/test_boinccas_CACreateBOINCGroups.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include <Lm.h>
2222

23-
namespace test_boinccas_CACreateBOINCGroups {
23+
namespace test_boinccas {
2424
constexpr auto masterAccountName = "boinc_master";
2525
constexpr auto projectAccountName = "boinc_project";
2626
constexpr auto masterAccountPassword = "qwerty123456!@#$%^";

tests/unit-tests/boinccas/test_boinccas_CACreateClientAuthFile.cpp

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,54 +17,56 @@
1717

1818
#include "boinccas_helper.h"
1919

20-
namespace test_boinccas_CACreateClientAuthFile {
21-
class test_boinccas_CACreateClientAuthFile :
22-
public test_boinccas_TestBase {
23-
protected:
24-
test_boinccas_CACreateClientAuthFile() :
25-
test_boinccas_TestBase("CreateClientAuthFile") {
26-
}
27-
};
28-
20+
namespace test_boinccas {
2921
struct AccountData {
3022
std::string username;
3123
std::string password;
3224
};
3325

34-
std::pair<bool, AccountData> parseAccountXml(const std::string& filename)
35-
{
36-
AccountData result;
37-
38-
tinyxml2::XMLDocument doc;
39-
const auto err = doc.LoadFile(filename.c_str());
40-
if (err != tinyxml2::XML_SUCCESS) {
41-
return { false, result };
42-
}
43-
44-
const auto* root = doc.FirstChildElement("client_authorization");
45-
if (!root) {
46-
return { false, result };
47-
}
48-
49-
const auto* project = root->FirstChildElement("boinc_project");
50-
if (!project) {
51-
return { false, result };
52-
}
53-
54-
const auto* const usernameElem =
55-
project->FirstChildElement("username");
56-
if (usernameElem && usernameElem->GetText()) {
57-
result.username = usernameElem->GetText();
26+
class test_boinccas_CACreateClientAuthFile :
27+
public test_boinccas_TestBase {
28+
protected:
29+
test_boinccas_CACreateClientAuthFile() :
30+
test_boinccas_TestBase("CreateClientAuthFile") {
5831
}
5932

60-
const auto* const passwordElem =
61-
project->FirstChildElement("password");
62-
if (passwordElem && passwordElem->GetText()) {
63-
result.password = passwordElem->GetText();
33+
std::pair<bool, AccountData> parseAccountXml(
34+
const std::string& filename)
35+
{
36+
AccountData result;
37+
38+
tinyxml2::XMLDocument doc;
39+
const auto err = doc.LoadFile(filename.c_str());
40+
if (err != tinyxml2::XML_SUCCESS) {
41+
return { false, result };
42+
}
43+
44+
const auto* root = doc.FirstChildElement("client_authorization");
45+
if (!root) {
46+
return { false, result };
47+
}
48+
49+
const auto* project = root->FirstChildElement("boinc_project");
50+
if (!project) {
51+
return { false, result };
52+
}
53+
54+
const auto* const usernameElem =
55+
project->FirstChildElement("username");
56+
if (usernameElem && usernameElem->GetText()) {
57+
result.username = usernameElem->GetText();
58+
}
59+
60+
const auto* const passwordElem =
61+
project->FirstChildElement("password");
62+
if (passwordElem && passwordElem->GetText()) {
63+
result.password = passwordElem->GetText();
64+
}
65+
66+
return { true, result };
6467
}
6568

66-
return { true, result };
67-
}
69+
};
6870

6971
#ifdef BOINCCAS_TEST
7072
TEST_F(test_boinccas_CACreateClientAuthFile,

tests/unit-tests/boinccas/test_boinccas_CACreateProjectInitFile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "boinccas_helper.h"
1919
#include "project_init.h"
2020

21-
namespace test_boinccas_CACreateProjectInitFile {
21+
namespace test_boinccas {
2222
class test_boinccas_CACreateProjectInitFile :
2323
public test_boinccas_TestBase {
2424
protected:

tests/unit-tests/boinccas/test_boinccas_CADeleteBOINCAccounts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "registry_helper.h"
2020
#include "user_group_helper.h"
2121

22-
namespace test_boinccas_CADeleteBOINCAccounts {
22+
namespace test_boinccas {
2323
class test_boinccas_CADeleteBOINCAccounts : public test_boinccas_TestBase {
2424
protected:
2525
test_boinccas_CADeleteBOINCAccounts() :

0 commit comments

Comments
 (0)