mirror of
https://github.com/TREX-CoE/trexio.git
synced 2025-04-29 11:54:45 +02:00
Adapt the tests
This commit is contained in:
parent
0bbe16efce
commit
405f19c4bc
@ -192,11 +192,21 @@ class TestIO:
|
||||
self.test_array_1D()
|
||||
self.test_array_2D()
|
||||
|
||||
assert trexio.has_nucleus(self.test_file)
|
||||
|
||||
trexio.delete_nucleus(self.test_file)
|
||||
|
||||
assert not trexio.has_nucleus_num(self.test_file)
|
||||
assert not trexio.has_nucleus_charge(self.test_file)
|
||||
assert not trexio.has_nucleus_coord(self.test_file)
|
||||
assert not trexio.has_nucleus(self.test_file)
|
||||
|
||||
|
||||
def test_has_group(self):
|
||||
"""Check existense of a group."""
|
||||
self.open()
|
||||
assert trexio.has_nucleus(self.test_file)
|
||||
assert not trexio.has_rdm(self.test_file)
|
||||
|
||||
|
||||
def test_context_manager(self):
|
||||
|
@ -55,6 +55,14 @@ static int test_has_dset (const char* file_name, const back_end_t backend) {
|
||||
file = trexio_open(file_name, 'r', backend, &rc);
|
||||
assert (file != NULL);
|
||||
|
||||
// check that the group exists
|
||||
rc = trexio_has_basis(file);
|
||||
assert(rc==TREXIO_SUCCESS);
|
||||
|
||||
// check that the group does not exist
|
||||
rc = trexio_has_mo(file);
|
||||
assert(rc==TREXIO_HAS_NOT);
|
||||
|
||||
// check that the previously written dataset exists
|
||||
rc = trexio_has_basis_nucleus_index(file);
|
||||
assert (rc == TREXIO_SUCCESS);
|
||||
@ -130,5 +138,3 @@ int main(void) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,6 +55,14 @@ static int test_has_dset (const char* file_name, const back_end_t backend) {
|
||||
file = trexio_open(file_name, 'r', backend, &rc);
|
||||
assert (file != NULL);
|
||||
|
||||
// check that the group exists
|
||||
rc = trexio_has_basis(file);
|
||||
assert(rc==TREXIO_SUCCESS);
|
||||
|
||||
// check that the group does not exist
|
||||
rc = trexio_has_mo(file);
|
||||
assert(rc==TREXIO_HAS_NOT);
|
||||
|
||||
// check that the previously written dataset exists
|
||||
rc = trexio_has_basis_nucleus_index(file);
|
||||
assert (rc == TREXIO_SUCCESS);
|
||||
@ -130,5 +138,3 @@ int main(void) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,6 +86,14 @@ static int test_has_dset_sparse (const char* file_name, const back_end_t backend
|
||||
assert (file != NULL);
|
||||
assert (rc == TREXIO_SUCCESS);
|
||||
|
||||
// check that the group exists
|
||||
rc = trexio_has_mo_2e_int(file);
|
||||
assert(rc==TREXIO_SUCCESS);
|
||||
|
||||
// check that the group does not exist
|
||||
rc = trexio_has_rdm(file);
|
||||
assert(rc==TREXIO_HAS_NOT);
|
||||
|
||||
// first check that mo_2e_int_eri_lr (we only write non-lr component in this unit test)
|
||||
rc = trexio_has_mo_2e_int_eri_lr(file);
|
||||
assert(rc==TREXIO_HAS_NOT);
|
||||
@ -147,7 +155,7 @@ static int test_read_dset_sparse (const char* file_name, const back_end_t backen
|
||||
assert(index_read[4*offset_data_read] == 4 * (int32_t) (offset_file_read-offset));
|
||||
|
||||
// now attempt to read so that one encounters end of file during reading (i.e. offset_file_read + chunk_read > size_max)
|
||||
offset_file_read = 97;
|
||||
offset_file_read = 97L;
|
||||
offset_data_read = 1;
|
||||
int64_t eof_read_size_check = SIZE - offset_file_read; // if offset_file_read=97 => only 3 integrals will be read out of total of 100
|
||||
|
||||
@ -159,11 +167,6 @@ static int test_read_dset_sparse (const char* file_name, const back_end_t backen
|
||||
assert(chunk_read == eof_read_size_check);
|
||||
assert(index_read[4*size_r-1] == 0);
|
||||
assert(index_read[4*offset_data_read] == 4 * (int32_t) (offset_file_read-offset));
|
||||
/*
|
||||
for(int i=0; i<size_r; ++i){
|
||||
printf("%d %lf\n", index_read[4*i], value_read[i]);
|
||||
}
|
||||
*/
|
||||
|
||||
// close current session
|
||||
rc = trexio_close(file);
|
||||
|
@ -86,6 +86,14 @@ static int test_has_dset_sparse (const char* file_name, const back_end_t backend
|
||||
assert (file != NULL);
|
||||
assert (rc == TREXIO_SUCCESS);
|
||||
|
||||
// check that the group exists
|
||||
rc = trexio_has_mo_2e_int(file);
|
||||
assert(rc==TREXIO_SUCCESS);
|
||||
|
||||
// check that the group does not exist
|
||||
rc = trexio_has_rdm(file);
|
||||
assert(rc==TREXIO_HAS_NOT);
|
||||
|
||||
// first check that mo_2e_int_eri_lr (we only write non-lr component in this unit test)
|
||||
rc = trexio_has_mo_2e_int_eri_lr(file);
|
||||
assert(rc==TREXIO_HAS_NOT);
|
||||
|
@ -143,6 +143,12 @@ subroutine test_write(file_name, back_end)
|
||||
rc = trexio_has_determinant_list(trex_file)
|
||||
call trexio_assert(rc, TREXIO_HAS_NOT, 'SUCCESS HAS NOT 4')
|
||||
|
||||
rc = trexio_has_nucleus(trex_file)
|
||||
call trexio_assert(rc, TREXIO_HAS_NOT, 'SUCCESS HAS NOT 5')
|
||||
|
||||
rc = trexio_has_ao_2e_int(trex_file)
|
||||
call trexio_assert(rc, TREXIO_HAS_NOT, 'SUCCESS HAS NOT 6')
|
||||
|
||||
rc = trexio_write_nucleus_num(trex_file, nucleus_num)
|
||||
call trexio_assert(rc, TREXIO_SUCCESS, 'SUCCESS WRITE NUM')
|
||||
|
||||
@ -207,6 +213,12 @@ subroutine test_write(file_name, back_end)
|
||||
rc = trexio_has_determinant_list(trex_file)
|
||||
call trexio_assert(rc, TREXIO_SUCCESS, 'SUCCESS HAS 4')
|
||||
|
||||
rc = trexio_has_nucleus(trex_file)
|
||||
call trexio_assert(rc, TREXIO_SUCCESS, 'SUCCESS HAS 5')
|
||||
|
||||
rc = trexio_has_ao_2e_int(trex_file)
|
||||
call trexio_assert(rc, TREXIO_SUCCESS, 'SUCCESS HAS 6')
|
||||
|
||||
rc = trexio_close(trex_file)
|
||||
call trexio_assert(rc, TREXIO_SUCCESS, 'SUCCESS CLOSE')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user