Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Diff of /test/trunk/ooRexx/base/rexxutil/platform/windows/SysFileTree.testGroup [000000] .. [r9576] Maximize Restore

  Switch to side-by-side view

--- a
+++ b/test/trunk/ooRexx/base/rexxutil/platform/windows/SysFileTree.testGroup
@@ -0,0 +1,141 @@
+#!/usr/bin/rexx
+/*
+  SVN Revision: $Rev: 5144 $
+  Change Date:  $Date: 2009-09-03 22:30:46 -0700 (Thu, 03 Sep 2009) $
+*/
+/*----------------------------------------------------------------------------*/
+/*                                                                            */
+/* Copyright (c) 2013 - 2013 Rexx Language Association. All rights reserved.  */
+/*                                                                            */
+/* This program and the accompanying materials are made available under       */
+/* the terms of the Common Public License v1.0 which accompanies this         */
+/* distribution. A copy is also available at the following address:           */
+/* http://www.oorexx.org/license.html                                         */
+/*                                                                            */
+/* Redistribution and use in source and binary forms, with or                 */
+/* without modification, are permitted provided that the following            */
+/* conditions are met:                                                        */
+/*                                                                            */
+/* Redistributions of source code must retain the above copyright             */
+/* notice, this list of conditions and the following disclaimer.              */
+/* Redistributions in binary form must reproduce the above copyright          */
+/* notice, this list of conditions and the following disclaimer in            */
+/* the documentation and/or other materials provided with the distribution.   */
+/*                                                                            */
+/* Neither the name of Rexx Language Association nor the names                */
+/* of its contributors may be used to endorse or promote products             */
+/* derived from this software without specific prior written permission.      */
+/*                                                                            */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS        */
+/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT          */
+/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS          */
+/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT   */
+/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,      */
+/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED   */
+/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,        */
+/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY     */
+/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING    */
+/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS         */
+/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.               */
+/*                                                                            */
+/*----------------------------------------------------------------------------*/
+
+    parse source . . fileSpec
+
+    group = .TestGroup~new(fileSpec)
+    group~addWithSuite(.SysFileTree.testGroup, .SysFileTreeSuite)
+
+    group~restrictOS("WINDOWS")
+
+    if group~isAutomatedTest then return group
+
+    testResult = group~suite~execute~~print
+
+return testResult
+-- End of entry point.
+
+::requires 'ooTest.frm'
+
+::class 'SysFileTreeSuite' public subclass ooTestSuite
+
+::method setUp
+    expose curdir
+
+    -- We save the current directory and then change to the directory of the
+    -- test group, so that we are in a known location for the tests.
+    curDir = directory()
+
+    parse source . . fileSpec
+    newDir = FileSpec('L', fileSpec)
+    j = directory(newDir)
+
+::method tearDown
+    expose curDir
+
+    -- Change back to the current directory we were in before the tests
+    -- were run.
+    j = directory(curDir)
+
+
+
+::class 'SysFileTree.testGroup' subclass ooTestCase public
+
+::method 'testBasicSyntax1'
+    self~expectSyntax(88.901)
+    rv = SysFileTree()
+
+::method 'testBasicSyntax2'
+    self~expectSyntax(88.901)
+    rv = SysFileTree(.true)
+
+::method 'testBasicSyntax3'
+    -- 1 is a valid fileSpec
+    rv = SysFileTree(.true, files.)
+    self~assertEquals(0, rv)
+
+::method 'testBasicSyntax4'
+    -- 1 is a valid fileSpec
+    rv = SysFileTree(.true, 'cat')
+    self~assertEquals(0, rv)
+
+    -- No files named '1' should be found
+    self~assertEquals(0, cat.0)
+
+::method 'testBasicSyntax5'
+    cat = .array~new(5)
+    self~expectSyntax(40.919)
+    rv = SysFileTree(.true, cat)
+
+::method 'testIllegalChars'
+    patterns = .array~of('*.?>*', '*.?<*', '*.?|*', '*?:.', 'Sys*?".', '"Sys  Cur"*.*')
+
+    -- System error code: 123 -> ERROR_INVALID_NAME
+    do i = 1 to patterns~items
+        rv = SysFileTree(patterns[i], cat, 'F')
+        self~assertEquals(123, rv)
+        self~assertEquals(0, cat.0)
+    end
+
+::method 'testSpaces'
+    pattern = 'C:\Program Files\*.exe'
+
+    rv = SysFileTree(pattern, f, 'FS')
+    self~assertEquals(0, rv)
+    self~assertTrue(f.0 > 10)
+
+::method 'testSpacesWithQuotes'
+    -- Quotes are not needed and in fact are illegal.
+    pattern = '"C:\Program Files\*.exe"'
+
+    rv = SysFileTree(pattern, f, 'FS')
+    self~assertEquals(123, rv)
+    self~assertTrue(f.0 == 0)
+
+::method 'testLegalChars'
+    patterns = .array~of('Sys*.*', 'Sys?*.*', 'sys??*.*', 'Sys*?.*')
+
+    do i = 1 to patterns~items
+        rv = SysFileTree(patterns[i], cat, 'F')
+        self~assertEquals(0, rv)
+        self~assertTrue(cat.0 > 0, 'pattern is:' patterns[i] 'file count is:' cat.0 'dir is:' directory())
+    end