feat: adjust write-location-file
This commit is contained in:
parent
6447c61b1c
commit
3615fb97d6
|
@ -1,4 +1,3 @@
|
|||
/*write-location-file-test.c*/
|
||||
#include "write-location-file.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -11,9 +10,17 @@
|
|||
/*use macro extern int errno*/
|
||||
#include <errno.h>
|
||||
|
||||
static void test(){
|
||||
char lat[11]="52.26594";
|
||||
char lon[10]="10.52673";
|
||||
|
||||
static void test_write_location_file(){
|
||||
FILE* read;
|
||||
char buf[17];
|
||||
|
||||
/*create file*/
|
||||
write_location_file(lat, lon);
|
||||
|
||||
/*read file*/
|
||||
read = fopen("location-file.csv", "a+");
|
||||
|
||||
if (NULL == read) {
|
||||
|
@ -24,17 +31,17 @@ static void test(){
|
|||
|
||||
//printf("content of this file are \n");
|
||||
fscanf(read, "%17s", buf);
|
||||
printf("test() buf: %17s\n", buf);
|
||||
printf("test_write_location_file() buf: %17s\n", buf);
|
||||
|
||||
fclose(read);
|
||||
|
||||
char result[18] = "52.26594,10.52673";
|
||||
printf("test() result: %17s\n", result);
|
||||
printf("test_write_location_file() result: %17s\n", result);
|
||||
|
||||
assert(strcmp(buf, result)==0 && "test()");
|
||||
//assert(write_location_file("52.26594", "10.52673")==0 && "test()");
|
||||
assert(strcmp(buf, result)==0 && "test_write_location_file()");
|
||||
//assert(write_location_file("52.26594", "10.52673")==0 && "test_write_location_file()");
|
||||
}
|
||||
|
||||
int main(){
|
||||
test();
|
||||
test_write_location_file();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/*write-location-file.c*/
|
||||
|
||||
#include "write-location-file.h"
|
||||
|
||||
#include<stdio.h>
|
||||
|
@ -11,7 +9,6 @@
|
|||
int write_location_file(char *lat, char *lon){
|
||||
FILE *fp;
|
||||
|
||||
|
||||
printf("\nwrite-location-file() Start...\n");
|
||||
|
||||
printf("\nwrite-location-file() lat: %s, lon: %s\n", lat, lon);
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
/*write-location-file.h*/
|
||||
|
||||
int write_location_file(char *lat, char *lon);
|
||||
|
|
Loading…
Reference in New Issue