Ed Tanous | 2c6ffdb | 2023-06-28 11:28:38 -0700 | [diff] [blame] | 1 | #include "ossl_random.hpp" |
| 2 | |
Ed Tanous | 2c6ffdb | 2023-06-28 11:28:38 -0700 | [diff] [blame] | 3 | #include <gmock/gmock.h> // IWYU pragma: keep |
| 4 | #include <gtest/gtest.h> // IWYU pragma: keep |
| 5 | |
| 6 | namespace |
| 7 | { |
| 8 | |
Ed Tanous | b7f3a82 | 2024-06-05 08:45:25 -0700 | [diff] [blame] | 9 | using testing::IsEmpty; |
Ed Tanous | 2c6ffdb | 2023-06-28 11:28:38 -0700 | [diff] [blame] | 10 | using testing::MatchesRegex; |
| 11 | |
| 12 | TEST(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 Tanous | b7f3a82 | 2024-06-05 08:45:25 -0700 | [diff] [blame] | 22 | TEST(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 Tanous | 2c6ffdb | 2023-06-28 11:28:38 -0700 | [diff] [blame] | 30 | } // namespace |