summaryrefslogtreecommitdiff
path: root/tests/cpp/include/variables.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cpp/include/variables.h')
-rw-r--r--tests/cpp/include/variables.h36
1 files changed, 27 insertions, 9 deletions
diff --git a/tests/cpp/include/variables.h b/tests/cpp/include/variables.h
index f242653..b7063ef 100644
--- a/tests/cpp/include/variables.h
+++ b/tests/cpp/include/variables.h
@@ -4,6 +4,8 @@
*
*/
+ #include "doubl2str.h"
+
/**
* Set up namespace
*/
@@ -120,20 +122,36 @@ namespace TestVariables {
return r;
}
+
/*
- * Test Php::Value casting operators
- */
+ * Test Php::Value casting operators
+ */
void value_casting(Php::Parameters &params)
{
- Php::Value value = params[0];
+ Php::Value value = params[0];
- long value1 = value;
- std::string value2 = value;
- //long double value3 = value; // <------------ error: conversion from ‘Php::Value’ to ‘long double’ is ambiguous
- double value3 = value;
- bool value4 = value;
+ long value1 = value;
+ std::string value2 = value;
+ bool value4 = value;
- Php::out << " long:" << value1 << "\n string:" << value2 << "\n double:" << value3 << "\n bool:" << bool2str(value4) << std::endl;
+ Php::out << " long:" << value1 << "\n string:" << value2 << "\n bool:" << bool2str(value4) << std::endl;
+ }
+
+
+ /*
+ * Test Php::Value casting operators
+ */
+ void value_cast2double(Php::Parameters &params)
+ {
+ Php::Value value = params[0];
+ double value3 = value;
+
+ /*
+ * The remark (from valmat).
+ * Somehow std::to_string truncates the tail of numbers of type `double` when converting it to a string.
+ * So I wrote my own function `double2str()`, which does not have this drawback.
+ */
+ Php::out << double2str(value3) << std::endl;
}
/*