root/trunk/bugs/bug-4570.php

Revision 24, 1.9 KB (checked in by m, 4 years ago)

Fixed bug 4570 completely.

  • Property svn:keywords set to Id Rev
Line 
1<?php
2
3    /**
4    * Test case for Bug #4570
5    *
6    * @see http://pear.php.net/bugs/bug.php?id=4570
7    *
8    * @author Justin "nagash" Jones <j dot nagash at gmail dot com>
9    * @version $Id$
10    * @package File_Bittorrent
11    * @subpackage Bugs
12    */
13
14require_once '../File/Bittorrent/Encode.php';
15require_once '../File/Bittorrent/Decode.php';
16$decoder = new File_Bittorrent_Decode;
17$encoder = new File_Bittorrent_Encode;
18error_reporting(E_ALL);
19
20$data = array(
21        'broken' => null,
22        'bit' => 'torrent'
23        );
24
25echo '<pre>';
26
27echo 'The data array:' . "\n";
28print_r($data);
29
30$encode1 = $encoder->encode_array($data);
31$decode1 = $decoder->decode($encode1);
32
33echo "\n" . 'First decode:' . "\n";
34print_r($decode1); // Works fine!
35
36
37
38// If you add and remove and change these things, your results will vary.
39// Sometimes I just got an empty Array, other times I got data in the wrong keys.
40// And for the worst times, it looped indefinately, but I couldn't reproduce that
41// with this data - see below for an example.'
42$decode1['bit'] = 'testing';
43$decode1['bitlength'] = strlen($decode1['bit']);
44$decode1['field'] = 'something';
45$decode1['other'] = 'whee';
46
47echo "\n" . 'New data to encode:' . "\n";
48print_r($decode1);
49
50$encode2 = $encoder->encode_array($decode1);
51$decode2 = $decoder->decode($encode2);
52
53echo "\n" . 'Second decode:' . "\n";
54print_r($decode2);
55
56$user_array = array(
57    'additional' => array(),
58    'password'   => '8943f909f9c2e98f44fa6ffa2ea470eb',
59    'pwdlength'  => 6,
60    'username'   => 'nagash',
61    'usertype'   => '3',
62);
63
64$user_array_encoded = $encoder->encode($user_array);
65echo "\n";
66echo "User_array:\n";
67var_dump($user_array);
68echo "\n\n";
69echo "Encoded user_array:\n";
70echo $user_array_encoded . "\n\n";
71echo "Decoded encoded user_array:\n";
72var_dump($decoder->decode($user_array_encoded));
73echo "\n\n";
74
75echo '</pre>';
76
77?>
Note: See TracBrowser for help on using the browser.