File: test_sec2clock.c

package info (click to toggle)
netproc 0.6.6-0.1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 908 kB
  • sloc: ansic: 7,876; makefile: 101; sh: 12
file content (42 lines) | stat: -rw-r--r-- 776 bytes parent folder | download
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

#include "timer.h"
#include "unity.h"

#include "cycle_counting.h"

struct test_set
{
  uint64_t ml;
  char *expected;
};

static struct test_set test[] = {
  { 0, "00:00:00" },         { 1000, "00:00:01" },
  { 53646154, "14:54:06" },  { 172800000, "48:00:00" },
  { 172810000, "48:00:10" }, { 1800752000, "500:12:32" }
};

void
test_performance ( void )
{
  counter_T cnt;

  cnt = BEGIN_TSC ();
  char *p = msec2clock ( 1800752000 );
  cnt = END_TSC ( cnt );

  printf ( "%s\ncycles = %lu\n", p, cnt );
}

#define ARRAY_SIZE( x ) ( sizeof ( x ) / sizeof ( x[0] ) )

void
test_sec2clock ( void )
{
  for ( uint32_t i = 0; i < ARRAY_SIZE ( test ); i++ )
    {
      TEST_ASSERT_EQUAL_STRING ( test[i].expected, msec2clock ( test[i].ml ) );
    }

  // test_performance();
}