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 <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include "../include/sointu.h"
|
#include "../include/sointu.h"
|
||||||
|
|
||||||
#if UINTPTR_MAX == 0xffffffff // are we 32-bit?
|
#if UINTPTR_MAX == 0xffffffff // are we 32-bit?
|
||||||
|
@ -42,8 +42,8 @@ int main(int argc, char* argv[]) {
|
|||||||
char actual_output_folder[] = "actual_output/";
|
char actual_output_folder[] = "actual_output/";
|
||||||
long fsize;
|
long fsize;
|
||||||
long bufsize;
|
long bufsize;
|
||||||
bool small_difference;
|
float max_diff;
|
||||||
double diff;
|
float diff;
|
||||||
#ifndef SU_USE_16BIT_OUTPUT
|
#ifndef SU_USE_16BIT_OUTPUT
|
||||||
float* buf = NULL;
|
float* buf = NULL;
|
||||||
float* filebuf = NULL;
|
float* filebuf = NULL;
|
||||||
@ -105,10 +105,10 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
fread((void*)filebuf, su_max_samples * 2, sizeof(*filebuf), f);
|
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++) {
|
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
|
#ifdef SU_USE_16BIT_OUTPUT
|
||||||
diff = diff / 32768.0f;
|
diff = diff / 32768.0f;
|
||||||
#endif
|
#endif
|
||||||
@ -117,13 +117,11 @@ int main(int argc, char* argv[]) {
|
|||||||
printf("4klang rendered different wave than expected\n");
|
printf("4klang rendered different wave than expected\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
else if (diff > 0.0f) {
|
max_diff = fmax(diff, max_diff);
|
||||||
small_difference = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (small_difference) {
|
if (max_diff > 1e-6) {
|
||||||
printf("4klang rendered almost correct wave, but with small errors (< 1e-3)\n");
|
printf("4klang rendered almost correct wave, but a small maximum error of %f\n",max_diff);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user