-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset_steg_data_test.go
62 lines (53 loc) · 2.04 KB
/
set_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
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"fmt"
"testing"
)
func TestSteg(t *testing.T) {
// The tests to run
var tests = []struct {
name string
containerFile string
hideFile string
expectedResult bool
}{
{"NoParameterData", "", "", false},
{"ContainerFileDoesNotExist", "containerFakeFile", "", false},
{"HideFileDoesNotExist", "", "hideFakeFile", false},
{"BothFilesDoNotExist", "containerFakeFile", "hideFakeFile", false},
{"ContainerFileEmpty", "EmptyFile", "100ByteHideFile", false},
{"HideFileEmpty", "1000ByteContainerFile", "EmptyFile", false},
{"HideFileTooBig", "1000ByteContainerFile", "1000ByteHideFile", false},
{"HideFileWontFit", "1000ByteContainerFile", "10ByteHideFile", false},
{"SmallHideFileFits", "10000ByteContainerFile", "10ByteHideFile", true},
{"LargeHideFileFits", "10000ByteContainerFile", "100ByteHideFile", true},
}
// Set up test data
CreateEmptyFile("EmptyFile")
CreateFile("10ByteHideFile", 10)
CreateFile("100ByteHideFile", 100)
CreateFile("1000ByteHideFile", 1000)
CreateFile("1000ByteContainerFile", 1000)
CreateFile("10000ByteContainerFile", 10000)
// Write name of function being tested to test results file
LogResult("Steg")
// Run the tests
for _, currentTest := range tests {
testname := fmt.Sprintf("%s", currentTest.name)
t.Run(testname, func(t *testing.T) {
result := Steg(currentTest.containerFile, currentTest.hideFile)
if result != currentTest.expectedResult {
LogResult(currentTest.name + " - " + fmt.Sprintf("Input: %s,%s Got: %t Expected: %t", currentTest.containerFile, currentTest.hideFile, result, currentTest.expectedResult) + " - FAIL")
} else {
LogResult(currentTest.name + " - " + fmt.Sprintf("Input: %s,%s Got: %t Expected: %t", currentTest.containerFile, currentTest.hideFile, result, currentTest.expectedResult) + " - PASS")
}
})
}
// Clean up test data
DeleteFile("EmptyFile")
DeleteFile("10ByteHideFile")
DeleteFile("100ByteHideFile")
DeleteFile("1000ByteHideFile")
DeleteFile("1000ByteContainerFile")
DeleteFile("10000ByteContainerFile")
}