blob: 180f36617978ae2ade0df547efd3757b46ff41ae [file] [log] [blame]
Laurence Lundbladed92a6162018-11-01 11:38:35 +07001/*==============================================================================
Laurence Lundblade624405d2018-09-18 20:10:47 -07002 cmd_line_mainc.c -- basic tests for qcbor encoder / decoder
3
Laurence Lundbladed92a6162018-11-01 11:38:35 +07004 Copyright (c) 2018, Laurence Lundblade.
5 All rights reserved.
Laurence Lundblade624405d2018-09-18 20:10:47 -07006
Laurence Lundbladed92a6162018-11-01 11:38:35 +07007 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are
9 met:
10 * Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above
13 copyright notice, this list of conditions and the following
14 disclaimer in the documentation and/or other materials provided
15 with the distribution.
16 * Neither the name of The Linux Foundation nor the names of its
17 contributors, nor the name "Laurence Lundblade" may be used to
18 endorse or promote products derived from this software without
19 specific prior written permission.
Laurence Lundblade624405d2018-09-18 20:10:47 -070020
Laurence Lundbladed92a6162018-11-01 11:38:35 +070021 THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
22 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
25 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
31 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 ==============================================================================*/
Laurence Lundblade74f68412018-09-13 12:18:49 -070033// Created by Laurence Lundblade on 9/13/18.
Laurence Lundblade74f68412018-09-13 12:18:49 -070034
35#include <stdio.h>
Laurence Lundblade781fd822018-10-01 09:37:52 -070036#include "run_tests.h"
Laurence Lundbladed92a6162018-11-01 11:38:35 +070037#include "qcbor.h" // just to print sizes of the structures.
Laurence Lundblade74f68412018-09-13 12:18:49 -070038
Laurence Lundbladea954db92018-09-28 19:27:31 -070039
Laurence Lundbladecc2ed342018-09-22 17:29:55 -070040int fputs_wrapper(const char *szString, void *ctx)
41{
42 return fputs(szString, (FILE *)ctx);
43}
Laurence Lundblade2300b562018-09-29 20:00:09 -070044
Laurence Lundblade2300b562018-09-29 20:00:09 -070045
Laurence Lundblade570fab52018-10-13 18:28:27 +080046int main(int argc, const char * argv[])
47{
48 (void)argc; // Suppress unused warning
Laurence Lundblade742df4a2018-10-13 20:07:17 +080049 (void)argv; // Suppress unused warning
Laurence Lundbladefab1b522018-10-19 13:40:52 +053050
51 // Type and size of return from sizeof() varies. These will never be large so cast is safe
52 // TODO: use fputs_wrapper to output these
Laurence Lundbladea44d5062018-10-17 18:45:12 +053053 printf("sizeof(QCBOREncodeContext) %d\n", (uint32_t)sizeof(QCBOREncodeContext));
54 printf("sizeof(QCBORDecodeContext) %d\n", (uint32_t)sizeof(QCBORDecodeContext));
Laurence Lundbladefab1b522018-10-19 13:40:52 +053055 printf("sizeof(QCBORDecodeNesting) %d\n", (uint32_t)sizeof(QCBORDecodeNesting));
Laurence Lundbladea44d5062018-10-17 18:45:12 +053056 printf("sizeof(QCBORItem) %d\n", (uint32_t)sizeof(QCBORItem));
57 printf("sizeof(QCBORStringAllocator) %d\n\n", (uint32_t)sizeof(QCBORStringAllocator));
58
Laurence Lundbladedbe6f212018-10-28 11:37:53 +070059 // TODO: command line arg to select test
Laurence Lundbladecc2ed342018-09-22 17:29:55 -070060 int nNumTestsFailed = run_tests(&fputs_wrapper, stdout, NULL);
61
62 return nNumTestsFailed;
Laurence Lundblade74f68412018-09-13 12:18:49 -070063}