MCPcopy
hub / github.com/gofiber/fiber / Test_App_GetBytes

Function Test_App_GetBytes

app_test.go:1404–1429  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1402}
1403
1404func Test_App_GetBytes(t *testing.T) {
1405 t.Parallel()
1406
1407 b := []byte("fiber")
1408 appMutable := New()
1409 same := appMutable.GetBytes(b)
1410 if unsafe.SliceData(same) != unsafe.SliceData(b) {
1411 t.Error("expected original slice when immutable is disabled")
1412 }
1413
1414 alias := make([]byte, 10)
1415 copy(alias, b)
1416 sub := alias[:5]
1417 appImmutable := New(Config{Immutable: true})
1418 copied := appImmutable.GetBytes(sub)
1419 if unsafe.SliceData(copied) == unsafe.SliceData(sub) {
1420 t.Error("expected a copy for aliased slice when immutable is enabled")
1421 }
1422
1423 full := make([]byte, 5)
1424 copy(full, b)
1425 detached := appImmutable.GetBytes(full)
1426 if unsafe.SliceData(detached) == unsafe.SliceData(full) {
1427 t.Error("expected a copy even when cap==len")
1428 }
1429}
1430
1431func Test_App_Shutdown(t *testing.T) {
1432 t.Parallel()

Callers

nothing calls this directly

Calls 3

GetBytesMethod · 0.80
NewFunction · 0.70
ErrorMethod · 0.65

Tested by

no test coverage detected