コード例 #1
0
ファイル: u.dvlpos.php プロジェクト: myfarms/PHPlot
function test($msg, $angle, $dist, $expect_xoff, $expect_yoff, $expected_align)
{
    global $test_debug, $tests, $fails, $error;
    $failed = False;
    $tests++;
    $p = new PHPlot_test();
    if (isset($angle)) {
        $p->data_value_label_angle = $angle;
    }
    if (isset($dist)) {
        $p->data_value_label_distance = $dist;
    }
    // 'plotin' arg always enables labels.
    $p->test_CheckDataValueLabels('plotin', $x_adj, $y_adj, $h_align, $v_align);
    $align = $h_align . $v_align;
    if ($test_debug) {
        echo "CheckDataValueLabels(angle=" . (isset($angle) ? $angle : "UNSET") . ', dist=' . (isset($dist) ? $dist : "UNSET") . ")\n  " . "offset=({$x_adj}, {$y_adj}) alignment={$align}\n";
    }
    if (!expect_equal($expected_align, $align, "{$msg} alignment", $error)) {
        $failed = True;
    }
    // Offsets need to be checked within a fuzz factor. Use 1 since the
    // function actually returns an integer number of pixels.
    if (!expect_float($expect_xoff, $x_adj, 1, "{$msg} x-offset", $error) || !expect_float($expect_yoff, $y_adj, 1, "{$msg} y-offset", $error)) {
        $failed = True;
    }
    if ($failed) {
        $fails++;
    }
}
コード例 #2
0
ファイル: u.colors.php プロジェクト: myfarms/PHPlot
function test($name, $expected, $arg)
{
    global $p, $test_verbose, $n_tests, $n_pass, $n_fail;
    $n_tests++;
    $title = "Test case {$n_tests}: {$name}";
    if ($test_verbose) {
        echo "{$title}\n";
    }
    $error = '';
    if (expect_equal($expected, $p->SetRGBColor($arg), $title, $error)) {
        $n_pass++;
    } else {
        $n_fail++;
        echo "{$error}\n";
    }
}
コード例 #3
0
ファイル: u.pmarg.php プロジェクト: myfarms/PHPlot
function test($name, $call_SetMarginsPixels, $args_SetMarginsPixels, $call_SetPlotAreaPixels, $args_SetPlotAreaPixels, $return_margins, $expected = NULL)
{
    global $test_verbose, $n_tests, $n_pass, $n_fail;
    $n_tests++;
    $result = pmarg_test($call_SetMarginsPixels, $args_SetMarginsPixels, $call_SetPlotAreaPixels, $args_SetPlotAreaPixels, $return_margins);
    $title = "Test case {$n_tests}: {$name}";
    if ($test_verbose) {
        echo "{$title} - " . ($return_margins ? "Margins=" : "PlotArea=") . implode(', ', $result) . "\n";
    }
    $error = '';
    if (empty($expected) || expect_equal($expected, $result, $title, $error)) {
        $n_pass++;
    } else {
        $n_fail++;
        echo "{$error}\n";
    }
    return $result;
}
コード例 #4
0
ファイル: u.FindDataLimits.php プロジェクト: myfarms/PHPlot
function test($name, $data_type, $plot_type, $data, $expected)
{
    global $test_verbose, $n_tests, $n_pass, $n_fail;
    $n_tests++;
    $title = "Test case {$n_tests}: {$name}";
    if ($test_verbose) {
        echo "{$title}\n";
    }
    $p = new PHPlot_test();
    // See above, for access to protected methods
    $p->SetDataType($data_type);
    $p->SetPlotType($plot_type);
    $p->SetDataValues($data);
    // For PHPlot>5.1.2 (CVS). FindDataLimits requires this.
    $p->CALL_CheckDataArray();
    // Call internal function:
    $p->CALL_FindDataLimits();
    // Get min,max x,y - cast to float for comparing
    $results = $p->GET_min_max_x_y();
    // Backward compatibility fixup(s):
    compat_1($p, $data_type, $expected);
    $error = '';
    if (expect_equal($expected, $results, $title, $error)) {
        $n_pass++;
    } else {
        $n_fail++;
        echo "{$error}\n";
    }
}
コード例 #5
0
ファイル: u.defaultfont.php プロジェクト: myfarms/PHPlot
# 5. SetFontTTF with path and extension
$font_with_path_and_ext = $phplot_test_ttfdir . $phplot_test_ttfonts['serif'];
$p = new PHPlot_test();
$p->SetFontTTF('title', $font_with_path_and_ext, 12);
$font = $p->fonts['title']['font'];
expect_match('[a-z]\\.ttf$', $font, 'Case 5. Set title font with path and extension', $error);
if (!empty($test_debug)) {
    echo "5. font={$font}\n";
}
# 6. SetFontTTF with path and no extension - expected to fail.
$pp = pathinfo($phplot_test_ttfonts['serif']);
$font_with_path_no_ext = $phplot_test_ttfdir . basename($phplot_test_ttfonts['serif'], '.ttf');
// Note this uses the PHPlot_test2() class which suppresses the error image
// and allows the messages to be completely off.
$p = new PHPlot_test2();
$p->hide_error = True;
// Disables error message from PHPlot_test2
if ($p->SetFontTTF('title', $font_with_path_no_ext, 12)) {
    $font = $p->fonts['title']['font'];
} else {
    $font = 'EXPECTED_NO_FONT';
}
expect_equal('EXPECTED_NO_FONT', $font, 'Case 6. Set title font with path and no extension', $error);
if (!empty($test_debug)) {
    echo "6. result={$font}\n";
}
if (!empty($error)) {
    fwrite(STDERR, $error);
    exit(1);
}
echo "Default font unit tests PASS\n";