Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
test_randlib.c
00001 /* 00002 * Copyright (c) 2016 ARM. All rights reserved. 00003 */ 00004 #include "test_randlib.h" 00005 #include <string.h> 00006 #include <inttypes.h> 00007 #include "randLIB.h" 00008 00009 bool test_randLIB_seed_random() 00010 { 00011 randLIB_seed_random(); 00012 return true; 00013 } 00014 00015 bool test_randLIB_get_8bit() 00016 { 00017 randLIB_seed_random(); 00018 uint8_t test = randLIB_get_8bit(); 00019 if( test == 0 ) { 00020 test = randLIB_get_8bit(); 00021 if( test == 0 ) { 00022 return false; 00023 } 00024 } 00025 return true; 00026 } 00027 00028 bool test_randLIB_get_16bit() 00029 { 00030 randLIB_seed_random(); 00031 uint16_t test = randLIB_get_16bit(); 00032 if( test == 0 ) { 00033 test = randLIB_get_16bit(); 00034 if( test == 0 ) { 00035 return false; 00036 } 00037 } 00038 return true; 00039 } 00040 00041 bool test_randLIB_get_32bit() 00042 { 00043 randLIB_seed_random(); 00044 uint32_t test = randLIB_get_32bit(); 00045 if( test == 0 ) { 00046 test = randLIB_get_32bit(); 00047 if( test == 0 ) { 00048 return false; 00049 } 00050 } 00051 return true; 00052 } 00053 00054 bool test_randLIB_get_n_bytes_random() 00055 { 00056 int8_t ret = randLIB_get_n_bytes_random(NULL, 0); 00057 if( ret != -1){ 00058 return false; 00059 } 00060 00061 uint8_t dat[5]; 00062 ret = randLIB_get_n_bytes_random(&dat, 5); 00063 if( ret != 0){ 00064 return false; 00065 } 00066 return true; 00067 } 00068 00069 bool test_randLIB_get_random_in_range() 00070 { 00071 uint16_t ret = randLIB_get_random_in_range(2, 2); 00072 if( ret != 2 ){ 00073 return false; 00074 } 00075 00076 ret = randLIB_get_random_in_range(2, 3); 00077 if( ret != 2 && ret != 3){ 00078 return false; 00079 } 00080 00081 ret = randLIB_get_random_in_range(0, 0xFFFF); 00082 00083 return true; 00084 } 00085 00086 bool test_randLIB_randomise_base() 00087 { 00088 uint32_t ret = randLIB_randomise_base(0,0,0); 00089 if( ret ){ 00090 return false; 00091 } 00092 ret = randLIB_randomise_base(0xffff0000,0x8888,0x8888); 00093 if( ret != 0xffffffff ){ 00094 return false; 00095 } 00096 return true; 00097 }
Generated on Tue Jul 12 2022 12:28:55 by
