diff options
author | Mike Anchor <git@mjpa.co.uk> | 2016-07-06 11:10:02 +0300 |
---|---|---|
committer | Mike Anchor <git@mjpa.co.uk> | 2016-07-06 11:10:02 +0300 |
commit | 611748a1e815e9e9bc9944a8b73f7d6505e77216 (patch) | |
tree | b72577bc26ed36e1688b9d67f31f629b36c55d55 /src | |
parent | 07a1266eebaa4ee699f6eae9996a5fbc5c62fa6b (diff) |
Diffstat (limited to 'src')
-rw-r--r-- | src/JSONValue.cpp | 13 | ||||
-rw-r--r-- | src/JSONValue.h | 1 | ||||
-rw-r--r-- | src/demo/testcases.cpp | 13 |
3 files changed, 27 insertions, 0 deletions
diff --git a/src/JSONValue.cpp b/src/JSONValue.cpp index 376059e..6aa79bf 100644 --- a/src/JSONValue.cpp +++ b/src/JSONValue.cpp @@ -368,6 +368,19 @@ JSONValue::JSONValue(double m_number_value) } /** + * Basic constructor for creating a JSON Value of type Number + * + * @access public + * + * @param int m_integer_value The number to use as the value + */ +JSONValue::JSONValue(int m_integer_value) +{ + type = JSONType_Number; + number_value = (double) m_integer_value; +} + +/** * Basic constructor for creating a JSON Value of type Array * * @access public diff --git a/src/JSONValue.h b/src/JSONValue.h index e7024f9..1e38228 100644 --- a/src/JSONValue.h +++ b/src/JSONValue.h @@ -44,6 +44,7 @@ class JSONValue JSONValue(const std::wstring &m_string_value); JSONValue(bool m_bool_value); JSONValue(double m_number_value); + JSONValue(int m_integer_value); JSONValue(const JSONArray &m_array_value); JSONValue(const JSONObject &m_object_value); JSONValue(const JSONValue &m_source); diff --git a/src/demo/testcases.cpp b/src/demo/testcases.cpp index 5fe28a5..a73c20b 100644 --- a/src/demo/testcases.cpp +++ b/src/demo/testcases.cpp @@ -177,5 +177,18 @@ void run_tests() } print_out(test_output.c_str()); + // Test case for int initialisation of JSONValue. + test_output = wstring(L"| Testing JSONValue int initialisation") + wstring(DESC_LENGTH - 36, L' ') + wstring(L" | "); + JSONValue int_test = JSONValue(42); + if (int_test.Stringify() == L"42") + { + test_output += wstring(L"passed |\r\n"); + } + else + { + test_output += wstring(L"failed |\r\n"); + } + print_out(test_output.c_str()); + print_out(vert_sep.c_str()); } |