From 25c50aa4235fd396b740f19c5641dea5adaebc27 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Wed, 30 Nov 2022 22:29:35 -0600 Subject: Move C++ internals to prefixed names in dejagnu.h Also tidy the TestState constructor. --- ChangeLog | 11 +++++++++++ dejagnu.h | 36 +++++++++++++++++------------------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc3893c..128bf52 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2022-11-30 Jacob Bachmeyer + * dejagnu.h (outstate): Remove. + (TestState::pass, TestState::xpass, TestState::fail) + (TestState::xfail, TestState::untested, TestState::unresolved) + (TestState::unsupported, TestState::note): Remove support for + overriding protocol tag lines. + (outstate_list): Rename this... + (DG__outstate_list): ...to this to mark it as internal. + (teststate): Rename this... + (DG_teststate): ...to this to avoid name collisions with user code. + (TestState::TestState): Sort lines by length. + * dejagnu.h (buffer): Remove this variable. (pass, xpass, fail, xfail, untested, unresolved, unsupported) (note): Replace use of buffer and vsnprintf with flockfile, diff --git a/dejagnu.h b/dejagnu.h index 77795e9..2541464 100644 --- a/dejagnu.h +++ b/dejagnu.h @@ -176,30 +176,28 @@ totals (void) #include #include -const char *outstate_list[] = { - "FAILED: ", "PASSED: ", - "UNTESTED: ", "UNRESOLVED: ", "UNSUPPORTED: ", - "XFAILED: ", "XPASSED: " +const char * DG__outstate_list[] = { + "\tFAILED: ", "\tPASSED: ", + "\tUNTESTED: ", "\tUNRESOLVED: ", "\tUNSUPPORTED: ", + "\tXFAILED: ", "\tXPASSED: " }; -const char ** outstate = outstate_list; - -enum teststate { FAILED, PASSED, - UNTESTED, UNRESOLVED, UNSUPPORTED, - XFAILED, XPASSED } laststate; +enum DG_teststate { FAILED, PASSED, + UNTESTED, UNRESOLVED, UNSUPPORTED, + XFAILED, XPASSED }; class TestState { private: - teststate laststate; + DG_teststate laststate; std::string lastmsg; public: TestState (void) { DG__status.pass = 0; DG__status.fail = 0; - DG__status.untested = 0; DG__status.xpass = 0; DG__status.xfail = 0; + DG__status.untested = 0; DG__status.unresolved = 0; DG__status.unsupported = 0; } @@ -219,7 +217,7 @@ class TestState { DG__status.pass++; laststate = PASSED; lastmsg = s; - std::cout << "\t" << outstate[PASSED] << s << std::endl; + std::cout << DG__outstate_list[PASSED] << s << std::endl; } void xpass (std::string s) @@ -227,7 +225,7 @@ class TestState { DG__status.xpass++; laststate = PASSED; lastmsg = s; - std::cout << "\t" << outstate[XPASSED] << s << std::endl; + std::cout << DG__outstate_list[XPASSED] << s << std::endl; } void fail (std::string s) @@ -235,7 +233,7 @@ class TestState { DG__status.fail++; laststate = FAILED; lastmsg = s; - std::cout << "\t" << outstate[FAILED] << s << std::endl; + std::cout << DG__outstate_list[FAILED] << s << std::endl; } void xfail (std::string s) @@ -243,7 +241,7 @@ class TestState { DG__status.xfail++; laststate = XFAILED; lastmsg = s; - std::cout << "\t" << outstate[XFAILED] << s << std::endl; + std::cout << DG__outstate_list[XFAILED] << s << std::endl; } void untested (std::string s) @@ -251,7 +249,7 @@ class TestState { DG__status.untested++; laststate = UNTESTED; lastmsg = s; - std::cout << "\t" << outstate[UNTESTED] << s << std::endl; + std::cout << DG__outstate_list[UNTESTED] << s << std::endl; } void unresolved (std::string s) @@ -259,7 +257,7 @@ class TestState { DG__status.unresolved++; laststate = UNRESOLVED; lastmsg = s; - std::cout << "\t" << outstate[UNRESOLVED] << s << std::endl; + std::cout << DG__outstate_list[UNRESOLVED] << s << std::endl; } void unsupported (std::string s) @@ -267,7 +265,7 @@ class TestState { DG__status.unsupported++; laststate = UNSUPPORTED; lastmsg = s; - std::cout << "\t" << outstate[UNSUPPORTED] << s << std::endl; + std::cout << DG__outstate_list[UNSUPPORTED] << s << std::endl; } void note (std::string s) @@ -306,7 +304,7 @@ class TestState { // This is so this class can be printed in an ostream. friend std::ostream & operator << (std::ostream &os, TestState& t) { - return os << "\t" << outstate[t.laststate] << t.lastmsg ; + return os << DG__outstate_list[t.laststate] << t.lastmsg ; } int GetState (void) { return laststate; } -- cgit v1.1