1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
29 Serial.println("Testing Random Number generator for Arduino");
31 Serial.print("Testing OCSeedRandom ... ");
32 if (OCSeedRandom() == 0) {
33 Serial.println("[Success]");
35 Serial.println("[Fail]");
38 Serial.print("Testing OCGetRandomByte ... ");
39 uint8_t value8 = OCGetRandomByte();
40 if (value8 >= 0 && value8 < pow(2, 8)) {
41 Serial.println("[Success]");
43 Serial.println("[Fail]");
46 Serial.print("Testing OCGetRandom ... ");
47 uint32_t value32 = OCGetRandom();
48 if (value32 >= 0 && value32 < pow(2, 32)) {
49 Serial.println("[Success]");
51 Serial.println("[Fail]");
54 Serial.print("Testing OCFillRandomMem ... ");
55 uint8_t array[ARR_SIZE] = {};
56 OCFillRandomMem(array + 1, ARR_SIZE - 2);
59 for (int i = 1; i <= ARR_SIZE - 2; i++) {
61 if (value82 >= 0 && value82 < pow(2, 8)) {
65 if (overall == ARR_SIZE - 2 && array[0] == 0 && array[ARR_SIZE - 1] == 0) {
66 Serial.println("[Success]");
68 Serial.println("[Fail]");
69 Serial.print("overall:");Serial.println(overall);
70 Serial.print("array[0]:");Serial.println(array[0]);
71 Serial.print("array[ARR_SIZE - 1]:");Serial.println(array[ARR_SIZE - 1]);
73 Serial.println("========DONE TESTING=========");