File: k3bdeviceglobalstest.cpp

package info (click to toggle)
k3b 25.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 55,840 kB
  • sloc: cpp: 99,202; xml: 372; sh: 84; makefile: 10
file content (41 lines) | stat: -rw-r--r-- 1,344 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
/*
    SPDX-FileCopyrightText: 2016-2017 Leslie Zhai <lesliezhai@llvm.org.cn>
    SPDX-License-Identifier: GPL-2.0-or-later
*/

#include "k3bdeviceglobalstest.h"
#include "k3bdeviceglobals.h"

#include <QTest>

QTEST_GUILESS_MAIN(DeviceGlobalsTest)

DeviceGlobalsTest::DeviceGlobalsTest()
{
}

void DeviceGlobalsTest::testFrom2Byte()
{
    unsigned char* d = NULL;
    QCOMPARE(K3b::Device::from2Byte(d), (quint16)0);   // Invalid Byte!
    unsigned const char buf0[] = { 0x00, 0x00 };
    QCOMPARE(K3b::Device::from2Byte(buf0), (quint16)0x0000);
    unsigned const char buf1[] = { 0x00, 0x70 };
    QCOMPARE(K3b::Device::from2Byte(buf1), (quint16)0x0070);
    unsigned const char buf2[] = { 0x05, 0x00 };
    QCOMPARE(K3b::Device::from2Byte(buf2), (quint16)0x0500);
    unsigned const char buf3[] = { 0xF0, 0x03 };
    QCOMPARE(K3b::Device::from2Byte(buf3), (quint16)0xF003);
}

void DeviceGlobalsTest::testFrom4Byte() 
{
    unsigned const char buf0[] = { 0x00, 0x00, 0x00, 0x00 };
    QCOMPARE(K3b::Device::from4Byte(buf0), (quint32)0x00000000);
    unsigned const char buf1[] = { 0x00, 0x00, 0x00, 0x01 };
    QCOMPARE(K3b::Device::from4Byte(buf1), (quint32)0x00000001);
    unsigned const char buf2[] = { 0x12, 0x34, 0x56, 0x78 };
    QCOMPARE(K3b::Device::from4Byte(buf2), (quint32)0x12345678);
}

#include "moc_k3bdeviceglobalstest.cpp"