aboutsummaryrefslogtreecommitdiff
path: root/src/tests.odin
blob: 024e68c943186852d088a8d7ec4d04abdc84210f (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
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
65
66
67
68
69
70
71
72
73
74
75
76
package main

import "core:fmt"

// TODO: Make tests for all sorts of things using asserts

test :: proc() {
	
	fmt.println("\n--- TESTING PRINT STUFFS ---")
	
	test_delta: Delta = {1, 1, 1}
	fmt.println(toString(test_delta))
	test_delta = {0, 0, 0}
	fmt.println(toString(test_delta))
	test_delta = {0, 12, 2}
	fmt.printf("I've been waiting for %s! That's a long time!\n", toString(test_delta))
	
	start: Moment = {45, 8, 20, 4, 2023}
	end: Moment = add(start, test_delta)
	block: Timeblock = {start, end, 0, ""}
	fmt.println(toString(block))
	
	fmt.println(clockprint(block))
	
	
	
	fmt.println("\n--- TESTING WINDING ---")
	
	test_moment: Moment = {45, 8, 30, 12, 2023}
	fmt.println(toString(test_moment))
	test_delta = {30, 1, 2}
	fmt.printf("Winding forward by %s\n", toString(test_delta))
	wind(&test_moment, 30, 1, 2)
	fmt.println(toString(test_moment))
	
	
	
	fmt.println("\n--- TESTING OPERATIONS ---")
	
	fmt.printf("So far test_moment, holds: %s.\n", toString(test_moment))
	fmt.printf("Using add(), that is:      %s ephemerally,\n", toString(add(test_moment, test_delta)))
	fmt.printf("but test_moment, is still: %s.\n", toString(test_moment))
	fmt.printf("Using sub(), that is:      %s ephemerally,\n", toString(sub(test_moment, test_delta)))
	fmt.printf("but test_moment, is still: %s.\n", toString(test_moment))
	
	
	
	fmt.println("\n--- TESTING DELTA & SORTABLE ---")
	
	fmt.printf("The sortable() version of %s is %i.\n", toString(test_moment), sortable(test_moment))
	fmt.printf("The sortable() version of %s is %i.\n", toString(test_delta), sortable(test_delta))
	
	fmt.printf("The diff() between %s and %s is %s.\n",
				toString(test_moment),
				toString(add(test_moment, test_delta)), 
				toString(diff(test_moment, add(test_moment, test_delta))))
	
	fmt.println("\n--- TESTING WORKDAY & LUNCH ---")
	workday: = new_workday({10, 22, 4, 5, 2023},
	                       {00, 08, 5, 5, 2023},
	                       {00, 05, 6, 5, 2023},
	                       {30, 21, 5, 5, 2023})
	//lunch(&workday, {00, 16, 5, 5, 2023}, {00, 17, 5, 5, 2023})
	lunch(&workday, {00, 12, 5, 5, 2023}, {45, 22, 5, 5, 2023})
	//lunch(&workday, {00, 12, 5, 5, 2023}, {30, 12, 5, 5, 2023})
	//lunch(&workday, {30, 16, 5, 5, 2023}, {30, 17, 5, 5, 2023})
	//lunch(&workday, {30, 19, 5, 5, 2023}, {30, 22, 5, 5, 2023})
	for each_block, i in workday.blocks {
		fmt.printf("Block %2i: %s $f: %i%% %s\n", i+1, toString(each_block), int((each_block.value-1)*100), each_block.reason)
	}
	
	//for i: int=1; i < 14; i += 1  {
	//	fmt.println(days_in(i, 2023))
	//}
	fmt.println("")
}