You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
797 B

/* Verify correctness of the peak routine
* Copyright 2004 Phil Karn, KA9Q
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/* These values should trigger leading/trailing array fragment handling */
#define NSAMP 200002
#define OFFSET 1
int peakval(signed short *,int);
int peakval_port(signed short *,int);
int main(){
int i,s;
int result,rresult;
signed short samples[NSAMP];
srandom(time(NULL));
for(i=0;i<NSAMP;i++){
do {
s = random() & 0x0fff;
} while(s == 0x8000);
samples[i] = s;
}
samples[5] = 25000;
rresult = peakval_port(&samples[OFFSET],NSAMP-OFFSET);
result = peakval(&samples[OFFSET],NSAMP-OFFSET);
if(result == rresult){
printf("OK\n");
} else {
printf("peak mismatch: %d != %d\n",result,rresult);
}
exit(0);
}