File tree 3 files changed +26
-0
lines changed
3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
6
6
and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
7
7
8
+ ## [ 0.2.1] - 2020-10-21
9
+ ### Changed
10
+ - Updated Catch to version 2.13.2
11
+ - Updated nlohmann_json to 3.9.1
12
+
13
+ ### Fixed
14
+ - Typemapper failed to convert enum parameters on top-level (#10 )
15
+
8
16
## [ 0.2.0] - 2020-10-14
9
17
10
18
### Added
Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ namespace jsonrpccxx {
22
22
}
23
23
template <typename T>
24
24
constexpr json::value_t GetType (type<T>) {
25
+ if (std::is_enum<T>::value) {
26
+ return json::value_t ::string;
27
+ }
25
28
return json::value_t ::object;
26
29
}
27
30
constexpr json::value_t GetType (type<void >) { return json::value_t ::null; }
Original file line number Diff line number Diff line change @@ -146,6 +146,21 @@ bool add_products(const vector<product> &products) {
146
146
return true ;
147
147
}
148
148
149
+ string enumToString (const category& category) {
150
+ switch (category) {
151
+ case category::cash_carry: return " cash&carry" ;
152
+ case category::order: return " online-order" ;
153
+ default : return " unknown category" ;
154
+ }
155
+ }
156
+
157
+ TEST_CASE (" test with enum as top level parameter" , TEST_MODULE) {
158
+ MethodHandle mh = GetHandle (&enumToString);
159
+
160
+ json params = R"( ["cc"])" _json;
161
+ CHECK (mh (params) == " cash&carry" );
162
+ }
163
+
149
164
TEST_CASE (" test with custom params" , TEST_MODULE) {
150
165
MethodHandle mh = GetHandle (&add_products);
151
166
catalog.clear ();
You can’t perform that action at this time.
0 commit comments