powerguru-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Powerguru-commit] [SCM] powerguru branch, master, updated. ec6fbcc39e41


From: Rob Savoye
Subject: [Powerguru-commit] [SCM] powerguru branch, master, updated. ec6fbcc39e4117df4ad6607d6640dd7fd3fb0e23
Date: Sun, 9 Dec 2018 14:59:02 -0500 (EST)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "powerguru".

The branch, master has been updated
       via  ec6fbcc39e4117df4ad6607d6640dd7fd3fb0e23 (commit)
       via  2cd94bdf5a84633b2bfe19b637f9723d3186030e (commit)
      from  ea4f0556a9c4638f9102ba36a08100f2a1f52dfd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=ec6fbcc39e4117df4ad6607d6640dd7fd3fb0e23


commit ec6fbcc39e4117df4ad6607d6640dd7fd3fb0e23
Author: Rob Savoye <address@hidden>
Date:   Sun Dec 9 12:58:54 2018 -0700

    Use xmlNodeGetContent

diff --git a/lib/xml.cc b/lib/xml.cc
index 9608b5d..f5b02dd 100644
--- a/lib/xml.cc
+++ b/lib/xml.cc
@@ -90,19 +90,18 @@ XML::extractNode(xmlNodePtr node)
         name = reinterpret_cast<const char *>(node->name);
         xml->nameSet(name);
     }
-    // Sometimes the content is at the end of a line, so remove the carriage 
return
-    // and trailing garbage. It's a const, so return a substring instead of 
trying
-    // to change the value string.
-    if (node->children->content != 0) {
-        value = reinterpret_cast<char *>(node->children->content);
-        xml->valueSet(value.substr(0, value.find('\n')));
-    }
-
     if (node->children) {
-        //ptr = node->children->content;
-        ptr = xmlNodeGetContent(node->children);
+        // Sometimes the content is at the end of a line, so remove the
+        // carriage return and trailing garbage.
+        if (node->children->content != 0) {
+            value = reinterpret_cast<char *>(node->children->content);
+            xml->valueSet(value.substr(0, value.find('\n')));
+        }
+        
+        ptr = xmlNodeGetContent(node->children);        
         if (ptr != NULL) {
-            value = reinterpret_cast<const char *>(node->children->content);
+            //value = reinterpret_cast<const char *>(node->children->content);
+            value = reinterpret_cast<const char *>(ptr);
 #if 1
             dbglogfile << "\tChild node: " << name
                        << " has contents " << value << std::endl;
diff --git a/lib/xml.h b/lib/xml.h
index 005f0cc..85a8930 100644
--- a/lib/xml.h
+++ b/lib/xml.h
@@ -1,5 +1,5 @@
 // 
-// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
+// Copyright (C) 2005, 2006 - 2018
 //      Free Software Foundation, Inc.
 // 
 // This program is free software; you can redistribute it and/or modify

http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=2cd94bdf5a84633b2bfe19b637f9723d3186030e


commit 2cd94bdf5a84633b2bfe19b637f9723d3186030e
Author: Rob Savoye <address@hidden>
Date:   Sun Dec 9 12:58:19 2018 -0700

    Minor changes for testing, add more tests.

diff --git a/lib/commands.cc b/lib/commands.cc
index c570a29..abcd535 100644
--- a/lib/commands.cc
+++ b/lib/commands.cc
@@ -69,10 +69,12 @@ Commands::createCommand(cmd_t cmd, const std::string &args,
     return str;
 }
 
-const std::string &
-parseCommand(XML &xml)
+std::string &
+parseCommand(XML &xml, std::string &str)
 {
     DEBUGLOG_REPORT_FUNCTION;
+
+    return str;
 }
 
 // local Variables:
diff --git a/lib/commands.h b/lib/commands.h
index f714ecf..a72a86c 100644
--- a/lib/commands.h
+++ b/lib/commands.h
@@ -39,7 +39,7 @@ class Commands
 
   std::string &createCommand(cmd_t cmd, const std::string &args,
                                    std::string &str);
-  const std::string &execCommand(XML &xml);
+  std::string &execCommand(XML &xml, std::string &str);
 };
 
 #endif // __COMMANDS_H__
diff --git a/testsuite/libtests/cmd-test.cc b/testsuite/libtests/cmd-test.cc
index db96a86..f971cae 100644
--- a/testsuite/libtests/cmd-test.cc
+++ b/testsuite/libtests/cmd-test.cc
@@ -33,38 +33,88 @@ bool waitforgdb = false;
 
 TestState runtest;
 
+// Declare a class inherited from the base class so we can access the internal
+// protected data.
 class Test : public Commands
 {
 public:
     Test() {
         DEBUGLOG_REPORT_FUNCTION;
 
+        // Test creating commands
         std::string str;
-        std::cerr << createCommand(Commands::NOP, "", str) << std::endl;
+        createCommand(Commands::NOP, "", str);
         if (str == "<command></command>") {
-            runtest.pass("NOP command");
+            runtest.pass("create NOP command");
         } else {
-            runtest.fail("NOP command");
+            runtest.fail("create NOP command");
         }
         str.erase();
         //
-        std::cerr << createCommand(Commands::LIST, "foo", str) << std::endl;
+        createCommand(Commands::LIST, "foo", str);
         if (str == "<command><list>foo</list></command>") {
-            runtest.pass("LIST command");
+            runtest.pass("create LIST command");
         } else {
-            runtest.fail("LIST command");
+            runtest.fail("create LIST command");
         }
         str.erase();
-        std::cerr << createCommand(Commands::POLL, "bar", str) << std::endl;
+        createCommand(Commands::POLL, "bar", str);
         if (str == "<command><poll>bar</poll></command>") {
-            runtest.pass("POLL command");
+            runtest.pass("create POLL command");
         } else {
-            runtest.fail("POLL command");
+            runtest.fail("create POLL command");
         }
         str.erase();
 
+        // Test oarsing XML commands
+        XML xml;
+        std::string testnop = "<command></command>";
+        if (!xml.parseMem(testnop)) {
+            runtest.untested("XML::parseMem(nop command) failed!");
+        }
+        if (xml.nameGet() == "command") {
+            runtest.pass("parse NOP command");
+        } else {
+            runtest.fail("parse NOP command");
+        }
+        if (xml[0] == 0) {
+            runtest.pass("NOP command has no children");
+        } else {
+            runtest.fail("NOP command has no children");
+        }
+        str.erase();
+
+        std::string testlist = "<command><list>foo</list></command>"; 
+        if (!xml.parseMem(testlist)) {
+            runtest.untested("XML::parseMem(list command) failed!");
+        }
+        XMLNode *node = xml[0];
+        if (node->nameGet() == "list") {
+            runtest.pass("parse LIST command");
+        } else {
+            runtest.fail("parse LIST command");
+        }
+        str.erase();
+
+        if (xml[0] != 0) {
+            runtest.pass("LIST command has children");
+        } else {
+            runtest.fail("LIST command has children");
+        }
+        
+        if (xml[0]->nameGet() == "list" && xml[0]->valueGet() == "foo") {
+            runtest.pass("LIST command has correct child");
+        } else {
+            runtest.fail("LIST command has correct child");
+        }
+        
+        //execCommand(xml, str);
+        
         
+        std::string testpoll = "<command><poll>bar</poll></command>";
+
     };
+    
     ~Test() {};
 };
 

-----------------------------------------------------------------------

Summary of changes:
 lib/commands.cc                |  6 ++--
 lib/commands.h                 |  2 +-
 lib/xml.cc                     | 21 +++++++------
 lib/xml.h                      |  2 +-
 testsuite/libtests/cmd-test.cc | 68 ++++++++++++++++++++++++++++++++++++------
 5 files changed, 75 insertions(+), 24 deletions(-)


hooks/post-receive
-- 
powerguru



reply via email to

[Prev in Thread] Current Thread [Next in Thread]