diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-10 21:17:23 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-13 17:22:05 -0700 |
commit | 282e626ac112b1ca7a9bf9f9d4c0239db8fbd97a (patch) | |
tree | f83ef7974687a84341dd616b364b2aa5a9c012a8 /test | |
parent | 36bef2157595e1455aa55c64c6c526f096dd1c8e (diff) | |
download | qtlocation-mapboxgl-282e626ac112b1ca7a9bf9f9d4c0239db8fbd97a.tar.gz |
[core] Make enum ↔ string conversion more generic-friendly
Rewrite enum.hpp in such a way that parseConstant can be defined generically for all enumerated types.
While there, properly validated enumerated property values.
Diffstat (limited to 'test')
-rw-r--r-- | test/src/mbgl/test/fixture_log_observer.cpp | 4 | ||||
-rw-r--r-- | test/style/style_parser.cpp | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/test/src/mbgl/test/fixture_log_observer.cpp b/test/src/mbgl/test/fixture_log_observer.cpp index 11587be15a..fc0239bb1c 100644 --- a/test/src/mbgl/test/fixture_log_observer.cpp +++ b/test/src/mbgl/test/fixture_log_observer.cpp @@ -1,5 +1,6 @@ #include <mbgl/test/fixture_log_observer.hpp> #include <mbgl/test/util.hpp> +#include <mbgl/util/enum.hpp> namespace mbgl { @@ -96,7 +97,8 @@ std::vector<FixtureLog::Message> FixtureLogObserver::unchecked() const { } ::std::ostream& operator<<(::std::ostream& os, const FixtureLog::Message& message) { - os << "[\"" << message.severity << "\", \"" << message.event << "\""; + os << "[\"" << Enum<EventSeverity>::toString(message.severity) << "\", \""; + os << Enum<Event>::toString(message.event) << "\""; os << ", " << message.code; os << ", \"" << message.msg << "\""; return os << "]" << std::endl; diff --git a/test/style/style_parser.cpp b/test/style/style_parser.cpp index 7590f32403..aba5ec67bd 100644 --- a/test/style/style_parser.cpp +++ b/test/style/style_parser.cpp @@ -3,6 +3,7 @@ #include <mbgl/style/parser.hpp> #include <mbgl/util/io.hpp> +#include <mbgl/util/enum.hpp> #include <rapidjson/document.h> @@ -46,8 +47,8 @@ TEST_P(StyleParserTest, ParseStyle) { const uint32_t count = js_entry[rapidjson::SizeType(0)].GetUint(); const FixtureLogObserver::LogMessage message { - EventSeverityClass(js_entry[rapidjson::SizeType(1)].GetString()), - EventClass(js_entry[rapidjson::SizeType(2)].GetString()), + *Enum<EventSeverity>::toEnum(js_entry[rapidjson::SizeType(1)].GetString()), + *Enum<Event>::toEnum(js_entry[rapidjson::SizeType(2)].GetString()), int64_t(-1), js_entry[rapidjson::SizeType(3)].GetString() }; |