File: GstStructure.t

package info (click to toggle)
libgstreamer-perl 0.19-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 900 kB
  • ctags: 59
  • sloc: perl: 2,456; ansic: 32; makefile: 6
file content (49 lines) | stat: -rw-r--r-- 1,306 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 9;

# $Id$

use Glib qw(TRUE FALSE);
use GStreamer -init;

my $structure_one = {
  name => "urgs",
  fields => [
    [field_one => "Glib::String" => "urgs"],
    [field_two => "Glib::Int" => 23]
  ]
};

my $structure_two = {
  name => "sgru",
  fields => [
    [field_one => "Glib::String" => "sgru"],
    [field_two => "Glib::Int" => 42]
  ]
};

my $caps = GStreamer::Caps::Full -> new($structure_one);
isa_ok($caps, "GStreamer::Caps");

$caps -> append_structure($structure_two);
is($caps -> get_size(), 2);

is_deeply($caps -> get_structure(0), $structure_one);
is_deeply($caps -> get_structure(1), $structure_two);

my $string_one = GStreamer::Structure::to_string($structure_one);
my $string_two = GStreamer::Structure::to_string($structure_two);

# remove trailing semicolon that start to appear sometime in the past
$string_one =~ s/;\Z//;
$string_two =~ s/;\Z//;

is($string_one, "urgs, field_one=(string)urgs, field_two=(int)23");
is($string_two, "sgru, field_one=(string)sgru, field_two=(int)42");

is_deeply(GStreamer::Structure::from_string($string_one), $structure_one);
is_deeply(GStreamer::Structure::from_string($string_two), $structure_two);

is_deeply((GStreamer::Structure::from_string($string_one))[0], $structure_one);