Annotation of embedaddon/php/ext/standard/tests/file/fgetc_basic.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test fgetc() function : basic functionality
        !             3: --FILE--
        !             4: <?php
        !             5: /*
        !             6:  Prototype: string fgetc ( resource $handle );
        !             7:  Description: Gets character from file pointer
        !             8: */
        !             9: // include the header for common test function 
        !            10: include ("file.inc");
        !            11: 
        !            12: echo "*** Testing fgetc() : basic operations ***\n";
        !            13: /* read charecter from different files which are opened in different modes */
        !            14: $file_modes = array( "r", "rb", "rt", "r+", "r+b", "r+t");
        !            15: 
        !            16: /* create file with following type of contents */
        !            17: $file_content_types = array("numeric", "text", "text_with_new_line");
        !            18: 
        !            19: for($outerloop_counter = 0; $outerloop_counter < count($file_content_types); $outerloop_counter++) {
        !            20:   echo "--- Outerloop iteration ";
        !            21:   echo $outerloop_counter + 1;
        !            22:   echo " ---\n";
        !            23:   // create file file 
        !            24:   create_files(dirname(__FILE__), 1, $file_content_types[$outerloop_counter], 0755, 1, "w", "fgetc_basic", 1);
        !            25:  
        !            26:   //open the file in different modes and check the working of fgetc
        !            27:   for($innerloop_counter = 0; $innerloop_counter < count($file_modes); $innerloop_counter++) {
        !            28:     echo "-- Innerloop iteration ";
        !            29:     echo $innerloop_counter + 1;
        !            30:     echo " of Outerloop Iteration ";
        !            31:     echo $outerloop_counter + 1;
        !            32:     echo " --\n";
        !            33:      
        !            34:     // open the file using the $file_modes
        !            35:     $filename = dirname(__FILE__)."/fgetc_basic1.tmp"; // file name that is created by create_files
        !            36:     echo "-- Testing fgetc() : file opened using $file_modes[$innerloop_counter] mode --\n";
        !            37:     $file_handle = fopen($filename, $file_modes[$innerloop_counter]);
        !            38:     if ( !$file_handle ) {
        !            39:       echo "Error: failed to open file $filename!";
        !            40:       exit();
        !            41:     }
        !            42: 
        !            43:     // perform the read file at least 6 char and check 
        !            44:     for( $counter = 1; $counter <= 6; $counter++ ) {
        !            45:       // read data from the file and check, file pointer position, feof etc
        !            46:       var_dump( fgetc($file_handle) ); // read a char
        !            47:       var_dump( ftell($file_handle) ); // file pointer position
        !            48:       var_dump( feof($file_handle) );  // is it eof()
        !            49:       var_dump($file_handle); // dump the $file_handle to see if any thing got modifed 
        !            50:     } // end of for
        !            51:     
        !            52:     // close the file 
        !            53:     fclose ( $file_handle);
        !            54: 
        !            55:   } // end of innerloop for
        !            56:   
        !            57:   // delete the file
        !            58:   delete_files(dirname(__FILE__), 1, "fgetc_basic", 1, ".tmp");
        !            59: 
        !            60: } // end of outerloop for
        !            61: 
        !            62: echo "Done\n";
        !            63: ?>
        !            64: --EXPECTF--
        !            65: *** Testing fgetc() : basic operations ***
        !            66: --- Outerloop iteration 1 ---
        !            67: -- Innerloop iteration 1 of Outerloop Iteration 1 --
        !            68: -- Testing fgetc() : file opened using r mode --
        !            69: string(1) "2"
        !            70: int(1)
        !            71: bool(false)
        !            72: resource(%d) of type (stream)
        !            73: string(1) "2"
        !            74: int(2)
        !            75: bool(false)
        !            76: resource(%d) of type (stream)
        !            77: string(1) "2"
        !            78: int(3)
        !            79: bool(false)
        !            80: resource(%d) of type (stream)
        !            81: string(1) "2"
        !            82: int(4)
        !            83: bool(false)
        !            84: resource(%d) of type (stream)
        !            85: string(1) "2"
        !            86: int(5)
        !            87: bool(false)
        !            88: resource(%d) of type (stream)
        !            89: string(1) "2"
        !            90: int(6)
        !            91: bool(false)
        !            92: resource(%d) of type (stream)
        !            93: -- Innerloop iteration 2 of Outerloop Iteration 1 --
        !            94: -- Testing fgetc() : file opened using rb mode --
        !            95: string(1) "2"
        !            96: int(1)
        !            97: bool(false)
        !            98: resource(%d) of type (stream)
        !            99: string(1) "2"
        !           100: int(2)
        !           101: bool(false)
        !           102: resource(%d) of type (stream)
        !           103: string(1) "2"
        !           104: int(3)
        !           105: bool(false)
        !           106: resource(%d) of type (stream)
        !           107: string(1) "2"
        !           108: int(4)
        !           109: bool(false)
        !           110: resource(%d) of type (stream)
        !           111: string(1) "2"
        !           112: int(5)
        !           113: bool(false)
        !           114: resource(%d) of type (stream)
        !           115: string(1) "2"
        !           116: int(6)
        !           117: bool(false)
        !           118: resource(%d) of type (stream)
        !           119: -- Innerloop iteration 3 of Outerloop Iteration 1 --
        !           120: -- Testing fgetc() : file opened using rt mode --
        !           121: string(1) "2"
        !           122: int(1)
        !           123: bool(false)
        !           124: resource(%d) of type (stream)
        !           125: string(1) "2"
        !           126: int(2)
        !           127: bool(false)
        !           128: resource(%d) of type (stream)
        !           129: string(1) "2"
        !           130: int(3)
        !           131: bool(false)
        !           132: resource(%d) of type (stream)
        !           133: string(1) "2"
        !           134: int(4)
        !           135: bool(false)
        !           136: resource(%d) of type (stream)
        !           137: string(1) "2"
        !           138: int(5)
        !           139: bool(false)
        !           140: resource(%d) of type (stream)
        !           141: string(1) "2"
        !           142: int(6)
        !           143: bool(false)
        !           144: resource(%d) of type (stream)
        !           145: -- Innerloop iteration 4 of Outerloop Iteration 1 --
        !           146: -- Testing fgetc() : file opened using r+ mode --
        !           147: string(1) "2"
        !           148: int(1)
        !           149: bool(false)
        !           150: resource(%d) of type (stream)
        !           151: string(1) "2"
        !           152: int(2)
        !           153: bool(false)
        !           154: resource(%d) of type (stream)
        !           155: string(1) "2"
        !           156: int(3)
        !           157: bool(false)
        !           158: resource(%d) of type (stream)
        !           159: string(1) "2"
        !           160: int(4)
        !           161: bool(false)
        !           162: resource(%d) of type (stream)
        !           163: string(1) "2"
        !           164: int(5)
        !           165: bool(false)
        !           166: resource(%d) of type (stream)
        !           167: string(1) "2"
        !           168: int(6)
        !           169: bool(false)
        !           170: resource(%d) of type (stream)
        !           171: -- Innerloop iteration 5 of Outerloop Iteration 1 --
        !           172: -- Testing fgetc() : file opened using r+b mode --
        !           173: string(1) "2"
        !           174: int(1)
        !           175: bool(false)
        !           176: resource(%d) of type (stream)
        !           177: string(1) "2"
        !           178: int(2)
        !           179: bool(false)
        !           180: resource(%d) of type (stream)
        !           181: string(1) "2"
        !           182: int(3)
        !           183: bool(false)
        !           184: resource(%d) of type (stream)
        !           185: string(1) "2"
        !           186: int(4)
        !           187: bool(false)
        !           188: resource(%d) of type (stream)
        !           189: string(1) "2"
        !           190: int(5)
        !           191: bool(false)
        !           192: resource(%d) of type (stream)
        !           193: string(1) "2"
        !           194: int(6)
        !           195: bool(false)
        !           196: resource(%d) of type (stream)
        !           197: -- Innerloop iteration 6 of Outerloop Iteration 1 --
        !           198: -- Testing fgetc() : file opened using r+t mode --
        !           199: string(1) "2"
        !           200: int(1)
        !           201: bool(false)
        !           202: resource(%d) of type (stream)
        !           203: string(1) "2"
        !           204: int(2)
        !           205: bool(false)
        !           206: resource(%d) of type (stream)
        !           207: string(1) "2"
        !           208: int(3)
        !           209: bool(false)
        !           210: resource(%d) of type (stream)
        !           211: string(1) "2"
        !           212: int(4)
        !           213: bool(false)
        !           214: resource(%d) of type (stream)
        !           215: string(1) "2"
        !           216: int(5)
        !           217: bool(false)
        !           218: resource(%d) of type (stream)
        !           219: string(1) "2"
        !           220: int(6)
        !           221: bool(false)
        !           222: resource(%d) of type (stream)
        !           223: --- Outerloop iteration 2 ---
        !           224: -- Innerloop iteration 1 of Outerloop Iteration 2 --
        !           225: -- Testing fgetc() : file opened using r mode --
        !           226: string(1) "t"
        !           227: int(1)
        !           228: bool(false)
        !           229: resource(%d) of type (stream)
        !           230: string(1) "e"
        !           231: int(2)
        !           232: bool(false)
        !           233: resource(%d) of type (stream)
        !           234: string(1) "x"
        !           235: int(3)
        !           236: bool(false)
        !           237: resource(%d) of type (stream)
        !           238: string(1) "t"
        !           239: int(4)
        !           240: bool(false)
        !           241: resource(%d) of type (stream)
        !           242: string(1) " "
        !           243: int(5)
        !           244: bool(false)
        !           245: resource(%d) of type (stream)
        !           246: string(1) "t"
        !           247: int(6)
        !           248: bool(false)
        !           249: resource(%d) of type (stream)
        !           250: -- Innerloop iteration 2 of Outerloop Iteration 2 --
        !           251: -- Testing fgetc() : file opened using rb mode --
        !           252: string(1) "t"
        !           253: int(1)
        !           254: bool(false)
        !           255: resource(%d) of type (stream)
        !           256: string(1) "e"
        !           257: int(2)
        !           258: bool(false)
        !           259: resource(%d) of type (stream)
        !           260: string(1) "x"
        !           261: int(3)
        !           262: bool(false)
        !           263: resource(%d) of type (stream)
        !           264: string(1) "t"
        !           265: int(4)
        !           266: bool(false)
        !           267: resource(%d) of type (stream)
        !           268: string(1) " "
        !           269: int(5)
        !           270: bool(false)
        !           271: resource(%d) of type (stream)
        !           272: string(1) "t"
        !           273: int(6)
        !           274: bool(false)
        !           275: resource(%d) of type (stream)
        !           276: -- Innerloop iteration 3 of Outerloop Iteration 2 --
        !           277: -- Testing fgetc() : file opened using rt mode --
        !           278: string(1) "t"
        !           279: int(1)
        !           280: bool(false)
        !           281: resource(%d) of type (stream)
        !           282: string(1) "e"
        !           283: int(2)
        !           284: bool(false)
        !           285: resource(%d) of type (stream)
        !           286: string(1) "x"
        !           287: int(3)
        !           288: bool(false)
        !           289: resource(%d) of type (stream)
        !           290: string(1) "t"
        !           291: int(4)
        !           292: bool(false)
        !           293: resource(%d) of type (stream)
        !           294: string(1) " "
        !           295: int(5)
        !           296: bool(false)
        !           297: resource(%d) of type (stream)
        !           298: string(1) "t"
        !           299: int(6)
        !           300: bool(false)
        !           301: resource(%d) of type (stream)
        !           302: -- Innerloop iteration 4 of Outerloop Iteration 2 --
        !           303: -- Testing fgetc() : file opened using r+ mode --
        !           304: string(1) "t"
        !           305: int(1)
        !           306: bool(false)
        !           307: resource(%d) of type (stream)
        !           308: string(1) "e"
        !           309: int(2)
        !           310: bool(false)
        !           311: resource(%d) of type (stream)
        !           312: string(1) "x"
        !           313: int(3)
        !           314: bool(false)
        !           315: resource(%d) of type (stream)
        !           316: string(1) "t"
        !           317: int(4)
        !           318: bool(false)
        !           319: resource(%d) of type (stream)
        !           320: string(1) " "
        !           321: int(5)
        !           322: bool(false)
        !           323: resource(%d) of type (stream)
        !           324: string(1) "t"
        !           325: int(6)
        !           326: bool(false)
        !           327: resource(%d) of type (stream)
        !           328: -- Innerloop iteration 5 of Outerloop Iteration 2 --
        !           329: -- Testing fgetc() : file opened using r+b mode --
        !           330: string(1) "t"
        !           331: int(1)
        !           332: bool(false)
        !           333: resource(%d) of type (stream)
        !           334: string(1) "e"
        !           335: int(2)
        !           336: bool(false)
        !           337: resource(%d) of type (stream)
        !           338: string(1) "x"
        !           339: int(3)
        !           340: bool(false)
        !           341: resource(%d) of type (stream)
        !           342: string(1) "t"
        !           343: int(4)
        !           344: bool(false)
        !           345: resource(%d) of type (stream)
        !           346: string(1) " "
        !           347: int(5)
        !           348: bool(false)
        !           349: resource(%d) of type (stream)
        !           350: string(1) "t"
        !           351: int(6)
        !           352: bool(false)
        !           353: resource(%d) of type (stream)
        !           354: -- Innerloop iteration 6 of Outerloop Iteration 2 --
        !           355: -- Testing fgetc() : file opened using r+t mode --
        !           356: string(1) "t"
        !           357: int(1)
        !           358: bool(false)
        !           359: resource(%d) of type (stream)
        !           360: string(1) "e"
        !           361: int(2)
        !           362: bool(false)
        !           363: resource(%d) of type (stream)
        !           364: string(1) "x"
        !           365: int(3)
        !           366: bool(false)
        !           367: resource(%d) of type (stream)
        !           368: string(1) "t"
        !           369: int(4)
        !           370: bool(false)
        !           371: resource(%d) of type (stream)
        !           372: string(1) " "
        !           373: int(5)
        !           374: bool(false)
        !           375: resource(%d) of type (stream)
        !           376: string(1) "t"
        !           377: int(6)
        !           378: bool(false)
        !           379: resource(%d) of type (stream)
        !           380: --- Outerloop iteration 3 ---
        !           381: -- Innerloop iteration 1 of Outerloop Iteration 3 --
        !           382: -- Testing fgetc() : file opened using r mode --
        !           383: string(1) "l"
        !           384: int(1)
        !           385: bool(false)
        !           386: resource(%d) of type (stream)
        !           387: string(1) "i"
        !           388: int(2)
        !           389: bool(false)
        !           390: resource(%d) of type (stream)
        !           391: string(1) "n"
        !           392: int(3)
        !           393: bool(false)
        !           394: resource(%d) of type (stream)
        !           395: string(1) "e"
        !           396: int(4)
        !           397: bool(false)
        !           398: resource(%d) of type (stream)
        !           399: string(1) "
        !           400: "
        !           401: int(5)
        !           402: bool(false)
        !           403: resource(%d) of type (stream)
        !           404: string(1) "l"
        !           405: int(6)
        !           406: bool(false)
        !           407: resource(%d) of type (stream)
        !           408: -- Innerloop iteration 2 of Outerloop Iteration 3 --
        !           409: -- Testing fgetc() : file opened using rb mode --
        !           410: string(1) "l"
        !           411: int(1)
        !           412: bool(false)
        !           413: resource(%d) of type (stream)
        !           414: string(1) "i"
        !           415: int(2)
        !           416: bool(false)
        !           417: resource(%d) of type (stream)
        !           418: string(1) "n"
        !           419: int(3)
        !           420: bool(false)
        !           421: resource(%d) of type (stream)
        !           422: string(1) "e"
        !           423: int(4)
        !           424: bool(false)
        !           425: resource(%d) of type (stream)
        !           426: string(1) "
        !           427: "
        !           428: int(5)
        !           429: bool(false)
        !           430: resource(%d) of type (stream)
        !           431: string(1) "l"
        !           432: int(6)
        !           433: bool(false)
        !           434: resource(%d) of type (stream)
        !           435: -- Innerloop iteration 3 of Outerloop Iteration 3 --
        !           436: -- Testing fgetc() : file opened using rt mode --
        !           437: string(1) "l"
        !           438: int(1)
        !           439: bool(false)
        !           440: resource(%d) of type (stream)
        !           441: string(1) "i"
        !           442: int(2)
        !           443: bool(false)
        !           444: resource(%d) of type (stream)
        !           445: string(1) "n"
        !           446: int(3)
        !           447: bool(false)
        !           448: resource(%d) of type (stream)
        !           449: string(1) "e"
        !           450: int(4)
        !           451: bool(false)
        !           452: resource(%d) of type (stream)
        !           453: string(1) "
        !           454: "
        !           455: int(5)
        !           456: bool(false)
        !           457: resource(%d) of type (stream)
        !           458: string(1) "l"
        !           459: int(6)
        !           460: bool(false)
        !           461: resource(%d) of type (stream)
        !           462: -- Innerloop iteration 4 of Outerloop Iteration 3 --
        !           463: -- Testing fgetc() : file opened using r+ mode --
        !           464: string(1) "l"
        !           465: int(1)
        !           466: bool(false)
        !           467: resource(%d) of type (stream)
        !           468: string(1) "i"
        !           469: int(2)
        !           470: bool(false)
        !           471: resource(%d) of type (stream)
        !           472: string(1) "n"
        !           473: int(3)
        !           474: bool(false)
        !           475: resource(%d) of type (stream)
        !           476: string(1) "e"
        !           477: int(4)
        !           478: bool(false)
        !           479: resource(%d) of type (stream)
        !           480: string(1) "
        !           481: "
        !           482: int(5)
        !           483: bool(false)
        !           484: resource(%d) of type (stream)
        !           485: string(1) "l"
        !           486: int(6)
        !           487: bool(false)
        !           488: resource(%d) of type (stream)
        !           489: -- Innerloop iteration 5 of Outerloop Iteration 3 --
        !           490: -- Testing fgetc() : file opened using r+b mode --
        !           491: string(1) "l"
        !           492: int(1)
        !           493: bool(false)
        !           494: resource(%d) of type (stream)
        !           495: string(1) "i"
        !           496: int(2)
        !           497: bool(false)
        !           498: resource(%d) of type (stream)
        !           499: string(1) "n"
        !           500: int(3)
        !           501: bool(false)
        !           502: resource(%d) of type (stream)
        !           503: string(1) "e"
        !           504: int(4)
        !           505: bool(false)
        !           506: resource(%d) of type (stream)
        !           507: string(1) "
        !           508: "
        !           509: int(5)
        !           510: bool(false)
        !           511: resource(%d) of type (stream)
        !           512: string(1) "l"
        !           513: int(6)
        !           514: bool(false)
        !           515: resource(%d) of type (stream)
        !           516: -- Innerloop iteration 6 of Outerloop Iteration 3 --
        !           517: -- Testing fgetc() : file opened using r+t mode --
        !           518: string(1) "l"
        !           519: int(1)
        !           520: bool(false)
        !           521: resource(%d) of type (stream)
        !           522: string(1) "i"
        !           523: int(2)
        !           524: bool(false)
        !           525: resource(%d) of type (stream)
        !           526: string(1) "n"
        !           527: int(3)
        !           528: bool(false)
        !           529: resource(%d) of type (stream)
        !           530: string(1) "e"
        !           531: int(4)
        !           532: bool(false)
        !           533: resource(%d) of type (stream)
        !           534: string(1) "
        !           535: "
        !           536: int(5)
        !           537: bool(false)
        !           538: resource(%d) of type (stream)
        !           539: string(1) "l"
        !           540: int(6)
        !           541: bool(false)
        !           542: resource(%d) of type (stream)
        !           543: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>