forked from BOINC/boinc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix to xml_unescape function for multiple escape values.
Added unit tests for parse.cpp to prove xml_unescape is working properly.
- Loading branch information
Keith Uplinger
committed
May 29, 2019
1 parent
be63e62
commit 4928cc9
Showing
2 changed files
with
91 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include "gtest/gtest.h" | ||
#include "common_defs.h" | ||
#include "url.h" | ||
#include <string> | ||
#include <ios> | ||
|
||
using namespace std; | ||
|
||
namespace test_parse { | ||
|
||
// The fixture for testing class Foo. | ||
|
||
class test_parse : public ::testing::Test { | ||
protected: | ||
// You can remove any or all of the following functions if its body | ||
// is empty. | ||
|
||
test_parse() { | ||
// You can do set-up work for each test here. | ||
} | ||
|
||
virtual ~test_parse() { | ||
// You can do clean-up work that doesn't throw exceptions here. | ||
} | ||
|
||
// If the constructor and destructor are not enough for setting up | ||
// and cleaning up each test, you can define the following methods: | ||
|
||
virtual void SetUp() { | ||
// Code here will be called immediately after the constructor (right | ||
// before each test). | ||
} | ||
|
||
virtual void TearDown() { | ||
// Code here will be called immediately after each test (right | ||
// before the destructor). | ||
} | ||
|
||
// Objects declared here can be used by all tests in the test case for Foo. | ||
}; | ||
|
||
// Tests that Foo does Xyz. | ||
|
||
TEST_F(test_parse, xml_unescape) { | ||
string test = "<>"'&


K"; | ||
string answer = "<>\"\'&\r\r\n\nK"; | ||
xml_unescape(test); | ||
EXPECT_EQ(test, answer); | ||
|
||
//Note: this is to check that partial values don't pass strncmp for previously bad compares. | ||
test = "&quoYIKES&apoBOO"; | ||
answer = "&quoYIKES&apoBOO"; | ||
xml_unescape(test); | ||
EXPECT_EQ(test, answer); | ||
|
||
//Testing the ascii conversion unknown. | ||
test = "	s3;�&#;eqӒK"; | ||
answer = "	s3;�&#;eqӒK"; | ||
xml_unescape(test); | ||
EXPECT_EQ(test, answer); | ||
} | ||
|
||
} // namespace |