|
17 | 17 |
|
18 | 18 | #include "boinccas_helper.h" |
19 | 19 |
|
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 { |
29 | 21 | struct AccountData { |
30 | 22 | std::string username; |
31 | 23 | std::string password; |
32 | 24 | }; |
33 | 25 |
|
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") { |
58 | 31 | } |
59 | 32 |
|
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 }; |
64 | 67 | } |
65 | 68 |
|
66 | | - return { true, result }; |
67 | | - } |
| 69 | + }; |
68 | 70 |
|
69 | 71 | #ifdef BOINCCAS_TEST |
70 | 72 | TEST_F(test_boinccas_CACreateClientAuthFile, |
|
0 commit comments