1 | /* $Id: tstGuid.cpp 52045 2014-07-16 08:37:43Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * API Glue Testcase - Guid.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2013-2014 Oracle Corporation
|
---|
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 (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | /*******************************************************************************
|
---|
19 | * Header Files *
|
---|
20 | *******************************************************************************/
|
---|
21 | #include <VBox/com/Guid.h>
|
---|
22 |
|
---|
23 | #include <iprt/err.h>
|
---|
24 | #include <iprt/mem.h>
|
---|
25 | #include <iprt/string.h>
|
---|
26 | #include <iprt/test.h>
|
---|
27 | #include <iprt/uni.h>
|
---|
28 |
|
---|
29 |
|
---|
30 | static void test1(RTTEST hTest)
|
---|
31 | {
|
---|
32 | RTTestSub(hTest, "Basics");
|
---|
33 |
|
---|
34 | #define CHECK(expr) RTTESTI_CHECK(expr)
|
---|
35 | #define CHECK_DUMP(expr, value) \
|
---|
36 | do { \
|
---|
37 | if (!(expr)) \
|
---|
38 | RTTestFailed(hTest, "%d: FAILED %s, got \"%s\"", __LINE__, #expr, value); \
|
---|
39 | } while (0)
|
---|
40 |
|
---|
41 | #define CHECK_DUMP_I(expr) \
|
---|
42 | do { \
|
---|
43 | if (!(expr)) \
|
---|
44 | RTTestFailed(hTest, "%d: FAILED %s, got \"%d\"", __LINE__, #expr, expr); \
|
---|
45 | } while (0)
|
---|
46 | #define CHECK_EQUAL(Str, szExpect) \
|
---|
47 | do { \
|
---|
48 | if (!(Str).equals(szExpect)) \
|
---|
49 | RTTestIFailed("line %u: expected \"%s\" got \"%s\"", __LINE__, szExpect, (Str).c_str()); \
|
---|
50 | } while (0)
|
---|
51 | #define CHECK_EQUAL_I(iRes, iExpect) \
|
---|
52 | do { \
|
---|
53 | if (iRes != iExpect) \
|
---|
54 | RTTestIFailed("line %u: expected \"%zd\" got \"%zd\"", __LINE__, iExpect, iRes); \
|
---|
55 | } while (0)
|
---|
56 |
|
---|
57 | com::Guid zero;
|
---|
58 | CHECK(zero.isZero());
|
---|
59 |
|
---|
60 | com::Guid copyZero(zero);
|
---|
61 | CHECK(copyZero.isZero());
|
---|
62 |
|
---|
63 | com::Guid assignZero(zero);
|
---|
64 | CHECK(assignZero.isZero());
|
---|
65 |
|
---|
66 | com::Guid random;
|
---|
67 | random.create();
|
---|
68 | CHECK(!random.isZero());
|
---|
69 |
|
---|
70 | com::Guid copyRandom(random);
|
---|
71 | CHECK(!copyRandom.isZero());
|
---|
72 |
|
---|
73 | com::Guid assignRandom(random);
|
---|
74 | CHECK(!assignRandom.isZero());
|
---|
75 |
|
---|
76 | /** @todo extend this a lot, it needs to cover many more cases */
|
---|
77 |
|
---|
78 | #undef CHECK
|
---|
79 | #undef CHECK_DUMP
|
---|
80 | #undef CHECK_DUMP_I
|
---|
81 | #undef CHECK_EQUAL
|
---|
82 | }
|
---|
83 |
|
---|
84 |
|
---|
85 | int main()
|
---|
86 | {
|
---|
87 | RTTEST hTest;
|
---|
88 | RTEXITCODE rcExit = RTTestInitAndCreate("tstGuid", &hTest);
|
---|
89 | if (rcExit == RTEXITCODE_SUCCESS)
|
---|
90 | {
|
---|
91 | RTTestBanner(hTest);
|
---|
92 |
|
---|
93 | test1(hTest);
|
---|
94 |
|
---|
95 | rcExit = RTTestSummaryAndDestroy(hTest);
|
---|
96 | }
|
---|
97 | return rcExit;
|
---|
98 | }
|
---|
99 |
|
---|