blob: ce44673fd48ec33478514f9f070bf6111e5a0560 [file] [log] [blame]
Laurence Lundblade6ed34222018-12-18 09:46:23 -08001/*==============================================================================
2 run_tests.h -- test aggregator and results reporting
3
Laurence Lundbladeac515e52020-01-30 10:44:06 -08004 Copyright (c) 2018-2020, Laurence Lundblade. All rights reserved.
Laurence Lundblade6ed34222018-12-18 09:46:23 -08005
6 SPDX-License-Identifier: BSD-3-Clause
7
8 See BSD-3-Clause license in README.md
9
10 Created 9/30/18
Laurence Lundbladeac515e52020-01-30 10:44:06 -080011 =============================================================================*/
Laurence Lundblade6ed34222018-12-18 09:46:23 -080012
13/**
14 @file run_tests.h
15*/
16
17/**
18 @brief Type for function to output a text string
19
20 @param[in] szString The string to output
21 @param[in] pOutCtx A context pointer; NULL if not needed
22 @param[in] bNewline If non-zero, output a newline after the string
23
24 This is a prototype of a function to be passed to RunTests() to
25 output text strings.
26
27 This can be implemented with stdio (if available) using a straight
28 call to fputs() where the FILE * is passed as the pOutCtx as shown in
29 the example code below. This code is for Linux where the newline is
30 a \\n. Windows usually prefers \\r\\n.
31
32 @code
33 static void fputs_wrapper(const char *szString, void *pOutCtx, int bNewLine)
34 {
35 fputs(szString, (FILE *)pOutCtx);
36 if(bNewLine) {
37 fputs("\n", pOutCtx);
38 }
39 }
40 @endcode
41*/
42typedef void (*OutputStringCB)(const char *szString, void *pOutCtx, int bNewline);
43
44
45/**
46 @brief Runs the QCBOR tests.
47
48 @param[in] szTestNames An argv-style list of test names to run. If
49 empty, all are run.
50 @param[in] pfOutput Function that is called to output text strings.
51 @param[in] pOutCtx Context pointer passed to output function.
52 @param[out] pNumTestsRun Returns the number of tests run. May be NULL.
53
54 @return The number of tests that failed. Zero means overall success.
55 */
Laurence Lundbladeac515e52020-01-30 10:44:06 -080056int RunTestsQCBOR(const char *szTestNames[],
57 OutputStringCB pfOutput,
58 void *pOutCtx,
59 int *pNumTestsRun);
Laurence Lundblade6ed34222018-12-18 09:46:23 -080060
61
62/**
63 @brief Print sizes of encoder / decoder contexts.
64
65 @param[in] pfOutput Function that is called to output text strings.
66 @param[in] pOutCtx Context pointer passed to output function.
67 */
Laurence Lundbladeac515e52020-01-30 10:44:06 -080068void PrintSizesQCBOR(OutputStringCB pfOutput, void *pOutCtx);
Laurence Lundblade6ed34222018-12-18 09:46:23 -080069