From: <mie...@us...> - 2007-10-10 04:24:03
|
Revision: 919 http://oorexx.svn.sourceforge.net/oorexx/?rev=919&view=rev Author: miesfeld Date: 2007-10-09 21:24:07 -0700 (Tue, 09 Oct 2007) Log Message: ----------- Apply [ 1810164 ] Need testUnit for TimeSpan Supplied by Lee Peedin. Thanks Lee. Modified Paths: -------------- test/trunk/tests/oorexxunit/ooRexx/extensions/platform/windows/rxwinsys/ooRexx.Extensions.Platform.Windows.RxWinSys.Clipboard.testUnit Added Paths: ----------- test/trunk/tests/oorexxunit/ooRexx/base/class/ooRexx.Base.Class.TimeSpan.testUnit Added: test/trunk/tests/oorexxunit/ooRexx/base/class/ooRexx.Base.Class.TimeSpan.testUnit =================================================================== --- test/trunk/tests/oorexxunit/ooRexx/base/class/ooRexx.Base.Class.TimeSpan.testUnit (rev 0) +++ test/trunk/tests/oorexxunit/ooRexx/base/class/ooRexx.Base.Class.TimeSpan.testUnit 2007-10-10 04:24:07 UTC (rev 919) @@ -0,0 +1,321 @@ +#!/usr/bin/rexx +/* + name: ooRexx.Base.Class.TimeSpan.testUnit + author: Lee Peedin + date: 2007/10/09 + version: 1.0 + +-- line commented lines are ignored, when building the directory of infos from this header + changed: + + languageLevel: 6.02 + purpose: Test the methods of the class TimeSpan class. + remark: --- + + license: CPL 1.0 (Common Public License v1.0, see below) + link: + +// category needs not to be numbered, importance is given by position (1=most important) + category: ooRexx + category: Base + category: Class + category: TimeSpan +*/ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) 2007 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.ibm.com/developerworks/oss/CPLv1.0.htm */ +/* */ +/* 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. */ +/* */ +/*----------------------------------------------------------------------------*/ + +testUnitClass=.ooRexx.Base.Class.TimeSpan.TestUnit -- change accordingly +------------------------------------------------------------------------------------------- + /* list of array objects, each containing the testUnit class object and an + optional list of mandatory test case methods name */ +mandatoryTestMethods=.list~new -- no mandatory tests for this testCase class +testUnitList=.list~of( .array~of(testUnitClass, mandatoryTestMethods) ) + + +------------------------------------------------------------------------------------------- +-- ===> the following code needs not to be individualized <=== + + -- read top comment, containing infos about this program +arrLines=.array~new +do i=1 to 150 until arrLines[i]="*/" + arrLines[i]=sourceline(i) +end + -- supply information for the testClass(es) in this file; the class attribute + -- "TestCaseInfo" (a directory object, index points to a queue) will store + -- the parsed infos +aTestUnitClass=testUnitList~at(testUnitList~first)[1] -- get first testClass + + -- will parse the array lines and store result in class object +call makeDirTestInfo aTestUnitClass, arrLines +tmpDir=aTestUnitClass~TestCaseInfo +parse source s -- op_sys invocationType fullPathToThisFile +tmpDir~setentry("test_Case-source", s) + + -- now add this directory to other testCase classes, if any left +do arr over testUnitList + if arr[1]=aTestUnitClass then iterate -- already handled + arr[1]~TestCaseInfo=tmpDir -- save info in class object +end + +-- if this file is CALLed or REQUIRED then define an entry "bRunTestLocally" in .local +-- and set it to .false; this way the independent local invocation of the tests is inhibited +if .local~hasentry("bRunTestsLocally")=.false then + .local~bRunTestsLocally=.true -- if this file is executed directly, then run tests for debugging + +if .bRunTestsLocally=.true then -- run ALL tests in this test unit +do + ts=.testSuite~new -- create a testSuite + do arr over testUnitList + -- create a testSuite for the given test case class, use all its testmethods + ts~addTest( .testSuite~new(arr[1])) + end + -- testResult=.testSuite~new(testUnitClass)~run + testResult=ts~run -- now run all the tests + +-- call simpleDumpTestResults testResult + call simpleFormatTestResults testResult +end + + /* return list of array objects containing test case classes and + optionally list of mandatory test methods */ +return testUnitList + +::requires ooRexxUnit.cls -- load the ooRexxUnit classes + +-- class named exactly like file +::class "ooRexx.Base.Class.TimeSpan.TestUnit" subclass TestCase public + +::method 'test_fromDays' + expected = '1.12:00:00.000000' + self~assertEquals('subTest1',expected,.timespan~fromDays(1.5)) + +::method 'test_fromHours' + expected = '18:00:00.000000' + self~assertEquals('subTest2',expected,.timespan~fromHours(18)) + +::method 'test_fromMinutes' + expected = '00:25:00.000000' + self~assertEquals('subTest3',expected,.timespan~fromMinutes(25)) + +::method 'test_fromSeconds' + expected = '00:00:15.000000' + self~assertEquals('subTest4',expected,.timespan~fromSeconds(15)) + +::method 'test_fromMicroSeconds' + expected = '00:00:00.000012' + self~assertEquals('subTest5',expected,.timespan~fromMicroSeconds(12)) + +::method 'test_fromNormalTime' + a_normalTime = '10:03:44' + expected = '10:03:44.000000' + self~assertEquals('subTest6',expected,.timespan~fromNormalTime(a_normalTime)) + +::method 'test_fromCivilTime' + a_civilTime = '10:11am' + expected = '10:11:00.000000' + self~assertEquals('subTest7',expected,.timespan~fromCivilTime(a_civilTime)) + +::method 'test_fromLongTime' + a_longTime = '10:14:48.546000' + expected = '10:14:48.546000' + self~assertEquals('subTest8',expected,.timespan~fromLongTime(a_longTime)) + +::method 'test_InitA' + expected = '15:37:30.000000' + self~assertEquals('subTest9',expected,.timespan~new(time('f','15:37:30','n'))) + +::method 'test_InitB' + expected = '15:37:30.000000' + self~assertEquals('subTest10',expected,.timespan~new(15,37,30)) + +::method 'test_initC' + expected = '6.04:33:15.000100' + self~assertEquals('subTest11',expected,.timespan~new(6,4,33,15,100)) + +::method 'test_ComparisonA' + a_timeSpan1 = .timespan~new(time('f','15:37:30','n')) + a_timeSpan2 = .timespan~new(15,37,30) + + expected = 1 + self~assertEquals('subTest12',expected,a_timeSpan1 == a_timeSpan2) + +::method 'test_ComparisonB' + a_timeSpan1 = .timespan~new(time('f','15:37:30','n')) + a_timeSpan2 = .timespan~new(15,37,45) + + expected = 0 + self~assertEquals('subTest13',expected,a_timeSpan1 == a_timeSpan2) + +::method 'test_CompareToA' + a_timeSpan1 = .timespan~new(time('f','15:37:30','n')) + a_timeSpan2 = .timespan~new(15,37,30) + a_timeSpan3 = .timespan~new(15,37,45) + + expected = 0 + self~assertEquals('subTest14',expected,a_timeSpan1~compareTo(a_timeSpan2)) + +::method 'test_CompareToB' + a_timeSpan1 = .timespan~new(time('f','15:37:30','n')) + a_timeSpan2 = .timespan~new(15,37,30) + a_timeSpan3 = .timespan~new(15,37,45) + + expected = -1 + self~assertEquals('subTest15',expected,a_timeSpan1~compareTo(a_timeSpan3)) + +::method 'test_CompareToC' + a_timeSpan1 = .timespan~new(time('f','15:37:30','n')) + a_timeSpan2 = .timespan~new(15,37,30) + a_timeSpan3 = .timespan~new(15,37,45) + + expected = 1 + self~assertEquals('subTest16',expected,a_timeSpan3~compareTo(a_timeSpan1)) + +::method 'test_duration' + a_timeSpan1 = .timespan~new(6,4,33,15,100) + a_timeSpan2 = .timespan~new(6,4,33,15,110) + expected = '00:00:00.000010' + self~assertEquals('subTest17',expected,(a_timeSpan2 - a_timeSpan1)~duration) + +::method 'test_days' + a_timeSpan = .timespan~new(6,4,33,15,100) + expected = 6 + self~assertEquals('subTest18',expected,a_timeSpan~days) + +::method 'test_hours' + a_timeSpan = .timespan~new(6,4,33,15,100) + expected = 4 + self~assertEquals('subTest19',expected,a_timeSpan~hours) + +::method 'test_minutes' + a_timeSpan = .timespan~new(6,4,3,5,100) + expected = 3 + self~assertEquals('subTest20',expected,a_timeSpan~minutes) + +::method 'test_seconds' + a_timeSpan = .timespan~new(6,4,3,5,100) + expected = 5 + self~assertEquals('subTest21',expected,a_timeSpan~seconds) + +::method 'test_microSeconds' + a_timeSpan = .timespan~new(6,4,33,15,100) + expected = 100 + self~assertEquals('subTest22',expected,a_timeSpan~microSeconds) + +::method 'test_totalDays' + a_timeSpan = .timespan~new(6,12,0,0,0) + expected = 6.5 + self~assertEquals('subTest23',expected,a_timeSpan~totalDays) + +---- +::method 'test_totalHours' + a_timeSpan = .timespan~new(6,12,0,0,0) + expected = 156 + self~assertEquals('subTest24',expected,a_timeSpan~totalHours) + +::method 'test_totalMinutes' + a_timeSpan = .timespan~new(6,12,15,0,0) + expected = 9375 + self~assertEquals('subTest25',expected,a_timeSpan~totalMinutes) + +::method 'test_totalSeconds' + a_timeSpan = .timespan~new(6,12,15,10,0) + expected = 562510 + self~assertEquals('subTest26',expected,a_timeSpan~totalSeconds) + +::method 'test_totalMicroSeconds' + a_timeSpan = .timespan~new(0,0,1.1) + expected = 1100000 + self~assertEquals('subTest27',expected,a_timeSpan~totalMicroSeconds) + +-- skipping hashCode + +::method 'test_addWeeks' + a_timeSpan = .timespan~new(6,4,33,15,100) + expected = '16.16:33:15.000100' + self~assertEquals('subTest28',expected,a_timeSpan~addWeeks(1.5)) + +::method 'test_addDays' + a_timeSpan = .timespan~new(6,4,33,15,100) + expected = '7.16:33:15.000100' + self~assertEquals('subTest29',expected,a_timeSpan~addDays(1.5)) + +::method 'test_addHours' + a_timeSpan = .timespan~new(6,4,33,15,100) + expected = '6.06:03:15.000100' + self~assertEquals('subTest30',expected,a_timeSpan~addHours(1.5)) + +::method 'test_addMinutes' + a_timeSpan = .timespan~new(6,4,33,15,100) + expected = '6.04:34:45.000100' + self~assertEquals('subTest31',expected,a_timeSpan~addMinutes(1.5)) + +::method 'test_addSeconds' + a_timeSpan = .timespan~new(6,4,33,15,100) + expected = '6.04:33:16.500100' + self~assertEquals('subTest32',expected,a_timeSpan~addSeconds(1.5)) + +::method 'test_addMicroSeconds' + a_timeSpan = .timespan~new(6,4,33,15,100) + expected = '6.04:33:16.000100' + self~assertEquals('subTest33',expected,a_timeSpan~addMicroSeconds(1000000)) + +::method 'test_signA' + a_timeSpan1 = .timespan~new(time('f','15:37:30','n')) + a_timeSpan2 = .timespan~new(15,37,30) + + expected = 0 + self~assertEquals('subTest34',expected,(a_timeSpan1 - a_timeSpan2)~sign) + +::method 'test_signB' + a_timeSpan1 = .timespan~new(15,37,30) + a_timeSpan2 = .timespan~new(15,37,45) + + expected = -1 + self~assertEquals('subTest35',expected,(a_timeSpan1 - a_timeSpan2)~sign) + +::method 'test_signC' + a_timeSpan1 = .timespan~new(15,37,30) + a_timeSpan2 = .timespan~new(15,37,45) + + expected = 1 + self~assertEquals('subTest35',expected,(a_timeSpan2 - a_timeSpan1)~sign) + +::method 'test_string' + a_timeSpan = .timespan~new(6,4,33,15,100) + expected = '6.04:33:15.000100' + self~assertEquals('subTest36',expected,a_timeSpan~string) + Property changes on: test/trunk/tests/oorexxunit/ooRexx/base/class/ooRexx.Base.Class.TimeSpan.testUnit ___________________________________________________________________ Name: svn:executable + * Name: svn:eol-style + LF Modified: test/trunk/tests/oorexxunit/ooRexx/extensions/platform/windows/rxwinsys/ooRexx.Extensions.Platform.Windows.RxWinSys.Clipboard.testUnit =================================================================== --- test/trunk/tests/oorexxunit/ooRexx/extensions/platform/windows/rxwinsys/ooRexx.Extensions.Platform.Windows.RxWinSys.Clipboard.testUnit 2007-10-10 04:08:15 UTC (rev 918) +++ test/trunk/tests/oorexxunit/ooRexx/extensions/platform/windows/rxwinsys/ooRexx.Extensions.Platform.Windows.RxWinSys.Clipboard.testUnit 2007-10-10 04:24:07 UTC (rev 919) @@ -17,8 +17,10 @@ // category needs not to be numbered, importance is given by position (1=most important) category: ooRexx - category: Base - category: Class + category: Extensions + category: Platform + category: Windows + category: RxWinSys category: WindowsClipboard */ /*----------------------------------------------------------------------------*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |