diff options
author | valmat <ufabiz@gmail.com> | 2014-06-11 19:34:40 +0600 |
---|---|---|
committer | valmat <ufabiz@gmail.com> | 2014-06-11 19:34:40 +0600 |
commit | 4f3769855dd65a8ef0b647c7e98860b8aa747c26 (patch) | |
tree | be9c261e7b6284c77a5ef19d125b25f2b37f4dbd /tests/cpp | |
parent | e350c8f1b33d7c6c605f5450e8cf901cc3e5e1c4 (diff) |
done
Diffstat (limited to 'tests/cpp')
-rw-r--r-- | tests/cpp/h/variables.h | 1 | ||||
-rw-r--r-- | tests/cpp/include/variables/028-029-compare.h | 194 | ||||
-rw-r--r-- | tests/cpp/main.cpp | 3 |
3 files changed, 198 insertions, 0 deletions
diff --git a/tests/cpp/h/variables.h b/tests/cpp/h/variables.h index 8a074cd..0b684dd 100644 --- a/tests/cpp/h/variables.h +++ b/tests/cpp/h/variables.h @@ -27,6 +27,7 @@ #include "../include/variables/025-post-raw1.h" #include "../include/variables/026-post-raw2.h" #include "../include/variables/027-env.h" +#include "../include/variables/028-029-compare.h" //#include "../include/variables/.h" diff --git a/tests/cpp/include/variables/028-029-compare.h b/tests/cpp/include/variables/028-029-compare.h new file mode 100644 index 0000000..bd95298 --- /dev/null +++ b/tests/cpp/include/variables/028-029-compare.h @@ -0,0 +1,194 @@ +/** + * + * Test variables + * phptname.phpt + * + */ + + + + +/** + * Set up namespace + */ +namespace TestVariables { + + /* + * Test bool Value::operator==(const Value &value) const + */ + void test_compare1() + { + Php::Value v1(5), v2(5.0), v3("5"), v4("5.0"); + + Php::out << "true:" << std::endl; + Php::out << (v1 == v2) << std::endl; + Php::out << (v1 == v3) << std::endl; + Php::out << (v1 == v4) << std::endl; + Php::out << (v2 == v1) << std::endl; + Php::out << (v2 == v3) << std::endl; + Php::out << (v2 == v4) << std::endl; + Php::out << (v3 == v1) << std::endl; + Php::out << (v3 == v2) << std::endl; + Php::out << (v3 == v4) << std::endl; + Php::out << (v4 == v1) << std::endl; + Php::out << (v4 == v2) << std::endl; + Php::out << (v4 == v3) << std::endl; + + Php::Value v5(6), v6(6.0), v7("6"), v8("6.0"); + + Php::out << "false:" << std::endl; + Php::out << (v1 == v5) << std::endl; + Php::out << (v1 == v6) << std::endl; + Php::out << (v1 == v7) << std::endl; + Php::out << (v1 == v8) << std::endl; + + Php::out << (v2 == v5) << std::endl; + Php::out << (v2 == v6) << std::endl; + Php::out << (v2 == v7) << std::endl; + Php::out << (v2 == v8) << std::endl; + + Php::out << (v3 == v5) << std::endl; + Php::out << (v3 == v6) << std::endl; + Php::out << (v3 == v7) << std::endl; + Php::out << (v3 == v8) << std::endl; + + Php::out << (v4 == v5) << std::endl; + Php::out << (v4 == v6) << std::endl; + Php::out << (v4 == v7) << std::endl; + Php::out << (v4 == v8) << std::endl; + + Php::Value v9, v10, v11, v12; + v9[0] = 5; + v9[1] = 6; + + v10[0] = 5; + v10[1] = "Hello!"; + + v11[0] = 5; + v11[1] = 6; + + v12[0] = 5; + + Php::out << "Compare array:" << std::endl; + Php::out << (v1 == v9) << std::endl; + Php::out << (v5 == v9) << std::endl; + Php::out << (v9 == v10) << std::endl; + Php::out << (v11 == v9) << std::endl; + Php::out << (v12 == v9) << std::endl; + + Php::Value v13 = false, v14, v15 = 0; + Php::out << "Compare NULL:" << std::endl; + Php::out << (v1 == v13) << std::endl; + Php::out << (v1 == v14) << std::endl; + Php::out << (v1 == v15) << std::endl; + + Php::out << (v13 == v14) << std::endl; + Php::out << (v13 == v15) << std::endl; + Php::out << (v14 == v15) << std::endl; + } + + /* + * Test bool Value::operator< (const Value &value) const + */ + void test_compare2() + { + Php::Value v1(5), v2(5.0), v3("5"), v4("5.0"); + + Php::out << "false:" << std::endl; + Php::out << (v1 < v2) << std::endl; + Php::out << (v1 < v3) << std::endl; + Php::out << (v1 < v4) << std::endl; + Php::out << (v2 < v1) << std::endl; + Php::out << (v2 < v3) << std::endl; + Php::out << (v2 < v4) << std::endl; + Php::out << (v3 < v1) << std::endl; + Php::out << (v3 < v2) << std::endl; + Php::out << (v3 < v4) << std::endl; + Php::out << (v4 < v1) << std::endl; + Php::out << (v4 < v2) << std::endl; + Php::out << (v4 < v3) << std::endl; + + Php::Value v5(6), v6(6.0), v7("6"), v8("6.0"); + + Php::out << "true:" << std::endl; + Php::out << (v1 < v5) << std::endl; + Php::out << (v1 < v6) << std::endl; + Php::out << (v1 < v7) << std::endl; + Php::out << (v1 < v8) << std::endl; + + Php::out << (v2 < v5) << std::endl; + Php::out << (v2 < v6) << std::endl; + Php::out << (v2 < v7) << std::endl; + Php::out << (v2 < v8) << std::endl; + + Php::out << (v3 < v5) << std::endl; + Php::out << (v3 < v6) << std::endl; + Php::out << (v3 < v7) << std::endl; + Php::out << (v3 < v8) << std::endl; + + Php::out << (v4 < v5) << std::endl; + Php::out << (v4 < v6) << std::endl; + Php::out << (v4 < v7) << std::endl; + Php::out << (v4 < v8) << std::endl; + + Php::out << "false:" << std::endl; + Php::out << (v1 > v5) << std::endl; + Php::out << (v1 > v6) << std::endl; + Php::out << (v1 > v7) << std::endl; + Php::out << (v1 > v8) << std::endl; + + Php::out << (v2 > v5) << std::endl; + Php::out << (v2 > v6) << std::endl; + Php::out << (v2 > v7) << std::endl; + Php::out << (v2 > v8) << std::endl; + + Php::out << (v3 > v5) << std::endl; + Php::out << (v3 > v6) << std::endl; + Php::out << (v3 > v7) << std::endl; + Php::out << (v3 > v8) << std::endl; + + Php::out << (v4 > v5) << std::endl; + Php::out << (v4 > v6) << std::endl; + Php::out << (v4 > v7) << std::endl; + Php::out << (v4 > v8) << std::endl; + + Php::Value v9, v10, v11, v12; + v9[0] = 5; + v9[1] = 6; + + v10[0] = 5; + v10[1] = "Hello!"; + + v11[0] = 5; + v11[1] = 6; + + v12[0] = 5; + + Php::out << "Compare array:" << std::endl; + Php::out << (v1 < v9) << std::endl; + Php::out << (v5 < v9) << std::endl; + Php::out << (v9 < v10) << std::endl; + Php::out << (v9 > v10) << std::endl; + Php::out << (v11 < v9) << std::endl; + Php::out << (v12 < v9) << std::endl; + + Php::Value v13 = false, v14, v15 = 0; + Php::out << "Compare NULL:" << std::endl; + Php::out << (v1 < v13) << std::endl; + Php::out << (v1 < v14) << std::endl; + Php::out << (v1 < v15) << std::endl; + + Php::out << (v1 > v13) << std::endl; + Php::out << (v1 > v14) << std::endl; + Php::out << (v1 > v15) << std::endl; + + Php::out << (v13 < v14) << std::endl; + Php::out << (v13 < v15) << std::endl; + Php::out << (v14 < v15) << std::endl; + } + +/** + * End of namespace + */ +} + diff --git a/tests/cpp/main.cpp b/tests/cpp/main.cpp index 37ba5ed..47cd90d 100644 --- a/tests/cpp/main.cpp +++ b/tests/cpp/main.cpp @@ -125,6 +125,9 @@ extern "C" extension.add("TestVariables\\post_raw1", TestVariables::post_raw1); extension.add("TestVariables\\post_raw2", TestVariables::post_raw2); extension.add("TestVariables\\test_env", TestVariables::test_env); + extension.add("TestVariables\\test_compare1", TestVariables::test_compare1); + extension.add("TestVariables\\test_compare2", TestVariables::test_compare2); + |