Skip to content

Commit

Permalink
Squashed 'externals/coda-oss/' changes from 8241dfe7e6..ab45464820
Browse files Browse the repository at this point in the history
ab45464820 remove C++17 workarounds (#618)
3d5daf702e unittests for creating XML from scratch (#617)

git-subtree-dir: externals/coda-oss
git-subtree-split: ab454648207b2923020bea7614a49def65f1108f
  • Loading branch information
Dan Smith authored and Dan Smith committed Nov 28, 2022
1 parent 282e8cb commit df96d9e
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 20 deletions.
11 changes: 0 additions & 11 deletions modules/c++/mt/include/mt/AbstractTiedThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,7 @@ class AbstractTiedThreadPool : public AbstractThreadPool<Request_T>
protected:
virtual mt::TiedWorkerThread<Request_T>*
newTiedWorker(mt::RequestQueue<Request_T>* q,
#if CODA_OSS_cpp17
std::unique_ptr<CPUAffinityThreadInitializer>&& init) = 0;
#else
std::unique_ptr<CPUAffinityThreadInitializer> init) = 0;
virtual mt::TiedWorkerThread<Request_T>*
newTiedWorker(mt::RequestQueue<Request_T>* q,
std::unique_ptr<CPUAffinityThreadInitializer>&& init) {
std::unique_ptr<CPUAffinityThreadInitializer> init_(init.release());
return newTiedWorker(q, init_);
}
#endif


private:
CPUAffinityInitializer* mAffinityInit;
Expand Down
9 changes: 0 additions & 9 deletions modules/c++/mt/include/mt/TiedWorkerThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@ class TiedWorkerThread : public mt::WorkerThread<Request_T>
mCPUAffinityInit(std::move(cpuAffinityInit))
{
}
#if !CODA_OSS_cpp17
TiedWorkerThread(
mt::RequestQueue<Request_T>* requestQueue,
std::unique_ptr<CPUAffinityThreadInitializer> cpuAffinityInit =
std::unique_ptr<CPUAffinityThreadInitializer>(nullptr)) :
TiedWorkerThread(requestQueue, std::unique_ptr<CPUAffinityThreadInitializer>(cpuAffinityInit.release()))
{
}
#endif

virtual void initialize()
{
Expand Down
59 changes: 59 additions & 0 deletions modules/c++/xml.lite/unittests/test_xmlparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,63 @@ TEST_CASE(testXmlConsoleOutput)
}
}

TEST_CASE(testXmlCreateRoot)
{
xml::lite::MinidomParser xmlParser;
auto& document = getDocument(xmlParser);

const auto pDocuments = document.createElement(xml::lite::QName(xml::lite::Uri(), "documents"), "");

io::StringStream output;
pDocuments->print(output);
auto actual = output.stream().str();
TEST_ASSERT_EQ("<documents/>", actual);

pDocuments->setCharacterData("test");
output.reset();
pDocuments->print(output);
actual = output.stream().str();
TEST_ASSERT_EQ("<documents>test</documents>", actual);
}

TEST_CASE(testXmlCreateNested)
{
xml::lite::MinidomParser xmlParser;
auto& document = getDocument(xmlParser);

const auto pDocuments = document.createElement(xml::lite::QName(xml::lite::Uri(), "documents"), "");
xml::lite::AttributeNode a;
a.setQName("count");
a.setValue("1");
pDocuments->getAttributes().add(a);

auto& html = pDocuments->addChild(xml::lite::Element::create(xml::lite::QName("html")));
html.addChild(xml::lite::Element::create(xml::lite::QName("title"), "Title"));
auto& body = html.addChild(xml::lite::Element::create(xml::lite::QName("body")));

auto& p = body.addChild(xml::lite::Element::create(xml::lite::QName("p"), "paragraph"));
a.setQName("a");
a.setValue("abc");
p.getAttributes().add(a);

body.addChild(xml::lite::Element::create(xml::lite::QName("br")));

io::StringStream output;
pDocuments->print(output);
auto actual = output.stream().str();
const auto expected =
"<documents count=\"1\">"
"<html>"
"<title>Title</title>"
"<body>"
"<p a=\"abc\">paragraph</p>"
"<br/>"
"</body>"
"</html>"
"</documents>";
TEST_ASSERT_EQ(expected, actual);
}

TEST_CASE(testXmlParseAndPrintUtf8)
{
io::StringStream input;
Expand Down Expand Up @@ -502,6 +559,8 @@ int main(int, char**)
TEST_CHECK(testXmlParseAndPrintUtf8);
TEST_CHECK(testXmlPrintUtf8);
TEST_CHECK(testXmlConsoleOutput);
TEST_CHECK(testXmlCreateRoot);
TEST_CHECK(testXmlCreateNested);

TEST_CHECK(testReadEncodedXmlFiles);
TEST_CHECK(testReadXmlFiles);
Expand Down

0 comments on commit df96d9e

Please sign in to comment.