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

Function Test_App_GetString

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

Source from the content-addressed store, hash-verified

1379}
1380
1381func Test_App_GetString(t *testing.T) {
1382 t.Parallel()
1383
1384 heap := string([]byte("fiber"))
1385 appMutable := New()
1386 same := appMutable.GetString(heap)
1387 if unsafe.StringData(same) != unsafe.StringData(heap) {
1388 t.Error("expected original string when immutable is disabled")
1389 }
1390
1391 appImmutable := New(Config{Immutable: true})
1392 copied := appImmutable.GetString(heap)
1393 if unsafe.StringData(copied) == unsafe.StringData(heap) {
1394 t.Error("expected a copy for heap-backed string when immutable is enabled")
1395 }
1396
1397 literal := "fiber"
1398 sameLit := appImmutable.GetString(literal)
1399 if unsafe.StringData(sameLit) != unsafe.StringData(literal) {
1400 t.Error("expected original literal when immutable is enabled")
1401 }
1402}
1403
1404func Test_App_GetBytes(t *testing.T) {
1405 t.Parallel()

Callers

nothing calls this directly

Calls 3

NewFunction · 0.70
ErrorMethod · 0.65
GetStringMethod · 0.45

Tested by

no test coverage detected