2 //******************************************************************
4 // Copyright 2014 Intel Corporation All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
11 #include "gtest/gtest.h"
15 int main(int argc, char* argv[]) {
16 testing::InitGoogleTest(&argc, argv);
17 return RUN_ALL_TESTS();
20 TEST(RandomGeneration,OCSeedRandom) {
21 EXPECT_EQ((uint32_t )0, OCSeedRandom());
24 TEST(RandomGeneration,OCGetRandomByte) {
25 uint8_t value = OCGetRandomByte();
26 EXPECT_LE((uint8_t )0, value);
27 EXPECT_GT(pow(2, 8), value);
30 TEST(RandomGeneration,OCGetRandom) {
31 uint32_t value = OCGetRandom();
32 EXPECT_LE((uint8_t )0, value);
33 EXPECT_GT(pow(2, 32), value);
36 TEST(RandomGeneration,OCFillRandomMem) {
37 uint16_t ARR_SIZE = 20;
38 uint8_t array[ARR_SIZE];
39 memset(array, 0, ARR_SIZE);
40 OCFillRandomMem(array + 1, ARR_SIZE - 2);
42 for (int i = 1; i < ARR_SIZE - 2; i++) {
43 uint8_t value = array[i];
44 EXPECT_LE((uint8_t )0, value);
45 EXPECT_GT(pow(2, 8), value);
47 EXPECT_EQ((uint8_t )0, array[0]);
48 EXPECT_EQ((uint8_t )0, array[ARR_SIZE - 1]);