VirtualBox

source: vbox/trunk/src/VBox/Runtime/testcase/tstUuid.cpp@ 283

Last change on this file since 283 was 129, checked in by vboxsync, 18 years ago

Generic Uuid. Corrected Gen.u16TimeMin to Gen.u16TimeMid.

  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1/* $Id: tstUuid.cpp 129 2007-01-18 00:07:02Z vboxsync $ */
2/** @file
3 * InnoTek Portable Runtime Testcase - UUID.
4 */
5
6/*
7 * Copyright (C) 2006 InnoTek Systemberatung GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22
23/*******************************************************************************
24* Header Files *
25*******************************************************************************/
26#include <iprt/uuid.h>
27#include <iprt/stream.h>
28#include <iprt/err.h>
29
30
31int main(int argc, char **argv)
32{
33 int rc;
34 int cErrors = 0;
35
36#define CHECK_RC() \
37 do { if (RT_FAILURE(rc)) { RTPrintf("tstUuid(%d): rc=%Vrc!\n", __LINE__, rc); cErrors++; } } while (0)
38#define CHECK_EXPR(expr) \
39 do { const bool f = !!(expr); if (!f) { RTPrintf("tstUuid(%d): %s!\n", __LINE__, #expr); cErrors++; } } while (0)
40
41 RTUUID UuidNull;
42 rc = RTUuidClear(&UuidNull); CHECK_RC();
43 CHECK_EXPR(RTUuidIsNull(&UuidNull));
44 CHECK_EXPR(RTUuidCompare(&UuidNull, &UuidNull) == 0);
45
46 RTUUID Uuid;
47 rc = RTUuidCreate(&Uuid); CHECK_RC();
48 CHECK_EXPR(!RTUuidIsNull(&Uuid));
49 CHECK_EXPR(RTUuidCompare(&Uuid, &Uuid) == 0);
50 CHECK_EXPR(RTUuidCompare(&Uuid, &UuidNull) > 0);
51 CHECK_EXPR(RTUuidCompare(&UuidNull, &Uuid) < 0);
52
53 char sz[RTUUID_STR_LENGTH];
54 rc = RTUuidToStr(&Uuid, sz, sizeof(sz)); CHECK_RC();
55 RTUUID Uuid2;
56 rc = RTUuidFromStr(&Uuid2, sz); CHECK_RC();
57 CHECK_EXPR(RTUuidCompare(&Uuid, &Uuid2) == 0);
58
59 /*
60 * Summary.
61 */
62 if (!cErrors)
63 RTPrintf("tstUuid: SUCCESS {%s}\n", sz);
64 else
65 RTPrintf("tstUuid: FAILED - %d errors\n", cErrors);
66 return !!cErrors;
67}
68
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette