From 708a22fae15b13db871ca5ffc73004c70f0584fe Mon Sep 17 00:00:00 2001 From: valmat Date: Fri, 28 Mar 2014 19:00:17 +0600 Subject: Changed the structure of the test file. With the increasing number of tests the old structure became uncomfortable. --- tests/cpp/include/valueiterator/001-006.h | 27 +++++++++++++++++++ tests/cpp/include/valueiterator/007.h | 44 +++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 tests/cpp/include/valueiterator/001-006.h create mode 100644 tests/cpp/include/valueiterator/007.h (limited to 'tests/cpp/include/valueiterator') diff --git a/tests/cpp/include/valueiterator/001-006.h b/tests/cpp/include/valueiterator/001-006.h new file mode 100644 index 0000000..0dc6778 --- /dev/null +++ b/tests/cpp/include/valueiterator/001-006.h @@ -0,0 +1,27 @@ +/** + * + * TestValueIterator + * test valueiterator/001.phpt-valueiterator/006.phpt + * + */ + +/** + * Set up namespace + */ +namespace TestValueIterator { + + + void loopValue(Php::Parameters ¶ms) + { + std::cout << "Array/Object contains " << params[0].size() << " items" << std::endl; + for (auto it=params[0].begin(), itend = params[0].end(); it != itend; ++it) { + std::cout << "["<< it->first << "]="<< it->second << std::endl; + //std::cout << "["<< it->key() << "]="<< it->value() << std::endl; + } + return; + } +/** + * End of namespace + */ +} + diff --git a/tests/cpp/include/valueiterator/007.h b/tests/cpp/include/valueiterator/007.h new file mode 100644 index 0000000..3cfcb59 --- /dev/null +++ b/tests/cpp/include/valueiterator/007.h @@ -0,0 +1,44 @@ +/** + * + * TestValueIterator + * test valueiterator/007.phpt + * + */ + +/** + * Set up namespace + */ +namespace TestValueIterator { + + void loopArray(void) + { + + Php::Value value; + /* + If we fill the array in this form, we get the following: + *** Error in `/usr/bin/php': double free or corruption (fasttop): 0x0000000001956d60 *** + value[0] = "val0"; + value[1] = "val1"; + value["third"] = "val3"; + value["fourth"] = "val3"; + */ + value.set(0 , "val0"); + value.set(1 , "val1"); + value.set("third" , "val3"); + value.set("fourth", "val3"); + + std::cout << "Array/Object contains " << value.size() << " items" << std::endl; + // assum the value variable holds an array or object, it then + // is possible to iterator over the values or properties + for (auto &iter : value) + { + // output key and value + Php::out << "["<< iter.first << "]="<< iter.second << std::endl; + } + } + +/** + * End of namespace + */ +} + -- cgit v1.2.3