File: structstest.cpp

package info (click to toggle)
qt-gstreamer 0.10.2-2.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,012 kB
  • ctags: 2,868
  • sloc: cpp: 17,352; yacc: 156; lex: 125; makefile: 23
file content (99 lines) | stat: -rw-r--r-- 2,988 bytes parent folder | download | duplicates (6)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
    Copyright (C) 2010  George Kiagiadakis <kiagiadakis.george@gmail.com>

    This library is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published
    by the Free Software Foundation; either version 2.1 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#include "qgsttest.h"
#include <QGlib/Value>
#include <QGst/Fourcc>
#include <QGst/Fraction>
#include <QGst/IntRange>
#include <QGst/DoubleRange>
#include <QGst/FractionRange>

class StructsTest : public QGstTest
{
    Q_OBJECT
private Q_SLOTS:
    void fourccTest();
    void fractionTest();
    void doubleRangeTest();
    void fractionRangeTest();
};

void StructsTest::fourccTest()
{
    QGst::Fourcc f("MJPG");
    QCOMPARE(f.value.as_bytes.first, 'M');
    QCOMPARE(f.value.as_bytes.second, 'J');
    QCOMPARE(f.value.as_bytes.third, 'P');
    QCOMPARE(f.value.as_bytes.fourth, 'G');
    QCOMPARE(f.value.as_integer, GST_STR_FOURCC("MJPG"));

    f = QGst::Fourcc(GST_STR_FOURCC("MJPG")); //quint32 constructor
    QCOMPARE(f.value.as_bytes.first, 'M');
    QCOMPARE(f.value.as_bytes.second, 'J');
    QCOMPARE(f.value.as_bytes.third, 'P');
    QCOMPARE(f.value.as_bytes.fourth, 'G');
    QCOMPARE(f.value.as_integer, GST_STR_FOURCC("MJPG"));

    QGlib::Value v = QGlib::Value::create(f);
    f = v.get<QGst::Fourcc>();
    QCOMPARE(f.value.as_bytes.first, 'M');
    QCOMPARE(f.value.as_bytes.second, 'J');
    QCOMPARE(f.value.as_bytes.third, 'P');
    QCOMPARE(f.value.as_bytes.fourth, 'G');
    QCOMPARE(f.value.as_integer, GST_STR_FOURCC("MJPG"));
}

void StructsTest::fractionTest()
{
    QGst::Fraction f(25, 1);
    QCOMPARE(f.numerator, 25);
    QCOMPARE(f.denominator, 1);

    QGlib::Value v = QGlib::Value::create(f);
    f = v.get<QGst::Fraction>();
    QCOMPARE(f.numerator, 25);
    QCOMPARE(f.denominator, 1);
}

void StructsTest::doubleRangeTest()
{
    QGst::DoubleRange r(1.0, 2.0);
    QCOMPARE(r.start, 1.0);
    QCOMPARE(r.end, 2.0);

    QGlib::Value v = QGlib::Value::create(r);
    r = v.get<QGst::DoubleRange>();
    QCOMPARE(r.start, 1.0);
    QCOMPARE(r.end, 2.0);
}

void StructsTest::fractionRangeTest()
{
    QGst::FractionRange r(QGst::Fraction(1, 1), QGst::Fraction(25, 1));
    QCOMPARE(r.start.numerator, 1);
    QCOMPARE(r.end.numerator, 25);

    QGlib::Value v = QGlib::Value::create(r);
    r = v.get<QGst::FractionRange>();
    QCOMPARE(r.start.numerator, 1);
    QCOMPARE(r.end.numerator, 25);
}

QTEST_APPLESS_MAIN(StructsTest)

#include "moc_qgsttest.cpp"
#include "structstest.moc"