summaryrefslogtreecommitdiff
path: root/cpp/test/IceUtil/time/Client.cpp
blob: f4e7ba1f83317c346c6ba8044081754c9e5bfcc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

#include <IceUtil/Time.h>
#include <TestHelper.h>

using namespace IceUtil;
using namespace std;

class Client : public Test::TestHelper
{
public:

    virtual void run(int argc, char* argv[]);
};

void
Client::run(int argc, char*[])
{
    if(argc > 1)
    {
        throw std::invalid_argument("too many arguments");
    }

    cerr << "testing Time::toString... " << flush;
    Time t = Time::now();
    test(!t.toDateTime().empty());
    // Add forty years to current time to ensure toDateTime works for large values
    // see https://github.com/zeroc-ice/ice/issues/1283
    t = Time::seconds(t.toSeconds() + (40 * 365 * 24 * 3600));
    test(!t.toDateTime().empty());
    cerr << "ok" << endl;
}

DEFINE_TEST(Client);