sandbox-c/write-location-file/write-location-file-test.c

41 lines
895 B
C

/*write-location-file-test.c*/
#include "write-location-file.h"
#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*use macro extern int errno*/
#include <errno.h>
static void test(){
FILE* read;
char buf[17];
read = fopen("location-file.csv", "a+");
if (NULL == read) {
/*failed to open file and associate stream*/
fprintf(stderr, "Value of errno: %d\n", errno);
fprintf(stderr, "Error opening file: %s\n", strerror(errno));
}
//printf("content of this file are \n");
fscanf(read, "%17s", buf);
printf("test() buf: %17s\n", buf);
fclose(read);
char result[18] = "52.26594,10.52673";
printf("test() result: %17s\n", result);
assert(strcmp(buf, result)==0 && "test()");
//assert(write_location_file("52.26594", "10.52673")==0 && "test()");
}
int main(){
test();
}