star-ck

Describe the radiative properties of gas mixtures
git clone git://git.meso-star.fr/star-ck.git
Log | Files | Refs | README | LICENSE

commit 76f9d4e1a578d5723007891404cbe9ba09c68a62
parent a5abd4ad73123c4e578f0ae6adfc36271a162c4f
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon,  5 Sep 2022 15:06:36 +0200

Test the hash functions

Diffstat:
Msrc/test_sck_load.c | 51++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 50 insertions(+), 1 deletion(-)

diff --git a/src/test_sck_load.c b/src/test_sck_load.c @@ -207,6 +207,14 @@ write_sck static void test_load(struct sck* sck) { + hash256_T hash0; + hash256_T hash1; + hash256_T band_hash0; + hash256_T band_hash1; + hash256_T pt_hash0; + hash256_T pt_hash1; + struct sck_band band; + FILE* fp = NULL; const char* filename = "test_file.sck"; const uint64_t pagesize = 16384; @@ -220,17 +228,55 @@ test_load(struct sck* sck) CHK(sck_load_stream(NULL, fp, filename) == RES_BAD_ARG); CHK(sck_load_stream(sck, NULL, filename) == RES_BAD_ARG); CHK(sck_load_stream(sck, fp, NULL) == RES_OK); + + CHK(sck_compute_hash(sck, NULL) == RES_BAD_ARG); + CHK(sck_compute_hash(NULL, hash0) == RES_BAD_ARG); + CHK(sck_compute_hash(sck, hash0) == RES_OK); + + CHK(sck_band_compute_hash(NULL, 0, band_hash0) == RES_BAD_ARG); + CHK(sck_band_compute_hash(sck, nbands, band_hash0) == RES_BAD_ARG); + CHK(sck_band_compute_hash(sck, 0, NULL) == RES_BAD_ARG); + CHK(sck_band_compute_hash(sck, 0, band_hash0) == RES_OK); + CHK(!hash256_eq(band_hash0, hash0)); + + CHK(sck_get_band(sck, 0, &band) == RES_OK); + CHK(sck_quad_pt_compute_hash(NULL, 0, pt_hash0) == RES_BAD_ARG); + CHK(sck_quad_pt_compute_hash(&band, band.quad_pts_count, pt_hash0) == RES_BAD_ARG); + CHK(sck_quad_pt_compute_hash(&band, 0, NULL) == RES_BAD_ARG); + CHK(sck_quad_pt_compute_hash(&band, 0, pt_hash0) == RES_OK); + CHK(!hash256_eq(pt_hash0, band_hash0)); + CHK(!hash256_eq(pt_hash0, hash0)); + check_sck_load(sck, nbands, nnodes); rewind(fp); CHK(sck_load_stream(sck, fp, filename) == RES_OK); - CHK(fclose(fp) == 0); CHK(sck_load(NULL, filename) == RES_BAD_ARG); CHK(sck_load(sck, NULL) == RES_BAD_ARG); CHK(sck_load(sck, "nop") == RES_IO_ERR); CHK(sck_load(sck, filename) == RES_OK); check_sck_load(sck, nbands, nnodes); + + CHK(sck_compute_hash(sck, hash1) == RES_OK); + CHK(hash256_eq(hash0, hash1)); + + rewind(fp); + write_sck(fp, pagesize, nbands+1, nnodes); + rewind(fp); + + CHK(sck_load_stream(sck, fp, filename) == RES_OK); + CHK(sck_compute_hash(sck, hash1) == RES_OK); + CHK(!hash256_eq(hash0, hash1)); + + CHK(sck_band_compute_hash(sck, 0, band_hash1) == RES_OK); + CHK(hash256_eq(band_hash0, band_hash1)); + + CHK(sck_get_band(sck, 0, &band) == RES_OK); + CHK(sck_quad_pt_compute_hash(&band, 0, pt_hash1) == RES_OK); + CHK(hash256_eq(pt_hash0, pt_hash1)); + + CHK(fclose(fp) == 0); } static void @@ -317,6 +363,7 @@ test_load_files(struct sck* sck, int argc, char** argv) int i; CHK(sck); FOR_EACH(i, 1, argc) { + hash256_T hash; size_t nnodes; size_t nbands; size_t iband; @@ -361,6 +408,8 @@ test_load_files(struct sck* sck, int argc, char** argv) } } } + + CHK(sck_compute_hash(sck, hash) == RES_OK); } }