diff options
author | Kevron Rees <tripzero.kev@gmail.com> | 2013-11-11 09:58:52 -0800 |
---|---|---|
committer | Kevron Rees <tripzero.kev@gmail.com> | 2013-11-11 09:58:52 -0800 |
commit | 51691c0e355051ba9cb11427a2a13d3f19828e55 (patch) | |
tree | f0fe2b267d2c9a4f2c7338355bd2a2e3301c19b3 | |
parent | a825db03bd5e608311290d2d6803475da5a209df (diff) | |
download | automotive-message-broker-51691c0e355051ba9cb11427a2a13d3f19828e55.tar.gz |
fixed toString fromString for bool Property types
-rw-r--r-- | lib/abstractpropertytype.h | 3 | ||||
-rw-r--r-- | plugins/testplugin/testplugin.cpp | 12 |
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/abstractpropertytype.h b/lib/abstractpropertytype.h index 3e9dcbad..43bb7634 100644 --- a/lib/abstractpropertytype.h +++ b/lib/abstractpropertytype.h @@ -273,6 +273,9 @@ public: } static std::string stringize(std::string v) { + if(v == "0" || v == "1") + return v; + boost::algorithm::to_lower(v); return v == "true" ? "1":"0"; } diff --git a/plugins/testplugin/testplugin.cpp b/plugins/testplugin/testplugin.cpp index 2cdc2fd1..d0fdb087 100644 --- a/plugins/testplugin/testplugin.cpp +++ b/plugins/testplugin/testplugin.cpp @@ -33,6 +33,16 @@ AbstractRoutingEngine *m_re; //std::list<ObdPid*> Obd2Amb::supportedPidsList; +void testBooleanToStringFromString() +{ + BasicPropertyType<bool> boolean(true); + std::string isTrue = boolean.toString(); + boolean.fromString(boolean.toString()); + std::string isTrue2 = boolean.toString(); + + g_assert(isTrue == isTrue2); +} + bool beginsWith(std::string a, std::string b) { return (a.compare(0, b.length(), b) == 0); @@ -78,6 +88,8 @@ TestPlugin::TestPlugin(AbstractRoutingEngine *re, map<string, string> config) g_assert (tfirst->toString() == tsecond->toString()); + testBooleanToStringFromString(); + DebugOut() << "Exiting..." << endl; exit(-1); } |