Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MJPA/SimpleJSON.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/JSONValue.cpp13
-rw-r--r--src/JSONValue.h1
-rw-r--r--src/demo/testcases.cpp13
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());
}