Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkUIDGeneratorTest.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "mitkUIDGenerator.h"
18 #include <mitkLogMacros.h>
19 #include <mitkTestingMacros.h>
20 
22 {
23  auto uidGen1 = new mitk::UIDGenerator("UID_", 8);
24  mitk::UIDGenerator *uidGen2 = uidGen1;
25  std::string uid1_1, uid2_1;
26 
27  uid1_1 = uidGen1->GetUID();
28 
29  uidGen1 = new mitk::UIDGenerator("UID_", 8);
30 
31  uid2_1 = uidGen1->GetUID();
32 
33  delete uidGen1;
34  delete uidGen2;
35 
36  MITK_TEST_CONDITION(uid1_1 != uid2_1, "Different UIDs are not allowed to be equal");
37 }
38 
39 void multipleUIDsFromSameGeneratorTest(int /*UIDlength*/)
40 {
41  auto uidGen = new mitk::UIDGenerator("UID_", 8);
42  std::string uid1, uid2;
43  uid1 = uidGen->GetUID();
44  uid2 = uidGen->GetUID();
45  delete uidGen;
46  MITK_TEST_CONDITION(uid1 != uid2,
47  "Testing two UIDs from the same generator. Different UIDs are not allowed to be equal");
48 }
49 
51 {
52  mitk::UIDGenerator uidGen1("UID_", 8);
53  std::string uid1_1, uid2_1;
54 
55  uid1_1 = uidGen1.GetUID();
56 
57  uidGen1 = mitk::UIDGenerator("UID_", 8);
58 
59  uid2_1 = uidGen1.GetUID();
60 
61  MITK_TEST_CONDITION(uid1_1 != uid2_1, "Different UIDs are not allowed to be equal");
62 }
63 
65 {
66  mitk::UIDGenerator uidGen1("UID_", 8);
67  mitk::UIDGenerator uidGen2("UID_", 8);
68  std::string uid1_1, uid2_1;
69 
70  uid1_1 = uidGen1.GetUID();
71  uid2_1 = uidGen2.GetUID();
72 
73  MITK_TEST_CONDITION(uid1_1 != uid2_1, "Different UIDs are not allowed to be equal");
74 }
75 
76 int mitkUIDGeneratorTest(int /*argc*/, char * /*argv*/ [])
77 {
78  MITK_TEST_BEGIN("mitkUIDGeneratorTest");
84  MITK_TEST_END();
85 }
Generated unique IDs.
void severalGeneratorInstancesTest()
void newGeneratorInstancesTest()
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
void newGeneratorInstancesHeapTest()
#define MITK_TEST_CONDITION(COND, MSG)
void multipleUIDsFromSameGeneratorTest(int)
and MITK_TEST_END()
int mitkUIDGeneratorTest(int, char *[])