-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_steg_data_test.go
50 lines (41 loc) · 1.44 KB
/
get_steg_data_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
package main
import (
"fmt"
"testing"
)
func TestUnsteg(t *testing.T) {
// The tests to run
var tests = []struct {
name string
containerFile string
expectedResult bool
hideFile string
}{
{"NoParameterData", "", false, ""},
{"ContainerFileDoesNotExist", "", false, ""},
{"ContainerFileEmpty", "EmptyFile", false, ""},
{"NoHiddenFileData", "1000ByteContainerFile", false, ""},
{"ValidFile", "Waves.mp3", true, "HideFile.txt"},
}
// Set up test data
CreateEmptyFile("EmptyFile")
CreateFile("1000ByteContainerFile", 1000)
// Write name of function being tested to test results file
LogResult("Unsteg")
// Run the tests
for _, currentTest := range tests {
testname := fmt.Sprintf("%s", currentTest.name)
t.Run(testname, func(t *testing.T) {
result, hideFile := Unsteg(currentTest.containerFile)
if result != currentTest.expectedResult || hideFile != currentTest.hideFile {
LogResult(currentTest.name + " - " + fmt.Sprintf("Input: %s Got: %t %s Expected: %t %s", currentTest.containerFile, result, hideFile, currentTest.expectedResult, currentTest.hideFile) + " - FAIL")
} else {
LogResult(currentTest.name + " - " + fmt.Sprintf("Input: %s Got: %t %s Expected: %t %s", currentTest.containerFile, result, hideFile, currentTest.expectedResult, currentTest.hideFile) + " - PASS")
}
})
}
// Clean up test data
DeleteFile("EmptyFile")
DeleteFile("1000ByteContainerFile")
DeleteFile("HideFile.txt")
}