time_test.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2014, 2015  Internet Systems Consortium, Inc. ("ISC")
00003  *
00004  * Permission to use, copy, modify, and/or distribute this software for any
00005  * purpose with or without fee is hereby granted, provided that the above
00006  * copyright notice and this permission notice appear in all copies.
00007  *
00008  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00009  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00010  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00011  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00012  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00013  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00014  * PERFORMANCE OF THIS SOFTWARE.
00015  */
00016 
00017 #include <config.h>
00018 #include <stdlib.h>
00019 
00020 #include <atf-c.h>
00021 
00022 #include <isc/time.h>
00023 #include <isc/result.h>
00024 
00025 ATF_TC(isc_time_parsehttptimestamp);
00026 ATF_TC_HEAD(isc_time_parsehttptimestamp, tc) {
00027         atf_tc_set_md_var(tc, "descr", "parse http time stamp");
00028 }
00029 ATF_TC_BODY(isc_time_parsehttptimestamp, tc) {
00030         isc_result_t result;
00031         isc_time_t t, x;
00032         char buf[ISC_FORMATHTTPTIMESTAMP_SIZE];
00033 
00034         setenv("TZ", "PST8PDT", 1);
00035         result = isc_time_now(&t);
00036         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00037 
00038         isc_time_formathttptimestamp(&t, buf, sizeof(buf));
00039         result = isc_time_parsehttptimestamp(buf, &x);
00040         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00041         ATF_REQUIRE_EQ(isc_time_seconds(&t), isc_time_seconds(&x));
00042 }
00043 
00044 /*
00045  * Main
00046  */
00047 ATF_TP_ADD_TCS(tp) {
00048         ATF_TP_ADD_TC(tp, isc_time_parsehttptimestamp);
00049         return (atf_no_error());
00050 }
00051 

Generated on Tue Apr 28 17:41:05 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha