testing branch. We work on testing units

This commit is contained in:
Raffaele
2022-01-17 17:14:13 +01:00
parent 631f537aa1
commit df6eba3992
4 changed files with 50 additions and 1 deletions
+2
View File
@@ -1,2 +1,4 @@
gcc tests/test.c src/lina.c -o test -Wall -Wextra -g -Isrc/
gcc tests/test_loader.c src/lina.c -o test_loader -Wall -Wextra -g -Isrc/
gcc tests/my_test.c src/lina.c -o my_test -Wall -Wextra -g -Isrc/
Executable
BIN
View File
Binary file not shown.
+47
View File
@@ -0,0 +1,47 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "lina.h"
#define check assert
//Print the matrix A with size m by n
static void pmatrix(FILE *fp, double *A, int m, int n);
int main()
{
int n,m;
double *M;
char *msg;
FILE *ptr = fopen("tests/dot/t1.txt","r");
check(ptr != NULL);
M = lina_loadMatrixFromStream(ptr, &n, &m, &msg);
printf("%d, %d", m,n);
//pmatrix(stdout,M,m,n);
free(M);
fclose(ptr);
return 0;
}
static void pmatrix(FILE *fp, double *A,int m,int n){
for(int i = 0; i<m; i++){
fprintf(fp, " | ");
for(int j = 0; j< n; j++)
fprintf(fp, "%g ",A[i*n + j]);
fprintf(fp, "|\n");
}
fprintf(fp, "\n");
}