67 lines
1.8 KiB
C
67 lines
1.8 KiB
C
#include "config.h"
|
|
#include "db.h"
|
|
#include "iCal.h"
|
|
#include "llist.h"
|
|
#include "planner.h" // for subject and event structs
|
|
#include "ui.h"
|
|
#include <assert.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
|
|
int test() {
|
|
|
|
time_t now = time(NULL);
|
|
|
|
// create new task named LinAlg with priority 3, created now with deadline in
|
|
// 5 days sp is currently unused spare var
|
|
Task *t1 = newTask("LinAlg", now, now + days(5), 3, 0);
|
|
assert(t1 != NULL);
|
|
|
|
// Stack Allocated vars only for local use!
|
|
Task *t2 = newTask("Phys", now, now + days(2), 7, 0);
|
|
assert(t2 != NULL);
|
|
Task *t3 = newTask("Analysis", now, now + days(10), 5, 0);
|
|
assert(t3 != NULL);
|
|
Task *t4 = newTask("TM1", now, now + days(1), 9, 0);
|
|
assert(t4 != NULL);
|
|
|
|
printf("%s\n", ctime(&now));
|
|
|
|
// new llist test
|
|
llist *list1 = llistNew(t1, cmpTaskN);
|
|
llistAppend(list1, t2);
|
|
llistAppend(list1, t3);
|
|
llistAppend(list1, t4);
|
|
|
|
// gnerate plan from task list in time
|
|
struct tm *lc = localtime(&now);
|
|
lc->tm_hour += 9; // add available time;
|
|
time_t maxTime = mktime(lc); // create timestamp
|
|
llist *l1 = genPlan(list1, maxTime); // return inked list of event;
|
|
llistFreeE(l1);
|
|
|
|
// print test tasks
|
|
// printTask(t1);
|
|
|
|
// find in list & modify
|
|
// Task search = {.name = "Analysis"}; // key to look for. cmpTask only
|
|
// compares
|
|
// // names using strcmp(a.name, b.name)
|
|
// llist *found = llistGet(list1, &search);
|
|
// if (found != NULL) {
|
|
// ((Task *)found->data)->deadline = time(NULL) + days(10);
|
|
// // ((Task *)found->data)->priority Names= 9;
|
|
// // printTask(found->data);
|
|
// } else {
|
|
// printf("%s not in List!\n", search.name);
|
|
// }
|
|
//
|
|
// char *t1Str = taskToStr(t1);
|
|
// // printf("%s\n", t1Str);
|
|
// llistFreeT(list1);
|
|
// free(t1Str);
|
|
//
|
|
return 0;
|
|
}
|