File: timetag_test.cpp

package info (click to toggle)
supercollider 1%3A3.10.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 45,496 kB
  • sloc: cpp: 283,513; lisp: 74,040; ansic: 72,252; sh: 23,016; python: 7,175; makefile: 1,087; perl: 766; java: 677; yacc: 314; lex: 175; ruby: 136; objc: 65; xml: 15
file content (64 lines) | stat: -rw-r--r-- 1,467 bytes parent folder | download | duplicates (3)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <boost/test/unit_test.hpp>

#include "utilities/time_tag.hpp"

#include "boost/date_time/posix_time/posix_time.hpp"

using namespace nova;
using namespace boost;

BOOST_AUTO_TEST_CASE( time_tag_test_1 )
{
    {
        time_tag tt;
        BOOST_REQUIRE_EQUAL(tt.get_secs(), 0u);
        BOOST_REQUIRE_EQUAL(tt.get_fraction(), 0u);
    }

    {
        time_tag tt(100, 200);
        BOOST_REQUIRE_EQUAL(tt.get_secs(), 100u);
        BOOST_REQUIRE_EQUAL(tt.get_fraction(), 200u);
    }

    {
        time_tag t1(0, 0);
        time_tag t2(0, 1);
        time_tag t3(0, 1);

        BOOST_REQUIRE(t1 < t2);
        BOOST_REQUIRE(t1 != t2);
        BOOST_REQUIRE(t2 == t3);
    }

    {
        time_tag t1(0, 0);
        time_tag t2(1, 0);

        time_tag t3 = t1 + t2;
        BOOST_REQUIRE(t2 == t3);

        t3 += t2;
        BOOST_REQUIRE(t3 == time_tag(2, 0));
    }
}

BOOST_AUTO_TEST_CASE( time_tag_test_2 )
{
    using namespace boost::posix_time;
    time_tag first = time_tag::from_ptime(ptime(microsec_clock::universal_time()));
    time_tag next = time_tag::from_ptime(ptime(microsec_clock::universal_time()));

    BOOST_REQUIRE(first <= next);
}

BOOST_AUTO_TEST_CASE( time_tag_test_3 )
{
    using namespace boost::posix_time;
    time_tag now = time_tag::from_ptime(ptime(microsec_clock::universal_time()));

    ptime pnow = now.to_ptime();

/*     std::cout << now.get_secs() << std::endl; */
/*     std::cout << pnow << std::endl; */
}