mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2024-08-17 02:41:43 +02:00
updated tests, but tests fail
This commit is contained in:
parent
b310ae8638
commit
87cfdc88d3
@ -26,7 +26,7 @@ C than in Fortran.
|
||||
*** Test
|
||||
#+BEGIN_SRC C :tangle test_qmckl_context.c
|
||||
#include "qmckl_context.h"
|
||||
#include "qmckl_test.h"
|
||||
#include <stdio.h>
|
||||
int main() {
|
||||
qmckl_exit_code rc; /* return code */
|
||||
rc = QMCKL_SUCCESS;
|
||||
@ -61,6 +61,15 @@ typedef struct qmckl_context_struct {
|
||||
#+BEGIN_SRC C :tangle test_qmckl_context.c
|
||||
qmckl_context context;
|
||||
qmckl_context new_context;
|
||||
|
||||
/* This needs to be repeated in the tests because we don't want to
|
||||
expose it in the headers.
|
||||
*/
|
||||
typedef struct qmckl_context_struct {
|
||||
struct qmckl_context_struct * prev;
|
||||
int precision;
|
||||
int range;
|
||||
} qmckl_context_struct;
|
||||
#+END_SRC
|
||||
|
||||
** =qmckl_context_create=
|
||||
@ -97,11 +106,11 @@ qmckl_context qmckl_context_create() {
|
||||
#+BEGIN_SRC C :tangle test_qmckl_context.c
|
||||
context = qmckl_context_create();
|
||||
if (context == (qmckl_context) 0) {
|
||||
eprintf("qmckl_context_create\n");
|
||||
fprintf(stderr,"qmckl_context_create\n");
|
||||
rc = QMCKL_FAILURE;
|
||||
}
|
||||
if ( ((qmckl_context_struct*) new_context)->precision != QMCKL_DEFAULT_PRECISION ) {
|
||||
eprintf("qmckl_context_copy: No access to data\n");
|
||||
fprintf(stderr,"qmckl_context_copy: No access to data\n");
|
||||
rc = QMCKL_FAILURE;
|
||||
}
|
||||
#+END_SRC
|
||||
@ -150,15 +159,15 @@ qmckl_context qmckl_context_copy(const qmckl_context context) {
|
||||
#+BEGIN_SRC C :tangle test_qmckl_context.c
|
||||
new_context = qmckl_context_copy(context);
|
||||
if (new_context == (qmckl_context) 0) {
|
||||
eprintf("qmckl_context_copy: Allocation failure\n");
|
||||
fprintf(stderr,"qmckl_context_copy: Allocation failure\n");
|
||||
rc = QMCKL_FAILURE;
|
||||
}
|
||||
if (new_context == context ) {
|
||||
eprintf("qmckl_context_copy: Same pointer\n");
|
||||
fprintf(stderr,"qmckl_context_copy: Same pointer\n");
|
||||
rc = QMCKL_FAILURE;
|
||||
}
|
||||
if ( ((qmckl_context_struct*) new_context)->precision != QMCKL_DEFAULT_PRECISION ) {
|
||||
eprintf("qmckl_context_copy: No access to data\n");
|
||||
fprintf(stderr,"qmckl_context_copy: No access to data\n");
|
||||
rc = QMCKL_FAILURE;
|
||||
}
|
||||
#+END_SRC
|
||||
@ -193,19 +202,19 @@ qmckl_context qmckl_context_previous(const qmckl_context context) {
|
||||
*** Test
|
||||
#+BEGIN_SRC C :tangle test_qmckl_context.c
|
||||
if (qmckl_context_previous(new_context) == (qmckl_context) 0) {
|
||||
eprintf("qmckl_context_copy: Null pointer\n");
|
||||
fprintf(stderr,"qmckl_context_copy: Null pointer\n");
|
||||
rc = QMCKL_FAILURE;
|
||||
}
|
||||
if (qmckl_context_previous(new_context) != context) {
|
||||
eprintf("qmckl_context_copy: Wrong pointer\n");
|
||||
fprintf(stderr,"qmckl_context_copy: Wrong pointer\n");
|
||||
rc = QMCKL_FAILURE;
|
||||
}
|
||||
if (qmckl_context_previous(context) != (qmckl_context) 0) {
|
||||
eprintf("qmckl_context_copy: Expected null pointer (1)\n");
|
||||
fprintf(stderr,"qmckl_context_copy: Expected null pointer (1)\n");
|
||||
rc = QMCKL_FAILURE;
|
||||
}
|
||||
if (qmckl_context_previous((qmckl_context) 0) != (qmckl_context) 0) {
|
||||
eprintf("qmckl_context_copy: Expected null pointer (2)\n");
|
||||
fprintf(stderr,"qmckl_context_copy: Expected null pointer (2)\n");
|
||||
rc = QMCKL_FAILURE;
|
||||
}
|
||||
#+END_SRC
|
||||
@ -246,19 +255,19 @@ qmckl_exit_code qmckl_context_destroy(qmckl_context *context) {
|
||||
*** Test
|
||||
#+BEGIN_SRC C :tangle test_qmckl_context.c
|
||||
if (new_context == (qmckl_context) 0) {
|
||||
eprintf("qmckl_context_destroy: new_context is NULL\n");
|
||||
fprintf(stderr,"qmckl_context_destroy: new_context is NULL\n");
|
||||
rc = QMCKL_FAILURE;
|
||||
}
|
||||
if (qmckl_context_destroy(&new_context) == QMCKL_FAILURE) {
|
||||
eprintf("qmckl_context_destroy: Unable to destroy the new_context\n");
|
||||
fprintf(stderr,"qmckl_context_destroy: Unable to destroy the new_context\n");
|
||||
rc = QMCKL_FAILURE;
|
||||
}
|
||||
if (new_context != (qmckl_context) 0) {
|
||||
eprintf("qmckl_context_destroy: new_context should be NULL\n");
|
||||
fprintf(stderr,"qmckl_context_destroy: new_context should be NULL\n");
|
||||
rc = QMCKL_FAILURE;
|
||||
}
|
||||
if (qmckl_context_destroy((qmckl_context) 0) == QMCKL_SUCCESS) {
|
||||
eprintf("qmckl_context_destroy: Failure expected with NULL pointer\n");
|
||||
fprintf(stderr,"qmckl_context_destroy: Failure expected with NULL pointer\n");
|
||||
rc = QMCKL_FAILURE;
|
||||
}
|
||||
#+END_SRC
|
||||
|
Loading…
Reference in New Issue
Block a user