MCPcopy
hub / github.com/bettercap/bettercap / TestRedirectionStructCopy

Function TestRedirectionStructCopy

firewall/redirection_test.go:203–230  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

201}
202
203func TestRedirectionStructCopy(t *testing.T) {
204 // Test that Redirection can be safely copied
205 original := NewRedirection("eth0", "tcp", 80, "192.168.1.1", 8080)
206 original.SrcAddress = "10.0.0.1"
207
208 // Create a copy
209 copy := *original
210
211 // Modify the copy
212 copy.Interface = "wlan0"
213 copy.SrcPort = 443
214
215 // Verify original is unchanged
216 if original.Interface != "eth0" {
217 t.Error("original Interface was modified")
218 }
219 if original.SrcPort != 80 {
220 t.Error("original SrcPort was modified")
221 }
222
223 // Verify copy has new values
224 if copy.Interface != "wlan0" {
225 t.Error("copy Interface was not set correctly")
226 }
227 if copy.SrcPort != 443 {
228 t.Error("copy SrcPort was not set correctly")
229 }
230}
231
232func BenchmarkNewRedirection(b *testing.B) {
233 for i := 0; i < b.N; i++ {

Callers

nothing calls this directly

Calls 2

NewRedirectionFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected