| 1379 | } |
| 1380 | |
| 1381 | func 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 | |
| 1404 | func Test_App_GetBytes(t *testing.T) { |
| 1405 | t.Parallel() |