1*6236dae4SAndroid Build Coastguard Worker /***************************************************************************
2*6236dae4SAndroid Build Coastguard Worker * _ _ ____ _
3*6236dae4SAndroid Build Coastguard Worker * Project ___| | | | _ \| |
4*6236dae4SAndroid Build Coastguard Worker * / __| | | | |_) | |
5*6236dae4SAndroid Build Coastguard Worker * | (__| |_| | _ <| |___
6*6236dae4SAndroid Build Coastguard Worker * \___|\___/|_| \_\_____|
7*6236dae4SAndroid Build Coastguard Worker *
8*6236dae4SAndroid Build Coastguard Worker * Copyright (C) Daniel Stenberg, <[email protected]>, et al.
9*6236dae4SAndroid Build Coastguard Worker *
10*6236dae4SAndroid Build Coastguard Worker * This software is licensed as described in the file COPYING, which
11*6236dae4SAndroid Build Coastguard Worker * you should have received as part of this distribution. The terms
12*6236dae4SAndroid Build Coastguard Worker * are also available at https://curl.se/docs/copyright.html.
13*6236dae4SAndroid Build Coastguard Worker *
14*6236dae4SAndroid Build Coastguard Worker * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15*6236dae4SAndroid Build Coastguard Worker * copies of the Software, and permit persons to whom the Software is
16*6236dae4SAndroid Build Coastguard Worker * furnished to do so, under the terms of the COPYING file.
17*6236dae4SAndroid Build Coastguard Worker *
18*6236dae4SAndroid Build Coastguard Worker * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19*6236dae4SAndroid Build Coastguard Worker * KIND, either express or implied.
20*6236dae4SAndroid Build Coastguard Worker *
21*6236dae4SAndroid Build Coastguard Worker * SPDX-License-Identifier: curl
22*6236dae4SAndroid Build Coastguard Worker *
23*6236dae4SAndroid Build Coastguard Worker ***************************************************************************/
24*6236dae4SAndroid Build Coastguard Worker #include "curlcheck.h"
25*6236dae4SAndroid Build Coastguard Worker
26*6236dae4SAndroid Build Coastguard Worker #include "timeval.h"
27*6236dae4SAndroid Build Coastguard Worker
unit_setup(void)28*6236dae4SAndroid Build Coastguard Worker static CURLcode unit_setup(void)
29*6236dae4SAndroid Build Coastguard Worker {
30*6236dae4SAndroid Build Coastguard Worker return CURLE_OK;
31*6236dae4SAndroid Build Coastguard Worker }
32*6236dae4SAndroid Build Coastguard Worker
unit_stop(void)33*6236dae4SAndroid Build Coastguard Worker static void unit_stop(void)
34*6236dae4SAndroid Build Coastguard Worker {
35*6236dae4SAndroid Build Coastguard Worker
36*6236dae4SAndroid Build Coastguard Worker }
37*6236dae4SAndroid Build Coastguard Worker
38*6236dae4SAndroid Build Coastguard Worker struct a {
39*6236dae4SAndroid Build Coastguard Worker struct curltime first;
40*6236dae4SAndroid Build Coastguard Worker struct curltime second;
41*6236dae4SAndroid Build Coastguard Worker time_t result;
42*6236dae4SAndroid Build Coastguard Worker };
43*6236dae4SAndroid Build Coastguard Worker
44*6236dae4SAndroid Build Coastguard Worker UNITTEST_START
45*6236dae4SAndroid Build Coastguard Worker {
46*6236dae4SAndroid Build Coastguard Worker struct a tests[] = {
47*6236dae4SAndroid Build Coastguard Worker { {36762, 8345 }, {36761, 995926 }, 13 },
48*6236dae4SAndroid Build Coastguard Worker { {36761, 995926 }, {36762, 8345 }, -13 },
49*6236dae4SAndroid Build Coastguard Worker { {36761, 995926 }, {0, 0}, 36761995 },
50*6236dae4SAndroid Build Coastguard Worker { {0, 0}, {36761, 995926 }, -36761995 },
51*6236dae4SAndroid Build Coastguard Worker };
52*6236dae4SAndroid Build Coastguard Worker size_t i;
53*6236dae4SAndroid Build Coastguard Worker
54*6236dae4SAndroid Build Coastguard Worker for(i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
55*6236dae4SAndroid Build Coastguard Worker timediff_t result = Curl_timediff(tests[i].first, tests[i].second);
56*6236dae4SAndroid Build Coastguard Worker if(result != tests[i].result) {
57*6236dae4SAndroid Build Coastguard Worker printf("%ld.%06u to %ld.%06u got %d, but expected %ld\n",
58*6236dae4SAndroid Build Coastguard Worker (long)tests[i].first.tv_sec,
59*6236dae4SAndroid Build Coastguard Worker tests[i].first.tv_usec,
60*6236dae4SAndroid Build Coastguard Worker (long)tests[i].second.tv_sec,
61*6236dae4SAndroid Build Coastguard Worker tests[i].second.tv_usec,
62*6236dae4SAndroid Build Coastguard Worker (int)result,
63*6236dae4SAndroid Build Coastguard Worker (long)tests[i].result);
64*6236dae4SAndroid Build Coastguard Worker fail("unexpected result!");
65*6236dae4SAndroid Build Coastguard Worker }
66*6236dae4SAndroid Build Coastguard Worker }
67*6236dae4SAndroid Build Coastguard Worker }
68*6236dae4SAndroid Build Coastguard Worker UNITTEST_STOP
69