File: TestFormatParser.cpp

package info (click to toggle)
soapysdr 0.8.1-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 948 kB
  • sloc: cpp: 5,378; ansic: 471; python: 311; sh: 21; makefile: 18
file content (46 lines) | stat: -rw-r--r-- 1,313 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
// Copyright (c) 2015-2015 Josh Blum
// SPDX-License-Identifier: BSL-1.0

#include <SoapySDR/Formats.hpp>
#include <cstdlib>
#include <cstdio>

int main(void)
{
    #define formatCheck(formatStr, expectedSize) \
    { \
        size_t bytes = SoapySDR::formatToSize(formatStr); \
        printf("%s -> %d bytes/element\t", formatStr, int(bytes)); \
        if (bytes != expectedSize) \
        { \
            printf("FAIL: expected %d bytes!\n", int(expectedSize)); \
            return EXIT_FAILURE; \
        } \
        else printf("OK\n"); \
    }

    formatCheck(SOAPY_SDR_CF64, 16);
    formatCheck(SOAPY_SDR_CF32, 8);
    formatCheck(SOAPY_SDR_CS32, 8);
    formatCheck(SOAPY_SDR_CU32, 8);
    formatCheck(SOAPY_SDR_CS16, 4);
    formatCheck(SOAPY_SDR_CU16, 4);
    formatCheck(SOAPY_SDR_CS12, 3);
    formatCheck(SOAPY_SDR_CU12, 3);
    formatCheck(SOAPY_SDR_CS8, 2);
    formatCheck(SOAPY_SDR_CU8, 2);
    formatCheck(SOAPY_SDR_CS4, 1);
    formatCheck(SOAPY_SDR_CU4, 1);

    formatCheck(SOAPY_SDR_F64, 8);
    formatCheck(SOAPY_SDR_F32, 4);
    formatCheck(SOAPY_SDR_S32, 4);
    formatCheck(SOAPY_SDR_U32, 4);
    formatCheck(SOAPY_SDR_S16, 2);
    formatCheck(SOAPY_SDR_U16, 2);
    formatCheck(SOAPY_SDR_S8, 1);
    formatCheck(SOAPY_SDR_U8, 1);

    printf("DONE!\n");
    return EXIT_SUCCESS;
}