From: <pra...@us...> - 2007-12-31 18:45:14
|
Revision: 1944 http://oorexx.svn.sourceforge.net/oorexx/?rev=1944&view=rev Author: pragmatic_lee Date: 2007-12-31 10:45:17 -0800 (Mon, 31 Dec 2007) Log Message: ----------- add String_x2bMethod.testGroup Added Paths: ----------- test/branches/test.3.2.0/ooRexx/base/class/String/String_x2bMethod.testGroup Added: test/branches/test.3.2.0/ooRexx/base/class/String/String_x2bMethod.testGroup =================================================================== --- test/branches/test.3.2.0/ooRexx/base/class/String/String_x2bMethod.testGroup (rev 0) +++ test/branches/test.3.2.0/ooRexx/base/class/String/String_x2bMethod.testGroup 2007-12-31 18:45:17 UTC (rev 1944) @@ -0,0 +1,384 @@ +#!/usr/bin/rexx +/* + name: String_x2bMethod.testGroup + author: Lee Peedin + date: 2007-12-31 + version: 1.0.0 + +-- line commented lines are ignored, when building the directory of infos from this header + + languageLevel: 6.02 + purpose: Test the x2b method of the class String. + remark: Initial test unit for demonstration purposes, needs to be completed. + + 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: String +*/ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) 2007 - 2008 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. */ +/* */ +/*----------------------------------------------------------------------------*/ + + +------------------------------------------------------------------------------------------- +-- ===> adapt the "testGroupList" to your testCase classes; each element in the list is <=== +-- ===> an array object, the first element containing the testCase class object, the <=== +-- ===> second element is a list of test method names which are regarded to be <=== +-- ===> mandatory (if the list remains empty all test methods are mandatory) <=== + + /* list of array objects, each containing the testGroup class object and an + optional list of mandatory test case methods name */ +mandatoryTestMethods=.list~new -- no mandatory tests for this testCase class +testGroupList=.list~of( .array~of(.String_x2bMethod.testGroup, 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 +aTestGroupClass=testGroupList~at(testGroupList~first)[1] -- get first testClass + + -- will parse the array lines and store result in class object +call makeDirTestInfo aTestGroupClass, arrLines +tmpDir=aTestGroupClass~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 testGroupList + if arr[1]=aTestGroupClass 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 testGroupList + -- create a testSuite for the given test case class, use all its testmethods + ts~addTest( .testSuite~new(arr[1])) + end + -- testResult=.testSuite~new(testGroupClass)~run + testResult=ts~run -- now run all the tests + + call simpleFormatTestResults testResult +end + + /* return list of array objects containing test case classes and + optionally list of mandatory test methods */ +return testGroupList + +::requires ooRexxUnit.cls -- load the ooRexxUnit classes + +::class "String_x2bMethod.testGroup" subclass TestCase public + +::method 'test001' + self~assertSame('subTest01','11000011','C3'~x2b()) + +::method 'test002' + self~assertSame('subTest01','0111','7'~x2b()) + +::method 'test003' + self~assertSame('subTest01','000111000001','1 C1'~x2b()) + +::method 'test004' + self~assertSame('subTest01','11000011',c2x('C3'X)~x2b()) + +::method 'test005' + self~assertSame('subTest01','10000001',d2x('129')~x2b()) + +::method 'test006' + self~assertSame('subTest01','1100',d2x('12')~x2b()) + +::method 'test007' + self~assertSame('subTest01','0000','0'~x2b()) + +::method 'test008' + self~assertSame('subTest01','0001','1'~x2b()) + +::method 'test009' + self~assertSame('subTest01','0010','2'~x2b()) + +::method 'test010' + self~assertSame('subTest01','0011','3'~x2b()) + +::method 'test011' + self~assertSame('subTest01','0100','4'~x2b()) + +::method 'test012' + self~assertSame('subTest01','0101','5'~x2b()) + +::method 'test013' + self~assertSame('subTest01','0110','6'~x2b()) + +::method 'test014' + self~assertSame('subTest01','0111','7'~x2b()) + +::method 'test015' + self~assertSame('subTest01','1000','8'~x2b()) + +::method 'test016' + self~assertSame('subTest01','1001','9'~x2b()) + +::method 'test017' + self~assertSame('subTest01','1010','A'~x2b()) + +::method 'test018' + self~assertSame('subTest01','1011','B'~x2b()) + +::method 'test019' + self~assertSame('subTest01','1100','C'~x2b()) + +::method 'test020' + self~assertSame('subTest01','1101','D'~x2b()) + +::method 'test021' + self~assertSame('subTest01','1110','E'~x2b()) + +::method 'test022' + self~assertSame('subTest01','1111','F'~x2b()) + +::method 'test023' + self~assertSame('subTest01','0123456789ABCDEF'~x2b(),'0123456789abcdef'~x2b()) + +::method 'test024' + self~assertSame('subTest01','0123456789ABCDEF'~x2b(),'01 23 45 67 89 ab cd ef'~x2b()) + +::method 'test025' + self~assertSame('subTest01','0123456789ABCDEF'~x2b(),c2x('0123456789abcdef'x)~x2b()) + +::method 'test026' + self~assertSame('subTest01','64',length('0123456789abcdef'~x2b())) + +::method 'test027' + long_str.1 = copies('1a',255) + self~assertSame('subTest01','2040',length(long_str.1~x2b())) + +::method 'test028' + long_str.2 = copies('1a',256) + self~assertSame('subTest01','2048',length(long_str.2~x2b())) + +::method 'test029' + long_str.3 = copies('1a',32768) + self~assertSame('subTest01','262144',length(long_str.3~x2b())) + +::method 'test030' + long_str.4 = copies('1a',100000) + self~assertSame('subTest01','800000',length(long_str.4~x2b())) + +::method 'test031' + self~assertSame('subTest01','',''~x2b()) + +::method 'test032' + self~assertSame('subTest01','',''~x2b()) + +::method 'test033' + self~assertSame('subTest01','',''~x2b()) + +::method 'test034' + self~assertSame('subTest01','0000000100000010','01 02'~x2b()) + +::method 'test035' + self~assertSame('subTest01','0123456789ABCDEF'~x2b(),'0123 4567 89ab cdef'~x2b()) + +::method 'test036' + self~assertSame('subTest01','0123456789ABCDEF'~x2b(),'01234567 89abcdef'~x2b()) + +::method 'test037' + many_bl_str = '01'||copies(" ",100000)||'02' + self~assertSame('subTest01','0000000100000010',many_bl_str~x2b()) + +::method 'test038' + self~expectSyntax(93.931) + xre = '0 1'~x2b() + +::method 'test039' + self~expectSyntax(93.931) + xre = '010 2'~x2b() + +::method 'test040' + self~expectSyntax(93.931) + xre = '01 '~x2b() + +::method 'test041' + self~expectSyntax(93.931) + xre = ' 01 02'~x2b() + +::method 'test042' + self~expectSyntax(93.931) + xre = ' 0 1 0 2'~x2b() + +::method 'test043' + iv_str.1 = xrange('00'x, '29'x) + self~expectSyntax(93.933) + xre = iv_str.1~x2b() + +::method 'test044' + iv_str.2 = xrange('3A'x,'40'x) + self~expectSyntax(93.933) + xre = iv_str.2~x2b() + +::method 'test045' + iv_str.3 = xrange('47'x, '60'x) + self~expectSyntax(93.933) + xre = iv_str.3~x2b() + +::method 'test046' + iv_str.4 = xrange('67'x, 'FF'x) + self~expectSyntax(93.933) + xre = iv_str.4~x2b() + +::method 'test047' + long_iv_str.1 = '1'||copies('*',100000)||'1' + self~expectSyntax(93.933) + xre = long_iv_str.1~x2b() + +::method 'test048' + long_iv_str.2 = copies('2A'x,100000) + self~expectSyntax(93.933) + xre = long_iv_str.2~x2b() + +::method 'test049' + long_iv_str.3 = copies('5C'x,100000) + self~expectSyntax(93.933) + xre = long_iv_str.3~x2b() + +::method 'test050' + long_iv_str.4 = 'A'||copies(' ',100000) + self~expectSyntax(93.931) + xre = long_iv_str.4~x2b() + +::method 'test051' + long_iv_str.5 = copies(' ',100000)||'A' + self~expectSyntax(93.931) + xre = long_iv_str.5~x2b() + +::method 'test052' + self~expectSyntax(93.933) + xre = no_val~x2b() + +::method 'test053' + self~expectSyntax(93.933) + xre = no_val.~x2b() + +::method 'test054' + self~expectSyntax(93.933) + xre = no_val.10~x2b() + +::method 'test055' + self~expectSyntax(93.902) + xre = '1a'x~x2b('B') + +::method 'test056' + self~expectSyntax(93.902) + xre = '1a'x~x2b(copies('A',100000)) + +::method 'test057' + self~assertSame('subTest01','200000',length(b2x(copies('41',100000)~x2b()))) + +::method 'test058' + self~assertSame('subTest01','000111100010','1E2'~x2b()) + +::method 'test059' + self~expectSyntax(93.933) + xre = '1E+2'~x2b() + +::method 'test060' + self~expectSyntax(93.933) + xre = '1.77E+2'~x2b() + +::method 'test061' + self~assertSame('subTest01','000100000000',(+1E2)~x2b) + +::method 'test062' + self~assertSame('subTest01','000100000000',(+1E+2)~x2b) + +::method 'test063' + self~assertSame('subTest01','000101110111',(+1.77E2)~x2b) + +::method 'test064' + self~assertSame('subTest01','000101110111',(+1.77E+2)~x2b) + +::method 'test065' + self~assertSame('subTest01','01000010',(+42)~x2b) + +::method 'test066' + self~assertSame('subTest01','01000010',(+21*2)~x2b) + +::method 'test067' + self~assertSame('subTest01','01000010',((7*3)*2)~x2b) + +::method 'test068' + numeric digits 1 + self~assertSame('subTest01','00010000',10~x2b()) + +::method 'test069' + self~assertSame('subTest01','0001',dataType(6,'N')~x2b()) + +::method 'test070' + self~expectSyntax(93.933) + xre = dataType(6)~x2b() + +::method 'test071' + self~assertSame('subTest01','00101000',subStr('0192837465abcdefgh',4,2)~x2b()) + +-- from bif.testgroup + -- test the BIF, using examples from the documentation +::method "test_X2B" + self~assertEquals("subTest1" , '11000011' , 'C3'~X2B() ) + self~assertEquals("subTest2" , '0111' , '7'~X2B() ) + self~assertEquals("subTest3" , '000111000001' , '1 C1'~X2B()) + + -- new tests + self~assertEquals("subTest4" , '' , ''~X2B()) + self~assertEquals("subTest4" , '' , ''~X2B()) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |