Move TestExtBzip2 to a php implementation
Esse commit está contido em:
@@ -34,7 +34,6 @@
|
||||
#include "hphp/facebook/extensions/string_buffer/test_ext_string_buffer.h"
|
||||
#include "hphp/facebook/extensions/tao/test_ext_tao.h"
|
||||
#include "hphp/facebook/extensions/urlextraction/test_ext_urlextraction.h"
|
||||
#include "hphp/test/ext/test_ext_bzip2.h"
|
||||
#include "hphp/test/ext/test_ext_curl.h"
|
||||
#include "hphp/test/ext/test_ext_file.h"
|
||||
#include "hphp/test/ext/test_ext_hash.h"
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| HipHop for PHP |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#include "hphp/test/ext/test_ext_bzip2.h"
|
||||
#include "hphp/runtime/ext/ext_bzip2.h"
|
||||
|
||||
IMPLEMENT_SEP_EXTENSION_TEST(Bzip2);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TestExtBzip2::RunTests(const std::string &which) {
|
||||
bool ret = true;
|
||||
|
||||
RUN_TEST(test_bzclose);
|
||||
RUN_TEST(test_bzopen);
|
||||
RUN_TEST(test_bzread);
|
||||
RUN_TEST(test_bzwrite);
|
||||
RUN_TEST(test_bzflush);
|
||||
RUN_TEST(test_bzerrstr);
|
||||
RUN_TEST(test_bzerror);
|
||||
RUN_TEST(test_bzerrno);
|
||||
RUN_TEST(test_bzcompress);
|
||||
RUN_TEST(test_bzdecompress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TestExtBzip2::test_bzclose() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtBzip2::test_bzopen() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtBzip2::test_bzread() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtBzip2::test_bzwrite() {
|
||||
String str = "HipHop for";
|
||||
Variant bz = f_bzopen("test/test_ext_bzip2.tmp", "w");
|
||||
VERIFY(bz);
|
||||
VS(f_bzwrite(bz, str), 10);
|
||||
f_bzflush(bz);
|
||||
VERIFY(f_bzclose(bz));
|
||||
|
||||
bz = f_bzopen("test/test_ext_bzip2.tmp", "r");
|
||||
Variant ret = f_bzread(bz, 10000);
|
||||
VS(ret, str);
|
||||
VERIFY(f_bzclose(bz));
|
||||
VS(ret, str);
|
||||
f_unlink("test/test_ext_bzip2.tmp");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtBzip2::test_bzflush() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtBzip2::test_bzerrstr() {
|
||||
Variant f = f_fopen("test/test_ext_bzip2.tmp", "w");
|
||||
f_fwrite(f, "this is a test");
|
||||
f_fclose(f);
|
||||
f = f_bzopen("test/test_ext_bzip2.tmp", "r");
|
||||
f_bzread(f);
|
||||
String ret = f_bzerrstr(f);
|
||||
f_bzclose(f);
|
||||
f_unlink("test/test_ext_bzip2.tmp");
|
||||
VS(ret, "DATA_ERROR_MAGIC");
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtBzip2::test_bzerror() {
|
||||
Variant f = f_fopen("test/test_ext_bzip2.tmp", "w");
|
||||
f_fwrite(f, "this is a test");
|
||||
f_fclose(f);
|
||||
f = f_bzopen("test/test_ext_bzip2.tmp", "r");
|
||||
f_bzread(f);
|
||||
Variant ret = f_bzerror(f);
|
||||
f_bzclose(f);
|
||||
f_unlink("test/test_ext_bzip2.tmp");
|
||||
VS(ret, CREATE_MAP2("errno", -5, "errstr", "DATA_ERROR_MAGIC"));
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtBzip2::test_bzerrno() {
|
||||
Variant f = f_fopen("test/test_ext_bzip2.tmp", "w");
|
||||
f_fwrite(f, "this is a test");
|
||||
f_fclose(f);
|
||||
f = f_bzopen("test/test_ext_bzip2.tmp", "r");
|
||||
f_bzread(f);
|
||||
int ret = f_bzerrno(f);
|
||||
f_bzclose(f);
|
||||
f_unlink("test/test_ext_bzip2.tmp");
|
||||
VS(ret, -5);
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtBzip2::test_bzcompress() {
|
||||
return Count(true);
|
||||
}
|
||||
|
||||
bool TestExtBzip2::test_bzdecompress() {
|
||||
String str = "HipHop for PHP transforms PHP source code into highly optimized C++.";
|
||||
String ret;
|
||||
ret = f_bzcompress(str);
|
||||
ret = f_bzcompress(ret);
|
||||
ret = f_bzcompress(ret);
|
||||
ret = f_bzdecompress(ret);
|
||||
ret = f_bzdecompress(ret);
|
||||
ret = f_bzdecompress(ret);
|
||||
VS(ret, str);
|
||||
str = StringUtil::Repeat("x", 1000);
|
||||
ret = f_bzcompress(str);
|
||||
ret = f_bzdecompress(ret);
|
||||
VS(ret, str);
|
||||
return Count(true);
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| HipHop for PHP |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef incl_HPHP_TEST_EXT_BZIP2_H_
|
||||
#define incl_HPHP_TEST_EXT_BZIP2_H_
|
||||
|
||||
// >>>>>> Generated by idl.php. Do NOT modify. <<<<<<
|
||||
|
||||
#include "hphp/test/ext/test_cpp_ext.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class TestExtBzip2 : public TestCppExt {
|
||||
public:
|
||||
virtual bool RunTests(const std::string &which);
|
||||
|
||||
bool test_bzclose();
|
||||
bool test_bzopen();
|
||||
bool test_bzread();
|
||||
bool test_bzwrite();
|
||||
bool test_bzflush();
|
||||
bool test_bzerrstr();
|
||||
bool test_bzerror();
|
||||
bool test_bzerrno();
|
||||
bool test_bzcompress();
|
||||
bool test_bzdecompress();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // incl_HPHP_TEST_EXT_BZIP2_H_
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
$str = "Holy fuck. Are they actually going to get there?";
|
||||
|
||||
$ret = bzcompress($str);
|
||||
$ret = bzcompress($ret);
|
||||
$ret = bzcompress($ret);
|
||||
$ret = bzdecompress($ret);
|
||||
$ret = bzdecompress($ret);
|
||||
$ret = bzdecompress($ret);
|
||||
var_dump($ret === $str);
|
||||
$str = str_repeat("x", 1000);
|
||||
$ret = bzcompress($str);
|
||||
$ret = bzdecompress($ret);
|
||||
var_dump($ret === $str);
|
||||
@@ -0,0 +1,2 @@
|
||||
bool(true)
|
||||
bool(true)
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
function VS($x, $y) {
|
||||
var_dump($x === $y);
|
||||
if ($x !== $y) { echo "Failed: $y\n"; }
|
||||
}
|
||||
function VERIFY($x) { VS($x, true); }
|
||||
|
||||
$tmpfile = tempnam('/tmp', 'hhbztest.tmp');
|
||||
|
||||
function test_bzwrite() {
|
||||
global $tmpfile;
|
||||
|
||||
$str = "HipHop for";
|
||||
$bz = bzopen($tmpfile, "w");
|
||||
VERIFY($bz !== false);
|
||||
VS(bzwrite($bz, $str), 10);
|
||||
bzflush($bz);
|
||||
VERIFY(bzclose($bz));
|
||||
|
||||
$bz = bzopen($tmpfile, "r");
|
||||
$ret = bzread($bz, 10000);
|
||||
VS($ret, $str);
|
||||
VERIFY(bzclose($bz));
|
||||
VS($ret, $str);
|
||||
unlink($tmpfile);
|
||||
}
|
||||
|
||||
function test_bzerrstr() {
|
||||
global $tmpfile;
|
||||
|
||||
$f = fopen($tmpfile, "w");
|
||||
fwrite($f, "this is a test");
|
||||
fclose($f);
|
||||
$f = bzopen($tmpfile, "r");
|
||||
bzread($f);
|
||||
$ret = bzerrstr($f);
|
||||
bzclose($f);
|
||||
unlink($tmpfile);
|
||||
VS($ret, "DATA_ERROR_MAGIC");
|
||||
}
|
||||
|
||||
function test_bzerror() {
|
||||
global $tmpfile;
|
||||
|
||||
$f = fopen($tmpfile, "w");
|
||||
fwrite($f, "this is a test");
|
||||
fclose($f);
|
||||
$f = bzopen($tmpfile, "r");
|
||||
bzread($f);
|
||||
$ret = bzerror($f);
|
||||
bzclose($f);
|
||||
unlink($tmpfile);
|
||||
VS($ret, array("errno" => -5,
|
||||
"errstr" => "DATA_ERROR_MAGIC"));
|
||||
}
|
||||
|
||||
test_bzwrite();
|
||||
test_bzerrstr();
|
||||
test_bzerror();
|
||||
@@ -0,0 +1,8 @@
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
Referência em uma Nova Issue
Bloquear um usuário