mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
Fix all CMake tests passing on MinGW: consider minor (< 1e-6) errors in waveform shape successes.
Such errors are due to floating point rounding errors.
This commit is contained in:
parent
b9ec015b4a
commit
95b70018cc
@ -1,5 +1,6 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "../include/sointu.h"
|
||||
|
||||
#if UINTPTR_MAX == 0xffffffff // are we 32-bit?
|
||||
|
@ -42,8 +42,8 @@ int main(int argc, char* argv[]) {
|
||||
char actual_output_folder[] = "actual_output/";
|
||||
long fsize;
|
||||
long bufsize;
|
||||
bool small_difference;
|
||||
double diff;
|
||||
float max_diff;
|
||||
float diff;
|
||||
#ifndef SU_USE_16BIT_OUTPUT
|
||||
float* buf = NULL;
|
||||
float* filebuf = NULL;
|
||||
@ -105,10 +105,10 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
fread((void*)filebuf, su_max_samples * 2, sizeof(*filebuf), f);
|
||||
|
||||
small_difference = false;
|
||||
max_diff = 0.0f;
|
||||
|
||||
for (n = 0; n < su_max_samples * 2; n++) {
|
||||
diff = (double)(buf[n]) - (double)(filebuf[n]);
|
||||
diff = buf[n] - filebuf[n];
|
||||
#ifdef SU_USE_16BIT_OUTPUT
|
||||
diff = diff / 32768.0f;
|
||||
#endif
|
||||
@ -117,13 +117,11 @@ int main(int argc, char* argv[]) {
|
||||
printf("4klang rendered different wave than expected\n");
|
||||
goto fail;
|
||||
}
|
||||
else if (diff > 0.0f) {
|
||||
small_difference = true;
|
||||
}
|
||||
max_diff = fmax(diff, max_diff);
|
||||
}
|
||||
|
||||
if (small_difference) {
|
||||
printf("4klang rendered almost correct wave, but with small errors (< 1e-3)\n");
|
||||
if (max_diff > 1e-6) {
|
||||
printf("4klang rendered almost correct wave, but a small maximum error of %f\n",max_diff);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user