Test fann_read_train_from_file

Esse commit está contido em:
Jakub Zelenka
2013-03-03 16:31:01 +00:00
commit 416ff75ebf
3 arquivos alterados com 36 adições e 2 exclusões
+2 -1
Ver Arquivo
@@ -2,8 +2,9 @@ Generic
- output redirection (never print to STDOUT) - fann_train_on_data
- ann->callback needs to be registered otherwise printf is used
- streams for file and dir checking
- group file checking in fann_train_on_file and fann_create_from_file and possibly use php function
- check if the directory for fann_save exists and is writable
- use log error log messages when generic error is reported
- fann_read_train_from_file
- check parameters ranges
- valid contants
- FANN connection_rate param for create_sparse*
+4 -1
Ver Arquivo
@@ -1524,7 +1524,10 @@ PHP_FUNCTION(fann_read_train_from_file)
RETURN_FALSE;
}
train_data = fann_read_train_from_file(filename);
if (!train_data) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid data train file format in '%s'", filename);
RETURN_FALSE;
}
PHP_FANN_ERROR_CHECK_TRAIN_DATA();
PHP_FANN_RETURN_TRAIN_DATA();
}
+30
Ver Arquivo
@@ -0,0 +1,30 @@
--TEST--
Test function fann_read_train_from_file() by calling it with its expected arguments
--FILE--
<?php
$filename = ( dirname( __FILE__ ) . "/fann_read_train_from_file.tmp" );
$content = <<<EOF
4 2 1
-1 -1
-1
-1 1
1
1 -1
1
1 1
-1
EOF;
file_put_contents( $filename, $content );
var_dump( fann_read_train_from_file( $filename ) );
?>
--CLEAN--
<?php
$filename = ( dirname( __FILE__ ) . "/fann_read_train_from_file.tmp" );
if ( file_exists( $filename ) )
unlink( $filename );
?>
--EXPECTF--
resource(%d) of type (FANN Train Data)