1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
#!/usr/bin/perl
use strict;
use warnings;
use Gtk2::TestHelper tests => 16;
use FindBin;
use lib "$FindBin::Bin";
use my_helper;
use Glib qw(TRUE FALSE);
use Gtk2::SourceView2;
exit tests();
sub tests {
test_constructor();
test_properties();
return 0;
}
sub test_constructor {
my $mark;
$mark = Gtk2::SourceView2::Mark->new(undef, 'test');
isa_ok($mark, 'Gtk2::SourceView2::Mark');
$mark = Gtk2::SourceView2::Mark->new('named', 'test');
isa_ok($mark, 'Gtk2::SourceView2::Mark');
}
sub test_properties {
my $mark = Gtk2::SourceView2::Mark->new(undef, 'test');
is($mark->next(undef), undef, "no next from a mark without buffer");
is($mark->next('test'), undef, "no next('test') from a mark without buffer");
is($mark->next('test2'), undef, "no next('test2') from a mark without buffer");
is($mark->prev(undef), undef, "no prev from a mark without buffer");
is($mark->prev('test'), undef, "no prev('test') from a mark without buffer");
is($mark->prev('test2'), undef, "no prev('test2') from a mark without buffer");
is($mark->get_category, 'test', "get_category");
my $buffer = Gtk2::SourceView2::Buffer->new(undef);
$buffer->set_text("Jumps over a green sheep");
my $iter1 = $buffer->get_iter_at_offset(6);
my $iter2 = $buffer->get_iter_at_offset(12);
my $iter3 = $buffer->get_iter_at_offset(18);
my $mark1 = $buffer->create_source_mark('m1', 'word', $iter1);
my $mark2 = $buffer->create_source_mark('m2', 'mark', $iter2);
my $mark3 = $buffer->create_source_mark('m3', 'word', $iter3);
is($mark1->get_category, 'word', "get_category");
is($mark2->get_category, 'mark', "get_category");
is($mark3->get_category, 'word', "get_category");
is($mark1->next(undef), $mark2, "next(undef)");
is($mark1->next('word'), $mark3, "next('word')");
is($mark3->prev(undef), $mark2, "prev(undef)");
is($mark3->prev('word'), $mark1, "prev('word')");
}
|