<commit_before><commit_msg>add some tests for exceptions<commit_after><?php

use Jcupitt\Vips;

class VipsExceptionTest extends PHPUnit_Framework_TestCase 
{
    protected function setUp()
    {
        $filename = dirname(__FILE__) . "/images/img_0076.jpg";
        $this->image = Vips\Image::newFromFile($filename);

        /* The original value of pixel (0, 0).
         */
        $this->pixel = $this->image->getpoint(0, 0);
    }

    public function testVipsNewFromFileException()
    {
        $this->expectException(Exception::class);

        $image = Vips\Image::newFromFile("I don't exist.jpg");
    }

    public function testVipsWriteToFileException()
    {
        $this->expectException(Exception::class);

        $this->image->writeToFile("/permissions error.jpg");
    }

    public function testVipsWriteToBufferException()
    {
        $this->expectException(Exception::class);

        $string = $this->image->writeToBuffer(".jpg", ["crazy option" => 42]);
    }

    public function testVipsGetException()
    {
        $this->expectException(Exception::class);

        $x = $this->image->get("I don't exist");
    }

    /* 
     *
     * oop this causes a segv
     *
    public function testVipsOperationException()
    {
        $this->expectException(Exception::class);

        $x = $this->image->add("nonsense");
    }
     *
     */

}

/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * End:
 * vim600: expandtab sw=4 ts=4 fdm=marker
 * vim<600: expandtab sw=4 ts=4
 */
{'fraction_non_alphanumeric': 0.145778364116095, 'fraction_numerical': 0.014511873350923483, 'mean_word_length': 2.7, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '469042', 'n_tokens_mistral': 493, 'n_tokens_neox': 466, 'n_words': 87}