From: Leandro Lucarella Date: Sun, 17 Aug 2003 00:52:55 +0000 (+0000) Subject: Added STL stack and vector tests. X-Git-Tag: svn_import~10 X-Git-Url: https://git.llucax.com/software/bife/bife%20%20.git/commitdiff_plain/817c277132c9de6cf976cea6d71abe375ccdd081/software/bife/bife++.git/commitdiff_plain/817c277132c9de6cf976cea6d71abe375ccdd081?hp=efa6c9315719fc0b98483abdc26341d061b4a4b4 Added STL stack and vector tests. --- diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_stack.cpp b/tests/test_stack.cpp new file mode 100644 index 0000000..ec6ebf8 --- /dev/null +++ b/tests/test_stack.cpp @@ -0,0 +1,34 @@ +#include +#include +#include + +using namespace std; + +int main(void) { + cout << "Pila comun..." << endl; + stack st; + st.push("Hola mundo"); + string s1 = "String 1"; + st.push(s1); + s1 += " "; + cout << "Primer elemento: " << st.top() << endl; + st.pop(); + cout << "Segundo elemento: " << st.top() << endl; + st.pop(); + cout << endl; + + cout << "Pila de punteros..." << endl; + stack stp; + string s = "Hola mundo"; + stp.push(&s); + //vp.push_back("Hola mundo"); + s1 = "String 1"; + stp.push(&s1); + s1 += " "; + while (!stp.empty()) { + cout << *(stp.top()) << endl; + stp.pop(); + } + return 0; +} + diff --git a/tests/test_vector.cpp b/tests/test_vector.cpp new file mode 100644 index 0000000..35b373f --- /dev/null +++ b/tests/test_vector.cpp @@ -0,0 +1,32 @@ +#include +#include +#include + +using namespace std; + +int main(void) { + cout << "Vector comun..." << endl; + vector v; + v.push_back("Hola mundo"); + string s1 = "String 1"; + v.push_back(s1); + s1 += " "; + for (vector::const_iterator i = v.begin(); i != v.end(); i++) { + cout << "Primer elemento: " << *i << endl; + } + cout << endl; + + cout << "Vector de punteros..." << endl; + vector vp; + string s = "Hola mundo"; + vp.push_back(&s); + //vp.push_back("Hola mundo"); + s1 = "String 1"; + vp.push_back(&s1); + s1 += " "; + for (vector::const_iterator i = vp.begin(); i != vp.end(); i++) { + cout << "Primer elemento: " << **i << endl; + } + return 0; +} +