| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- #include "Test.h"
- #include "Tribool.h"
- #include <Logging.h>
- #include <ios>
- #include <sstream>
- namespace Utilities {
- namespace Test {
- void TestUtilTribool()
- {
- Tribool::Tribool x;
- std::stringstream ss;
- std::ostringstream out;
- ss.str("");
- out.str(std::string());
- x = false;
- out << x;
- ss << "Output false (noboolalpha): " << out.str() << std::endl;
- Logging::Log(Logging::Severity::Info, ss.str());
- ss.str("");
- out.str(std::string());
- x = true;
- out << x;
- ss << "Output true (noboolalpha): " << out.str() << std::endl;
- Logging::Log(Logging::Severity::Info, ss.str());
- ss.str("");
- out.str(std::string());
- x = Tribool::Tribool::Indeterminate;
- out << x;
- ss << "Output indeterminate (noboolalpha): " << out.str() << std::endl;
- Logging::Log(Logging::Severity::Info, ss.str());
- ss.str("");
- out.str(std::string());
- out << Tribool::Tribool::Indeterminate;
- ss << "Output indeterminate (noboolalpha): " << out.str() << std::endl;
- Logging::Log(Logging::Severity::Info, ss.str());
- ss.str("");
- out.str(std::string());
- x = false;
- out << std::boolalpha << x;
- ss << "Output false (boolalpha): " << out.str() << std::endl;
- Logging::Log(Logging::Severity::Info, ss.str());
- ss.str("");
- out.str(std::string());
- x = true;
- out << std::boolalpha << x;
- ss << "Output true (boolalpha): " << out.str() << std::endl;
- Logging::Log(Logging::Severity::Info, ss.str());
- ss.str("");
- out.str(std::string());
- x = Tribool::Tribool::Indeterminate;
- out << std::boolalpha << x;
- ss << "Output indeterminate (boolalpha - default name): " << out.str() << std::endl;
- Logging::Log(Logging::Severity::Info, ss.str());
- ss.str("");
- out.str(std::string());
- out << std::boolalpha << Tribool::Tribool::Indeterminate;
- ss << "Output indeterminate (boolalpha - default name): " << out.str() << std::endl;
- Logging::Log(Logging::Severity::Info, ss.str());
- ss.str("");
- ss << "----------------------------------" << std::endl;
- Logging::Log(Logging::Severity::Info, ss.str());
- ss.str("");
- Tribool::Tribool b;
- ss << "Tribool::Tribool b = " << std::boolalpha << b << std::endl;
- Logging::Log(Logging::Severity::Info, ss.str());
- b = true;
- b = false;
- b = Tribool::Tribool::Indeterminate;
- ss.str("");
- if (b)
- ss << "indeterminate = true" << std::endl;
- else if (!b)
- ss << "indeterminate = false" << std::endl;
- else
- ss << "indeterminate = indeterminate" << std::endl;
- Logging::Log(Logging::Severity::Info, ss.str());
- ss.setf(std::ios::boolalpha);
- ss.str("");
- Tribool::Tribool b1 = true;
- ss << "true || indeterminate = " << (b1 || Tribool::Tribool::Indeterminate) << std::endl;
- ss << "true && indeterminate = " << (b1 && Tribool::Tribool::Indeterminate) << std::endl;
- Logging::Log(Logging::Severity::Info, ss.str());
- ss.str("");
- Tribool::Tribool b2 = false;
- ss << "false || indeterminate = " << (b2 || Tribool::Tribool::Indeterminate) << std::endl;
- ss << "false && indeterminate = " << (b2 && Tribool::Tribool::Indeterminate) << std::endl;
- Logging::Log(Logging::Severity::Info, ss.str());
- ss.str("");
- Tribool::Tribool b3 = Tribool::Tribool::Indeterminate;
- ss << "indeterminate || indeterminate = " << (b3 || b3) << std::endl;
- ss << "indeterminate && indeterminate = " << (b3 && b3) << std::endl;
- Logging::Log(Logging::Severity::Info, ss.str());
- }
- bool TestTribool()
- {
- std::stringstream ss;
- ss << "----------------------------------" << std::endl;
- ss << "| Test::Tribool |" << std::endl;
- ss << "----------------------------------" << std::endl;
- Logging::Log(Logging::Severity::Info, ss.str());
- TestUtilTribool();
- ss.str("");
- ss << "==================================" << std::endl << std::endl;
- Logging::Log(Logging::Severity::Info, ss.str());
- return true;
- }
- } // namespace Test
- } // namespace Utilities
|