Browse Source

Updated for c++17.

master
Alban Deniz 10 months ago
parent
commit
ae2f307b70
3 changed files with 86 additions and 25 deletions
  1. 1
    1
      TestChild/buildAndRun
  2. 22
    24
      TestService/buildAndRun
  3. 63
    0
      TestXMLReader/testXMLReader.cpp

+ 1
- 1
TestChild/buildAndRun View File

CFLAGS='-I.. -std=c++11 -g -O0 -pthread'
CFLAGS='-I.. -std=gnu++17 -g -O0 -pthread'
g++ $CFLAGS childProgram.cpp -o childProgram g++ $CFLAGS childProgram.cpp -o childProgram
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then

+ 22
- 24
TestService/buildAndRun View File

progName=serviceProgram progName=serviceProgram
debugFileName=$progName"Debug.log" debugFileName=$progName"Debug.log"


if [ "$(uname --operating-system)" == "Msys" ]
then
CFLAGS='-I.. -Wall -std=c++11 -DWIN32 -pthread -static -DDEBUG_LOG_FILE="'
CFLAGS=$CFLAGS$(pwd)/$debugFileName\"
CFLAGS='-I.. -Wall -std=c++11 -DWIN32 -pthread -static'
else
CFLAGS='-I.. -Wall -std=c++11 -g -O0 -pthread -DDEBUG_LOG_FILE="'
CFLAGS=$CFLAGS$(pwd)/$debugFileName\"
CFLAGS='-I.. -Wall -std=c++11 -g -O0 -pthread'
fi
#CFLAGS='-I.. -Wall -std=gnu++17 -g -O0 -pthread -DDEBUG_LOG_FILE="'
CFLAGS='-I.. -Wall -DWINDOWS_SERVICE -static -DDEBUG_LOG_FILE="Debug.log"'
#CFLAGS='-I.. -Wall -std=gnu++17 -g -O0 -pthread'


g++ $CFLAGS $progName.cpp ../CodeDweller/service.cpp -o $progName g++ $CFLAGS $progName.cpp ../CodeDweller/service.cpp -o $progName
if [ $? -ne 0 ] if [ $? -ne 0 ]
if [ "$(uname --operating-system)" == "Msys" ] if [ "$(uname --operating-system)" == "Msys" ]
then then


sc create "Test Service" binPath= "$(pwd)/$progName.exe" > /dev/null 2>&1
sc create "Test Service" binPath= "$(pwd)/$progName.exe"


#echo "Starting at "$(date +"%H:%M:%S.%N")
sc start "Test Service" "$(pwd)/$logFile" $message > /dev/null 2>&1
#echo "Sleeping 1 s at "$(date +"%H:%M:%S.%N")
echo "Starting at "$(date +"%H:%M:%S.%N")
sc start "Test Service" "$(pwd)/$logFile" $message
echo "Sleeping 1 s at "$(date +"%H:%M:%S.%N")
sleep 1 sleep 1


#echo "Pausing at "$(date +"%H:%M:%S.%N")
sc pause "Test Service" > /dev/null 2>&1
#echo "Sleeping 2 s at "$(date +"%H:%M:%S.%N")
echo "Pausing at "$(date +"%H:%M:%S.%N")
sc pause "Test Service"
echo "Sleeping 2 s at "$(date +"%H:%M:%S.%N")
sleep 2 sleep 2


#echo "Continuing at "$(date +"%H:%M:%S.%N")
sc continue "Test Service" > /dev/null 2>&1
#echo "Sleeping 2 s at "$(date +"%H:%M:%S.%N")
echo "Continuing at "$(date +"%H:%M:%S.%N")
sc continue "Test Service"
echo "Sleeping 2 s at "$(date +"%H:%M:%S.%N")
sleep 2 sleep 2


#echo "Stopping at "$(date +"%H:%M:%S.%N")
sc stop "Test Service" > /dev/null 2>&1
#echo "Returned at "$(date +"%H:%M:%S.%N")
echo "Stopping at "$(date +"%H:%M:%S.%N")
sc stop "Test Service"
echo "Returned at "$(date +"%H:%M:%S.%N")
sleep 1 sleep 1


sc delete "Test Service" > /dev/null 2>&1
sc delete "Test Service"


else else


} }


# Run tests. # Run tests.
echo Running Nominal test
run_test Nominal run_test Nominal
nominal_status=$? nominal_status=$?
echo Completed Nominal test
echo


# Stop timeout. # Stop timeout.
echo Running Stop test
run_test Stop run_test Stop
stop_status=$? stop_status=$?
echo Completed Stop test


if [ $nominal_status == "0" -a \ if [ $nominal_status == "0" -a \
$stop_status == "0" ] $stop_status == "0" ]

+ 63
- 0
TestXMLReader/testXMLReader.cpp View File

} }
if (elementXml != xml) { if (elementXml != xml) {
std::cout << "\nExpected: '" << xml << "'\n"
<< "Got: '" << elementXml << "'\n";
RETURN_FALSE("RawData() failure for root element"); RETURN_FALSE("RawData() failure for root element");
} }
} }
bool testWrongClosingTag() {
std::string stageContent;
CodeDweller::XMLReaderElement reader("elem");
reader
.Element("stage", stageContent)
.End("stage")
.End("elem");
std::string xml;
std::string expectedStageContent = "StageContent";
xml =
"<elem>\n"
" <stage>" + expectedStageContent + "</xxx>\n"
"</elem>";
CodeDweller::XMLReaderData confData(xml.data(), xml.size());
reader.initialize();
if (0 != reader.interpret(confData)) {
std::cout << "\nParsing '" << xml << "'\n";
RETURN_FALSE("Error: Wrong closing tag not detected.");
}
return true;
}
bool testSimilarAttributeName() { bool testSimilarAttributeName() {
std::string nameAttr, naAttr, nameLongAttr; std::string nameAttr, naAttr, nameLongAttr;
} }
bool testInvalidAttribute() {
std::string nameAttr;
CodeDweller::XMLReaderElement reader("elem");
reader
.Element("stage")
.Attribute("name", nameAttr)
.End("stage")
.End("elem");
std::string xml;
xml = "<elem><stage name=/></elem>";
CodeDweller::XMLReaderData confData(xml.data(), xml.size());
reader.initialize();
if (0 != reader.interpret(confData)) {
std::cout << "\nParsing '" << xml << "'\n";
RETURN_FALSE("Error: Invalid attribute not detected.");
}
return true;
}
bool testHugeAttributeValue() { bool testHugeAttributeValue() {
std::string xml = "<data name='messageContent' value='"; std::string xml = "<data name='messageContent' value='";
RUN_TEST(testEmptyElement); RUN_TEST(testEmptyElement);
RUN_TEST(testRawData); RUN_TEST(testRawData);
RUN_TEST(testSimilarElementName); RUN_TEST(testSimilarElementName);
RUN_TEST(testWrongClosingTag);
RUN_TEST(testSimilarAttributeName); RUN_TEST(testSimilarAttributeName);
RUN_TEST(testInvalidAttribute);
RUN_TEST(testHugeAttributeValue); RUN_TEST(testHugeAttributeValue);
RUN_TEST(testNullAttributeValue); RUN_TEST(testNullAttributeValue);
RUN_TEST(testIndicator); RUN_TEST(testIndicator);

Loading…
Cancel
Save