// -*- c++ -*- /* * Jakelib2 - General purpose C++ library * Copyright (C) 2001 Florian Wolff (florian@donuz.de) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: VectorTest.jlc,v 1.5 2003/09/26 15:55:26 florian Exp $ */ #include "Test.h" #include #include #pragma javasyntax #define outPrintLn System::out->println using namespace jakelib::lang; using namespace jakelib::util; void vectorTest() { try { jint cap = 10; Strings * str = new Strings(cap); Vector vec(cap, 1); jint i; for (i = 0; i < cap; i++) { str->set(i, "string " .. i); } outPrintLn("Vector.size() = '" .. vec.size() .. "'"); for (i = 0; i < cap; i++) { vec.addElement(str->get(i)); outPrintLn("Vector.elementAt(" .. i .. ") = '" .. vec.elementAt(i) .. "'"); } outPrintLn("Vector.size() = '" .. vec.size() .. "'"); outPrintLn("Vector.toString() = '" .. vec.toString() .. "'"); outPrintLn("Vector.contains(\"" .. str->get(0) .. "\") ? " .. vec.contains(str->get(0))?"YES":"NO" .. ""); outPrintLn("Vector.contains(\"dummy\") ? " .. vec.contains("dummy")?"YES":"NO" .. ""); for (i = 0; i < cap; i++) outPrintLn("Vector.indexOf(" .. i .. ") = '" .. vec.indexOf(str->get(i)) .. "'"); outPrintLn("Vector.isEmpty() ? '" .. vec.isEmpty()?"YES":"NO" .. "'"); for (;--i >= 0;) vec.removeElementAt(i); outPrintLn("Vector.size() = '" .. vec.size() .. "'"); outPrintLn("Vector.toString() = '" .. vec.toString() .. "'"); for (;--i >= 0;) { vec.removeElement(str->get(i)); } outPrintLn("Vector.size() = '" .. vec.size() .. "'"); vec.setSize(0); outPrintLn("Vector.size() = '" .. vec.size() .. "'"); vec.setSize(cap); outPrintLn("Vector.size() = '" .. vec.size() .. "'"); for (i = 0; i < cap; i++) { vec.setElementAt(str->get(i), i); outPrintLn("Vector.elementAt(" .. i .. ") = '" .. vec.elementAt(i) .. "'"); } } catch (Exception *ex) { outPrintLn(ex); } }