Home | History | Annotate | Download | only in String
      1 /*
      2 * The contents of this file are subject to the Netscape Public
      3 * License Version 1.1 (the "License"); you may not use this file
      4 * except in compliance with the License. You may obtain a copy of
      5 * the License at http://www.mozilla.org/NPL/
      6 *
      7 * Software distributed under the License is distributed on an "AS
      8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
      9 * implied. See the License for the specific language governing
     10 * rights and limitations under the License.
     11 *
     12 * The Original Code is mozilla.org code.
     13 *
     14 * The Initial Developer of the Original Code is Netscape
     15 * Communications Corporation.  Portions created by Netscape are
     16 * Copyright (C) 1998 Netscape Communications Corporation.
     17 * All Rights Reserved.
     18 *
     19 * Contributor(s): ajvincent (at) hotmail.com, pschwartau (at) netscape.com
     20 * Date: 31 October 2001
     21 *
     22 * SUMMARY: Regression test for bug 107771
     23 * See http://bugzilla.mozilla.org/show_bug.cgi?id=107771
     24 *
     25 * The bug: Section 1 passed, but Sections 2-5 all failed with |actual| == 12
     26 */
     27 //-----------------------------------------------------------------------------
     28 var UBound = 0;
     29 var bug = 107771;
     30 var summary = "Regression test for bug 107771";
     31 var status = '';
     32 var statusitems = [];
     33 var actual = '';
     34 var actualvalues = [];
     35 var expect= '';
     36 var expectedvalues = [];
     37 var str = '';
     38 var k = -9999;
     39 
     40 
     41 status = inSection(1);
     42 str = "AAA//BBB/CCC/";
     43 k = str.lastIndexOf('/');
     44 actual = k;
     45 expect = 12;
     46 
     47 status = inSection(2);
     48 str = str.substring(0, k);
     49 k = str.lastIndexOf('/');
     50 actual = k;
     51 expect = 8;
     52 addThis();
     53 
     54 status = inSection(3);
     55 str = str.substring(0, k);
     56 k = str.lastIndexOf('/');
     57 actual = k;
     58 expect = 4;
     59 addThis();
     60 
     61 status = inSection(4);
     62 str = str.substring(0, k);
     63 k = str.lastIndexOf('/');
     64 actual = k;
     65 expect = 3;
     66 addThis();
     67 
     68 status = inSection(5);
     69 str = str.substring(0, k);
     70 k = str.lastIndexOf('/');
     71 actual = k;
     72 expect = -1;
     73 addThis();
     74 
     75 
     76 
     77 //-----------------------------------------------------------------------------
     78 test();
     79 //-----------------------------------------------------------------------------
     80 
     81 
     82 
     83 function addThis()
     84 {
     85   statusitems[UBound] = status;
     86   actualvalues[UBound] = actual;
     87   expectedvalues[UBound] = expect;
     88   UBound++;
     89 }
     90 
     91 
     92 function test()
     93 {
     94   enterFunc ('test');
     95   printBugNumber (bug);
     96   printStatus (summary);
     97 
     98   for (var i=0; i<UBound; i++)
     99   {
    100     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
    101   }
    102 
    103   exitFunc ('test');
    104 }
    105