-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmutator_test.go
90 lines (68 loc) · 2.39 KB
/
mutator_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
package mutator
// import (
// "testing"
// )
// func TestSwapChars(t *testing.T) {
// m := &Mutator{}
// runes := []rune("abcdef")
// mutationType := MutationType{Length: 3}
// originalRunes := make([]rune, len(runes))
// copy(originalRunes, runes)
// result := m.swapChars(runes, mutationType)
// if len(result) != len(runes) {
// t.Errorf("Expected length %d, but got %d", len(runes), len(result))
// }
// // Check if the result runes are not in the same order
// if string(result) == string(originalRunes) {
// t.Errorf("Expected different order of runes, but got the same")
// }
// }
// func TestInsertHTML(t *testing.T) {
// m := &Mutator{}
// runes := []rune("Hello world")
// result := m.insertHTML(runes)
// if len(result) <= len(runes) {
// t.Errorf("Expected length greater than %d, but got %d", len(runes), len(result))
// }
// if string(result) == string(runes) {
// t.Errorf("Expected different runes after HTML insertion")
// }
// }
// func TestInsertFakeWord(t *testing.T) {
// m := &Mutator{}
// runes := []rune("Hello world")
// mutationType := MutationType{Length: 5}
// result := m.insertFakeWord(runes, mutationType)
// if len(result) <= len(runes) {
// t.Errorf("Expected length greater than %d, but got %d", len(runes), len(result))
// }
// if string(result) == string(runes) {
// t.Errorf("Expected different runes after fake word insertion")
// }
// }
// func TestReverseSubstring(t *testing.T) {
// m := &Mutator{}
// runes := []rune("Javier")
// mutationType := MutationType{Length: 1}
// result := m.reverseSubstring(runes, mutationType)
// if len(result) != len(runes) {
// t.Errorf("Expected length %d, but got %d", len(runes), len(result))
// }
// // Check if the substring is reversed
// reversed := m.reverseSubstring(runes, mutationType)
// if string(result) != string(reversed) {
// t.Errorf("Expected substring to be reversed. %s but got %s", string(result), string(reversed))
// }
// }
// func TestInsertRandomJSON(t *testing.T) {
// m := &Mutator{}
// runes := []rune("Hello world")
// mutationType := MutationType{Length: 3}
// result := m.insertRandomJSON(runes, mutationType.Length)
// if len(result) <= len(runes) {
// t.Errorf("Expected length greater than %d, but got %d", len(runes), len(result))
// }
// if string(result) == string(runes) {
// t.Errorf("Expected different runes after random JSON insertion")
// }
// }