diff --git a/tests/aws-cpp-sdk-core-tests/utils/UUIDTest.cpp b/tests/aws-cpp-sdk-core-tests/utils/UUIDTest.cpp index d50d1c6a887..39b2e4b3b15 100644 --- a/tests/aws-cpp-sdk-core-tests/utils/UUIDTest.cpp +++ b/tests/aws-cpp-sdk-core-tests/utils/UUIDTest.cpp @@ -22,19 +22,19 @@ TEST_F(UUIDTest, TestPlatformGeneratesUUID) for(size_t i = 0u; i < 1000u; ++i) { UUID uuid = UUID::RandomUUID(); - Aws::String uuidStr = uuid; + Aws::String uuidStr = uuid; ASSERT_EQ(36u, uuidStr.length()); ByteBuffer rawUUID = uuid; ASSERT_EQ(16u, rawUUID.GetLength()); ASSERT_EQ(0x40u, 0x40u & rawUUID[6]); ASSERT_EQ(0x80u, 0x80u & rawUUID[8]); - auto iter = generatedUUids.find(uuidStr); - auto endIter = generatedUUids.end(); - ASSERT_TRUE( iter == endIter ); + auto iter = generatedUUids.find(uuidStr); + auto endIter = generatedUUids.end(); + ASSERT_TRUE( iter == endIter ); generatedUUids.insert(uuidStr); - } + } } TEST_F(UUIDTest, TestUUIDToStringConversion) @@ -112,3 +112,34 @@ TEST_F(UUIDTest, TestPseudoRandomParallelUUID) ASSERT_EQ(BATCHES * 1000u, generatedAllUUids.size()); } +TEST_F(UUIDTest, TestPlatformRandomParallelUUID) +{ + Aws::UnorderedSet generatedAllUUids; + + static const size_t BATCHES = 20; + static const size_t PER_BATCH = 1000u; + Aws::Vector>> futures(BATCHES); + + for(size_t i = 0; i < BATCHES; ++i) + { + futures[i] = std::async( + []() + { + Aws::UnorderedSet generatedUUids; + for(size_t i = 0u; i < PER_BATCH; ++i) + { + generatedUUids.insert(StringUtils::ToLower(Aws::String(UUID::RandomUUID()).c_str())); + } + + return generatedUUids; + }); + } + + for(size_t i = 0; i < BATCHES; ++i) + { + Aws::UnorderedSet batch = futures[i].get(); + ASSERT_EQ(PER_BATCH, batch.size()); + generatedAllUUids.insert(batch.begin(), batch.end()); + } + ASSERT_EQ(BATCHES * PER_BATCH, generatedAllUUids.size()); +} \ No newline at end of file