File tree Expand file tree Collapse file tree 4 files changed +59
-1
lines changed
Expand file tree Collapse file tree 4 files changed +59
-1
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ list (APPEND WSJCPP_SOURCES "../unit-tests.wsjcpp/src/unit_test_ip_v6.h")
3636list (APPEND WSJCPP_SOURCES "../unit-tests.wsjcpp/src/unit_test_ip_v6.cpp" )
3737list (APPEND WSJCPP_SOURCES "../unit-tests.wsjcpp/src/unit_test_to_upper.h" )
3838list (APPEND WSJCPP_SOURCES "../unit-tests.wsjcpp/src/unit_test_to_upper.cpp" )
39+ list (APPEND WSJCPP_SOURCES "../unit-tests.wsjcpp/src/unit_test_create_uuid.h" )
40+ list (APPEND WSJCPP_SOURCES "../unit-tests.wsjcpp/src/unit_test_create_uuid.cpp" )
3941
4042# required-libraries
4143list (APPEND WSJCPP_LIBRARIES "-lpthread" )
Original file line number Diff line number Diff line change 1+ #include " unit_test_create_uuid.h"
2+ #include < vector>
3+ #include < wsjcpp_core.h>
4+
5+ REGISTRY_UNIT_TEST (UnitTestCreateUuid)
6+
7+ UnitTestCreateUuid::UnitTestCreateUuid()
8+ : UnitTestBase(" UnitTestCreateUuid" ) {
9+ }
10+
11+ // ---------------------------------------------------------------------
12+
13+ void UnitTestCreateUuid::init () {
14+ // nothing
15+ }
16+
17+ // ---------------------------------------------------------------------
18+
19+ bool UnitTestCreateUuid::run () {
20+ bool bTestSuccess = true ;
21+ std::vector<std::string> vUuids;
22+ for (int i = 0 ; i < 100 ; i++) {
23+ std::string sUuid = WSJCppCore::createUuid ();
24+ /* if (i < 3) {
25+ Log::info(TAG, "sUuid: " + sUuid);
26+ }*/
27+ vUuids.push_back (sUuid );
28+ }
29+ for (int x = 0 ; x < 100 ; x++) {
30+ for (int y = 0 ; y < 100 ; y++) {
31+ if (vUuids[x] == vUuids[y] && x != y) {
32+ bTestSuccess = false ;
33+ WSJCppLog::err (TAG, " Wrong generation random uuids: \n vUuids[" + std::to_string (x)+ " ] == vUuids[" + std::to_string (y) + " ] == '" + vUuids[x] + " '" );
34+ }
35+ }
36+ }
37+ return bTestSuccess;
38+ }
39+
Original file line number Diff line number Diff line change 1+ #ifndef UNIT_TEST_CREATE_UUID_H
2+ #define UNIT_TEST_CREATE_UUID_H
3+
4+ #include < wsjcpp_unit_tests.h>
5+
6+ // Description: TODO
7+ class UnitTestCreateUuid : public UnitTestBase {
8+ public:
9+ UnitTestCreateUuid ();
10+ virtual void init ();
11+ virtual bool run ();
12+ };
13+
14+ #endif // UNIT_TEST_CREATE_UUID_H
15+
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ distribution:
2828 - source-file : src/wsjcpp_core.h
2929 target-file : wsjcpp_core.h
3030 sha1 : " a8a5197a0b6f6230cd8f75ee536bb590ed61125a"
31- type : " source-code"
31+ type : " source-code" # todo must be header-file
3232 - source-file : " src/wsjcpp_unit_tests.cpp"
3333 target-file : " wsjcpp_unit_tests.cpp"
3434 type : " unit-tests"
@@ -56,3 +56,5 @@ unit-tests:
5656 description : Check function isIPv6
5757 - name : " ToUpper"
5858 description : " String to upper"
59+ - name : " CreateUuid"
60+ description : " Test generation uuids"
You can’t perform that action at this time.
0 commit comments