#include "../hrtf/mysofa.h"
#include "../hrtf/tools.h"
#include "tests.h"
#include <assert.h>
#include <float.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
void test_cache() {
char *filename1 = "build/sofacoustics.org/data/sofa_api_mo_test/Pulse.sofa";
char *filename2 = "tests/tester.sofa";
float sr1 = 48000;
float sr2 = 8000;
struct MYSOFA_EASY *easy1 = malloc(sizeof(struct MYSOFA_EASY));
struct MYSOFA_EASY *easy2 = malloc(sizeof(struct MYSOFA_EASY));
bzero(easy1, sizeof(struct MYSOFA_EASY));
bzero(easy2, sizeof(struct MYSOFA_EASY));
mysofa_close(easy2);
CU_ASSERT(!mysofa_cache_lookup(filename1, sr1));
CU_ASSERT(mysofa_cache_store(easy1, filename1, sr1) == easy1);
CU_ASSERT(mysofa_cache_lookup(filename1, sr1) ==
easy1);
mysofa_cache_release_all();
CU_ASSERT(!mysofa_cache_lookup(filename1, sr1));
easy1 = malloc(sizeof(struct MYSOFA_EASY));
bzero(easy1, sizeof(struct MYSOFA_EASY));
CU_ASSERT(mysofa_cache_store(easy1, filename1, sr1) == easy1);
easy2 = malloc(
sizeof(struct MYSOFA_EASY));
bzero(easy2, sizeof(struct MYSOFA_EASY));
CU_ASSERT(mysofa_cache_store(easy2, filename1, sr1) ==
easy1);
easy2 = malloc(
sizeof(struct MYSOFA_EASY));
bzero(easy2, sizeof(struct MYSOFA_EASY));
CU_ASSERT(mysofa_cache_store(easy2, filename1, sr2) ==
easy2);
CU_ASSERT(mysofa_cache_lookup(filename1, sr2) == easy2);
mysofa_cache_release(easy2);
mysofa_cache_release(easy2);
CU_ASSERT(!mysofa_cache_lookup(filename1, sr2));
easy2 = malloc(sizeof(struct MYSOFA_EASY));
bzero(easy2, sizeof(struct MYSOFA_EASY));
CU_ASSERT(mysofa_cache_store(easy2, filename2, sr2) ==
easy2);
CU_ASSERT(mysofa_cache_lookup(filename2, sr2) == easy2);
mysofa_cache_release(easy2);
mysofa_cache_release(easy2);
CU_ASSERT(!mysofa_cache_lookup(filename1, sr2));
mysofa_cache_release_all();
}