File indexing completed on 2025-03-16 04:30:27
0001 /* 0002 SPDX-FileCopyrightText: 2016-2017 Leslie Zhai <lesliezhai@llvm.org.cn> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #include "k3bdeviceglobalstest.h" 0007 #include "k3bdeviceglobals.h" 0008 0009 #include <QTest> 0010 0011 QTEST_GUILESS_MAIN(DeviceGlobalsTest) 0012 0013 DeviceGlobalsTest::DeviceGlobalsTest() 0014 { 0015 } 0016 0017 void DeviceGlobalsTest::testFrom2Byte() 0018 { 0019 unsigned char* d = NULL; 0020 QCOMPARE(K3b::Device::from2Byte(d), (quint16)0); // Invalid Byte! 0021 unsigned const char buf0[] = { 0x00, 0x00 }; 0022 QCOMPARE(K3b::Device::from2Byte(buf0), (quint16)0x0000); 0023 unsigned const char buf1[] = { 0x00, 0x70 }; 0024 QCOMPARE(K3b::Device::from2Byte(buf1), (quint16)0x0070); 0025 unsigned const char buf2[] = { 0x05, 0x00 }; 0026 QCOMPARE(K3b::Device::from2Byte(buf2), (quint16)0x0500); 0027 unsigned const char buf3[] = { 0xF0, 0x03 }; 0028 QCOMPARE(K3b::Device::from2Byte(buf3), (quint16)0xF003); 0029 } 0030 0031 void DeviceGlobalsTest::testFrom4Byte() 0032 { 0033 unsigned const char buf0[] = { 0x00, 0x00, 0x00, 0x00 }; 0034 QCOMPARE(K3b::Device::from4Byte(buf0), (quint32)0x00000000); 0035 unsigned const char buf1[] = { 0x00, 0x00, 0x00, 0x01 }; 0036 QCOMPARE(K3b::Device::from4Byte(buf1), (quint32)0x00000001); 0037 unsigned const char buf2[] = { 0x12, 0x34, 0x56, 0x78 }; 0038 QCOMPARE(K3b::Device::from4Byte(buf2), (quint32)0x12345678); 0039 } 0040 0041 #include "moc_k3bdeviceglobalstest.cpp"