EE445M RTOS
Taken at the University of Texas Spring 2015
tk_tb.c File Reference
#include "timekit.h"
#include <stdio.h>
#include <string.h>
Include dependency graph for tk_tb.c:

Go to the source code of this file.

Functions

int main (void)
 

Function Documentation

int main ( void  )

Definition at line 7 of file tk_tb.c.

References clocktime::hours, clocktime::minutes, clocktime::mode, clocktime::ms, clocktime::seconds, TK_PRINT_MODE_HOURS_MINUTES_SECONDS_MS, TK_TIME_VALID, TKIncrementHours(), TKIncrementMinutes(), TKIncrementMS(), TKIncrementSeconds(), TKToString(), and TKValidateTime().

7  {
8 
9  clocktime t;
10  t.hours = 0;
11  t.minutes = 0;
12  t.seconds = 0;
13  t.ms = 0;
15 
16  clocktime t2;
17 
18  printf("Testing valid increment test cases\n");
19  for (int i=0; i<=24*2; i++) {
20  t2 = t;
21  TKIncrementHours(&t, i);
22  printf("%s + %2i hours = %s\n", TKToString(&t2), i, TKToString(&t));
23  if(TKValidateTime(&t) != TK_TIME_VALID) {
24  printf("Error in valid hours increment\n");
25  }
26  }
27 
28  for (int i=0; i<=60*2; i++) {
29  t2 = t;
30  TKIncrementMinutes(&t, i);
31  printf("%s + %2i minutes = %s\n", TKToString(&t2), i, TKToString(&t));
32  if(TKValidateTime(&t) != TK_TIME_VALID) {
33  printf("Error in valid minutes increment\n");
34  }
35  }
36 
37  for (int i=0; i<=60*2; i++) {
38  t2 = t;
39  TKIncrementSeconds(&t, i);
40  printf("%s + %2i seconds = %s\n", TKToString(&t2), i, TKToString(&t));
41  if(TKValidateTime(&t) != TK_TIME_VALID) {
42  printf("Error in valid seconds increment\n");
43  }
44  }
45 
46  for (int i=0; i<=100*2; i++) {
47  t2 = t;
48  TKIncrementMS(&t, i);
49  printf("%s + %2i ms = %s\n", TKToString(&t2), i, TKToString(&t));
50  if(TKValidateTime(&t) != TK_TIME_VALID) {
51  printf("Error in valid ms increment\n");
52  }
53  }
54 
55  printf("Testing valid decrement test cases\n");
56  for (int i=0; i<=24*2; i++) {
57  t2 = t;
58  TKIncrementHours(&t, -i);
59  printf("%s - %2i hours = %s\n", TKToString(&t2), i, TKToString(&t));
60  if(TKValidateTime(&t) != TK_TIME_VALID) {
61  printf("Error in valid hours decrement\n");
62  }
63  }
64 
65  for (int i=0; i<=60*2; i++) {
66  t2 = t;
67  TKIncrementMinutes(&t, -i);
68  printf("%s - %2i minutes = %s\n", TKToString(&t2), i, TKToString(&t));
69  if(TKValidateTime(&t) != TK_TIME_VALID) {
70  printf("Error in valid minutes decrement\n");
71  }
72  }
73 
74  for (int i=0; i<=60*2; i++) {
75  t2 = t;
76  TKIncrementSeconds(&t, -i);
77  printf("%s - %2i seconds = %s\n", TKToString(&t2), i, TKToString(&t));
78  if(TKValidateTime(&t) != TK_TIME_VALID) {
79  printf("Error in valid seconds decrement\n");
80  }
81  }
82 
83  for (int i=0; i<=100*2; i++) {
84  t2 = t;
85  TKIncrementMS(&t, -i);
86  printf("%s - %2i ms = %s\n", TKToString(&t2), i, TKToString(&t));
87  if(TKValidateTime(&t) != TK_TIME_VALID) {
88  printf("Error in valid ms decrement\n");
89  }
90  }
91 
92 }
#define TK_TIME_VALID
Definition: timekit.h:10
void TKIncrementHours(clocktime *tm, short hours)
Definition: timekit.c:55
char mode
Definition: timekit.h:26
short seconds
Definition: timekit.h:24
void TKIncrementMS(clocktime *tm, short ms)
Definition: timekit.c:109
char * TKToString(clocktime *tm)
Definition: timekit.c:31
short minutes
Definition: timekit.h:23
void TKIncrementSeconds(clocktime *tm, short seconds)
Definition: timekit.c:89
short TKValidateTime(clocktime *tm)
Definition: timekit.c:131
short hours
Definition: timekit.h:22
void TKIncrementMinutes(clocktime *tm, short minutes)
Definition: timekit.c:69
#define TK_PRINT_MODE_HOURS_MINUTES_SECONDS_MS
Definition: timekit.h:8
short ms
Definition: timekit.h:25

Here is the call graph for this function: