blob: 1b9a2b88dac97d0ef0a96e6a89a2cee9ab73accf [file] [log] [blame]
Ed Tanous2c6ffdb2023-06-28 11:28:38 -07001#include "ossl_random.hpp"
2
Ed Tanous2c6ffdb2023-06-28 11:28:38 -07003#include <gmock/gmock.h> // IWYU pragma: keep
4#include <gtest/gtest.h> // IWYU pragma: keep
5
6namespace
7{
8
Ed Tanousb7f3a822024-06-05 08:45:25 -07009using testing::IsEmpty;
Ed Tanous2c6ffdb2023-06-28 11:28:38 -070010using testing::MatchesRegex;
11
12TEST(Bmcweb, GetRandomUUID)
13{
14 using bmcweb::getRandomUUID;
15 // 78e96a4b-62fe-48d8-ac09-7f75a94671e0
16 EXPECT_THAT(
17 getRandomUUID(),
18 MatchesRegex(
19 "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"));
20}
21
Ed Tanousb7f3a822024-06-05 08:45:25 -070022TEST(Bmcweb, GetRandomIdOfLength)
23{
24 using bmcweb::getRandomIdOfLength;
25 EXPECT_THAT(getRandomIdOfLength(1), MatchesRegex("^[a-zA-Z0-9]$"));
26 EXPECT_THAT(getRandomIdOfLength(10), MatchesRegex("^[a-zA-Z0-9]{10}$"));
27 EXPECT_THAT(getRandomIdOfLength(0), IsEmpty());
28}
29
Ed Tanous2c6ffdb2023-06-28 11:28:38 -070030} // namespace