vcpe/unit_test/misc/uuid_test.cpp

34 lines
822 B
C++
Raw Normal View History

//
// Created by xajhuang on 2023/1/31.
//
// provides main(); this line is required in only one .cpp file
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"
#include "uuid.h"
TEST_SUITE("Miscellaneous functions") {
TEST_CASE("UUID TEST") {
int i;
uuid_t msgId;
memset(msgId, 0, sizeof(msgId));
uuid_generate_random(msgId);
SUBCASE("Generate UUID") {
unsigned int sum = 0;
for (i = 0; i < UUID_BYTES; i++) {
sum += msgId[i];
}
REQUIRE_NE(sum, 0);
}
SUBCASE("UUID String") {
char strMsgId[64];
memset(strMsgId, 0, 64);
uuid_unparse(msgId, strMsgId);
REQUIRE_MESSAGE((strlen(strMsgId) == 36), "UUID:", strMsgId);
}
}
}