gigaseconds (C)

This commit is contained in:
2021-08-09 10:15:43 +02:00
parent 46793292f1
commit 58f636482e
5 changed files with 174 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
#include "gigasecond.h"
/* See GNUmakefile in following link for explanation
* https://exercism.io/my/solutions/103b2f7d92db42309c1988030f5202c7
*/
#if defined UNIT_TEST || defined DEBUG
#include <stdio.h>
#include <stdlib.h>
#endif
time_t gigasecond_after(time_t t)
{
return t+1e9;
}
#ifdef UNIT_TEST
int main(int ac, char **av)
{
int arg=1;
unsigned long i;
for (; arg<ac-1; ++arg) {
i=atol(av[arg]);
printf("giga(%lu)=%lu\n", i, gigasecond_after(i));
}
}
#endif

View File

@@ -0,0 +1,16 @@
#ifndef GIGASECOND_H
#define GIGASECOND_H
#include <time.h>
time_t gigasecond_after(time_t);
/* See GNUmakefile in following link for explanation
* https://exercism.io/my/solutions/103b2f7d92db42309c1988030f5202c7
*/
#ifdef TESTALL
#undef TEST_IGNORE
#define TEST_IGNORE() {}
#endif
#endif