Annotation of embedaddon/php/ext/standard/tests/file/fgets_variation4-win32.phpt, revision 1.1

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

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