sl@0: /* sl@0: * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * ANSI C version of the RTest facilities, specifically sl@0: * Start(char *title) sl@0: * Next(char *title) sl@0: * Test(int line); sl@0: * As a simplification we don't do the levels of nesting. sl@0: * sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "CTEST.H" sl@0: sl@0: static void failed(struct __testdata* td, int line) sl@0: { sl@0: printf("Test %d.%d failed, line %d\n", td->iCheck, td->iSubtest, line); sl@0: printf("Press any key to exit\n"); sl@0: fflush(stdout); sl@0: getchar(); sl@0: exit(84); sl@0: } sl@0: sl@0: EXPORT_C void td_Title(struct __testdata* td, char *title) sl@0: { sl@0: sl@0: printf("%s\n\n", title); sl@0: td->iCheck=0; sl@0: td->iSubtest=0; sl@0: } sl@0: sl@0: EXPORT_C void td_Next(struct __testdata* td, char *testname) sl@0: { sl@0: printf("%03d: %s\n", ++(td->iCheck), testname); sl@0: td->iSubtest=0; sl@0: } sl@0: sl@0: EXPORT_C void td_Test(struct __testdata* td, int line, int mustBeTrue) sl@0: { sl@0: (td->iSubtest)++; sl@0: if (mustBeTrue) sl@0: return; sl@0: failed(td, line); sl@0: } sl@0: sl@0: EXPORT_C void td_TestErrno(struct __testdata* td, int line, int mustBeTrue, int expectedErrno) sl@0: { sl@0: (td->iSubtest)++; sl@0: td->iErrno = errno; sl@0: if (mustBeTrue) sl@0: { sl@0: if (expectedErrno==td->iErrno) sl@0: return; sl@0: printf("Test %d.%d failed, line %d : expected errno = %d, not %d\n", sl@0: td->iCheck, td->iSubtest, line, expectedErrno, td->iErrno); sl@0: } sl@0: failed(td, line); sl@0: } sl@0: sl@0: EXPORT_C void td_Close() sl@0: { sl@0: printf("\n\nCompleted OK\n"); sl@0: fflush(stdout); sl@0: }