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

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

+ 22
- 24
TestService/buildAndRun View File

@@ -1,16 +1,9 @@
progName=serviceProgram
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
if [ $? -ne 0 ]
@@ -37,29 +30,29 @@ run_test() {
if [ "$(uname --operating-system)" == "Msys" ]
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

#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

#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

#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

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

else

@@ -122,12 +115,17 @@ return 0
}

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

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

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

+ 63
- 0
TestXMLReader/testXMLReader.cpp View File

@@ -147,6 +147,8 @@ bool testRawData() {
}
if (elementXml != xml) {
std::cout << "\nExpected: '" << xml << "'\n"
<< "Got: '" << elementXml << "'\n";
RETURN_FALSE("RawData() failure for root element");
}
@@ -212,6 +214,37 @@ bool testSimilarElementName() {
}
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() {
std::string nameAttr, naAttr, nameLongAttr;
@@ -262,6 +295,34 @@ bool testSimilarAttributeName() {
}
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() {
std::string xml = "<data name='messageContent' value='";
@@ -545,7 +606,9 @@ int main()
RUN_TEST(testEmptyElement);
RUN_TEST(testRawData);
RUN_TEST(testSimilarElementName);
RUN_TEST(testWrongClosingTag);
RUN_TEST(testSimilarAttributeName);
RUN_TEST(testInvalidAttribute);
RUN_TEST(testHugeAttributeValue);
RUN_TEST(testNullAttributeValue);
RUN_TEST(testIndicator);

Loading…
Cancel
Save