1 #include "ossl_random.hpp" 2 3 #include <gmock/gmock.h> // IWYU pragma: keep 4 #include <gtest/gtest.h> // IWYU pragma: keep 5 6 namespace 7 { 8 9 using testing::IsEmpty; 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 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 30 } // namespace 31