-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmodule_test.go
124 lines (111 loc) · 3.35 KB
/
module_test.go
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// -----------------------------------------------------------------------------
// ZR Library zr/[module_test.go]
// (c) balarabe@protonmail.com License: MIT
// -----------------------------------------------------------------------------
package zr
// # Library Version
// Test_mdle_VersionTime_
//
// # Constants and Variables
// Test_mdle_consts_
// Test_mdle_vars_
//
// # Global Settings
// Test_mdle_DebugMode_
// Test_mdle_SetDebugMode_
// to test all items in module.go use:
// go test --run Test_mdle_
//
// to generate a test coverage report use:
// go test -coverprofile cover.out
// go tool cover -html=cover.out
import (
"fmt"
"strconv"
"testing"
)
// -----------------------------------------------------------------------------
// # Library Version
// go test --run Test_mdle_VersionTime_
func Test_mdle_VersionTime_(t *testing.T) {
TBegin(t)
//
// VersionTime_() string
//
s := VersionTime()
TTrue(t, IsDate(s))
TTrue(t, len(VersionTime()) == 16)
//
// The format expected from VersionTime is:
// "DDDD-MM-YY hh:mm"
var yr, mt, dy, hr, mn int
yr, _ = strconv.Atoi(s[0:4])
mt, _ = strconv.Atoi(s[5:7])
dy, _ = strconv.Atoi(s[8:10])
hr, _ = strconv.Atoi(s[11:13])
mn, _ = strconv.Atoi(s[14:16])
TTrue(t, yr >= 2017 && yr <= 9999)
TTrue(t, s[4:5] == "-")
TTrue(t, mt >= 1 && mt <= 9999)
TTrue(t, s[7:8] == "-")
TTrue(t, dy >= 1 && dy <= 31)
TTrue(t, s[10:11] == " ")
TTrue(t, hr >= 0 && hr <= 59)
TTrue(t, s[10:11] == " ")
TTrue(t, mn >= 0 && hr <= 59)
} // Test_mdle_VersionTime_
// -----------------------------------------------------------------------------
// # Constants and Variables
// go test --run Test_mdle_consts_
func Test_mdle_consts_(t *testing.T) {
TBegin(t)
//
// error message constants
TEqual(t, EFailedParsing, ("Failed parsing"))
TEqual(t, EFailedReading, ("Failed reading"))
TEqual(t, EFailedWriting, ("Failed writing"))
TEqual(t, EInvalid, ("Invalid"))
TEqual(t, EInvalidArg, ("Invalid argument"))
TEqual(t, EInvalidType, ("Invalid type"))
TEqual(t, ENil, ("Value is nil"))
TEqual(t, ENoDef, ("Not defined"))
TEqual(t, ENotFound, ("Not found"))
TEqual(t, ENotHandled, ("Not handled"))
//
// other constants
TEqual(t, "\r\n", ("\r\n"))
} // Test_mdle_consts_
// go test --run Test_mdle_vars_
func Test_mdle_vars_(t *testing.T) {
TBegin(t)
//
TEqual(t, PL, (fmt.Println))
TEqual(t, VL, (VerboseLog))
} // Test_mdle_vars_
// -----------------------------------------------------------------------------
// # Global Settings
// go test --run Test_mdle_DebugMode_
func Test_mdle_DebugMode_(t *testing.T) {
TBegin(t)
//
// DebugMode() bool
//
debugMode = true
TEqual(t, DebugMode(), (true))
//
debugMode = false
TEqual(t, DebugMode(), (false))
} // Test_mdle_DebugMode_
// go test --run Test_mdle_SetDebugMode_
func Test_mdle_SetDebugMode_(t *testing.T) {
TBegin(t)
//
// SetDebugMode(val bool)
//
SetDebugMode(true)
TEqual(t, debugMode, (true))
//
SetDebugMode(false)
TEqual(t, debugMode, (false))
} // Test_mdle_SetDebugMode_
// end