]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
caljulian.c:
authorDamir Tomic <viperus@ntp.org>
Sun, 14 Jun 2015 06:29:55 +0000 (08:29 +0200)
committerDamir Tomic <viperus@ntp.org>
Sun, 14 Jun 2015 06:29:55 +0000 (08:29 +0200)
  fixed printf in case of an error

bk: 557d1f63HYq_if37fbOWPCEZU_l9Nw

tests/libntp/caljulian.c
tests/libntp/run-test-caljulian.c

index 52e65fccacab6b37fa99fed8b86dd1be72dad13e..789bd71bb70144424463d0d0341397299df8bf82 100644 (file)
 //added struct to calendar!
 
 char * CalendarToString(const struct calendar cal) { //&cal
-       char ss[100];
+       char * ss = malloc (sizeof (char) * 100);
        
-       //ss << cal.year << "-" << (u_int)cal.month << "-" << (u_int)cal.monthday
-        //  << " (" << cal.yearday << ") " << (u_int)cal.hour << ":"
-        //  << (u_int)cal.minute << ":" << (u_int)cal.second;
+       char buffer[100] ="";
+       sprintf(buffer, "%u", cal.year);
+       strcat(ss,buffer);
+       strcat(ss,"-");
+       sprintf(buffer, "%u", (u_int)cal.month);
+       strcat(ss,buffer);
+       strcat(ss,"-");
+       sprintf(buffer, "%u", (u_int)cal.monthday);
+       strcat(ss,buffer);
+       strcat(ss," (");
+       sprintf(buffer, "%u", (u_int) cal.yearday);
+       strcat(ss,buffer);
+       strcat(ss,") ");
+       sprintf(buffer, "%u", (u_int)cal.hour);
+       strcat(ss,buffer);
+       strcat(ss,":");
+       sprintf(buffer, "%u", (u_int)cal.minute);
+       strcat(ss,buffer);
+       strcat(ss,":");
+       sprintf(buffer, "%u", (u_int)cal.second);
+       strcat(ss,buffer);
+       printf("AAA %s ",ss);
+       //ss << cal.year << "-" << (u_int)cal.month << "-" << (u_int)cal.monthday << " (" << cal.yearday << ") " << (u_int)cal.hour << ":" << (u_int)cal.minute << ":" << (u_int)cal.second;
        return ss;
 }
 
index 853953361c2e806494e4c31c21ede7599cfc4206..9fafadb4d82ce9c7d89c68ce5f59db9b239b950f 100644 (file)
@@ -48,10 +48,10 @@ int main(int argc, char *argv[])
   progname = argv[0];
   Unity.TestFile = "caljulian.c";
   UnityBegin("caljulian.c");
-  RUN_TEST(test_RegularTime, 59);
-  RUN_TEST(test_LeapYear, 70);
-  RUN_TEST(test_uLongBoundary, 81);
-  RUN_TEST(test_uLongWrapped, 92);
+  RUN_TEST(test_RegularTime, 80);
+  RUN_TEST(test_LeapYear, 91);
+  RUN_TEST(test_uLongBoundary, 102);
+  RUN_TEST(test_uLongWrapped, 113);
 
   return (UnityEnd());
 }