Skip to content

Commit 0494b92

Browse files
committed
Removed duplicate unit-tests CoreUuid
1 parent 6d7b793 commit 0494b92

File tree

7 files changed

+15
-68
lines changed

7 files changed

+15
-68
lines changed

src/wsjcpp_core.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ bool WsjcppCore::init(
3232
const std::string &sLibraryNameForExports
3333
) {
3434
// init random
35-
std::srand(std::rand() + std::time(0));
36-
// WsjcppCore::initRandom();
35+
// std::srand(std::time(0));
36+
WsjcppCore::initRandom();
3737
return true;
3838
}
3939

@@ -498,18 +498,17 @@ std::string WsjcppCore::join(const std::vector<std::string> &vWhat, const std::s
498498
// ---------------------------------------------------------------------
499499

500500
void WsjcppCore::initRandom() {
501-
std::srand(std::rand() + std::time(0));
501+
std::srand(std::time(0));
502502
}
503503

504504
// ---------------------------------------------------------------------
505505

506506
std::string WsjcppCore::createUuid() {
507507
std::string sRet = "00000000-0000-0000-0000-000000000000";
508508
const std::string sAlphabet = "0123456789abcdef";
509-
// unsigned t = std::time(0);
510509
for (int i = 0; i < 36; i++) {
511510
if (i != 8 && i != 13 && i != 18 && i != 23) {
512-
sRet[i] = sAlphabet[std::rand() % sAlphabet.length()];
511+
sRet[i] = sAlphabet[rand() % sAlphabet.length()];
513512
}
514513
}
515514
return sRet;

src/wsjcpp_unit_tests_main.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ int main(int argc, char** argv) {
3232

3333
if (argc == 1) {
3434
int nAll = g_pWsjcppUnitTests->size();
35-
WsjcppLog::info("runUnitTests", "All tests count " + std::to_string(nAll));
35+
WsjcppLog::info(TAG, "All tests count " + std::to_string(nAll));
3636
int nSuccess = 0;
3737
for (int i = 0; i < g_pWsjcppUnitTests->size(); i++) {
3838
WsjcppUnitTestBase* pUnitTest = g_pWsjcppUnitTests->at(i);
3939
std::string sTestName = pUnitTest->name();
40-
WsjcppLog::info("runUnitTests", "Run test " + sTestName);
40+
WsjcppLog::info(TAG, "Run test " + sTestName);
4141
if (pUnitTest->run()) {
4242
WsjcppLog::ok(sTestName, "Test passed");
4343
nSuccess++;
@@ -72,7 +72,9 @@ int main(int argc, char** argv) {
7272
WsjcppUnitTestBase* pUnitTest = g_pWsjcppUnitTests->at(i);
7373
if (pUnitTest->name() == sArg3) {
7474
bTestFound = true;
75-
if (pUnitTest->run()) {
75+
WsjcppLog::info(TAG, "Run test " + pUnitTest->name());
76+
bool bResult = pUnitTest->run();
77+
if (bResult) {
7678
WsjcppLog::ok(TAG, pUnitTest->name() + " Test passed");
7779
nSuccess++;
7880
} else {

unit-tests.wsjcpp/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ list (APPEND WSJCPP_SOURCES "../src/wsjcpp_resources_manager.cpp")
3333
list (APPEND WSJCPP_INCLUDE_DIRS "src")
3434
list (APPEND WSJCPP_SOURCES "../unit-tests.wsjcpp/src/unit_test_core_normalize_path.h")
3535
list (APPEND WSJCPP_SOURCES "../unit-tests.wsjcpp/src/unit_test_core_normalize_path.cpp")
36-
list (APPEND WSJCPP_SOURCES "../unit-tests.wsjcpp/src/unit_test_core_uuid.h")
37-
list (APPEND WSJCPP_SOURCES "../unit-tests.wsjcpp/src/unit_test_core_uuid.cpp")
3836
list (APPEND WSJCPP_SOURCES "../unit-tests.wsjcpp/src/unit_test_core_extract_filename.h")
3937
list (APPEND WSJCPP_SOURCES "../unit-tests.wsjcpp/src/unit_test_core_extract_filename.cpp")
4038
list (APPEND WSJCPP_SOURCES "../unit-tests.wsjcpp/src/unit_test_to_upper.h")

unit-tests.wsjcpp/src/unit_test_core_uuid.cpp

Lines changed: 0 additions & 39 deletions
This file was deleted.

unit-tests.wsjcpp/src/unit_test_core_uuid.h

Lines changed: 0 additions & 13 deletions
This file was deleted.

unit-tests.wsjcpp/src/unit_test_create_uuid.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,17 @@ bool UnitTestCreateUuid::run() {
2222
for (int i = 0; i < 100; i++) {
2323
std::string sUuid = WsjcppCore::createUuid();
2424
// if (i < 3) {
25-
// WsjcppLog::info(TAG, "sUuid: " + sUuid);
25+
// WsjcppLog::info(TAG, "sUuid: " + sUuid);
2626
// }
2727
vUuids.push_back(sUuid);
2828
}
2929
for (int x = 0; x < 100; x++) {
3030
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: \nvUuids[" + std::to_string(x)+ "] == vUuids[" + std::to_string(y) + "] == '" + vUuids[x] + "'");
31+
if (x != y) {
32+
if (vUuids[x] == vUuids[y]) {
33+
bTestSuccess = false;
34+
WsjcppLog::err(TAG, "Wrong generation random uuids: \nvUuids[" + std::to_string(x)+ "] == vUuids[" + std::to_string(y) + "] == '" + vUuids[x] + "'");
35+
}
3436
}
3537
}
3638
}

wsjcpp.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ unit-tests:
4747
cases:
4848
- name: CoreNormalizePath
4949
description: Check function normalizePath
50-
- name: CoreUuid
51-
description: Check test generate uuid function
5250
- name: CoreExtractFilename
5351
description: Check function extract filenane from path
5452
- name: "ToUpper"

0 commit comments

Comments
 (0)