MCPcopy Create free account
hub / github.com/foxcpp/maddy / TestParseDataSize

Function TestParseDataSize

framework/config/map_test.go:401–431  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

399}
400
401func TestParseDataSize(t *testing.T) {
402 check := func(s string, ok bool, expected int) {
403 val, err := ParseDataSize(s)
404 if err != nil && ok {
405 t.Errorf("unexpected parseDataSize('%s') fail: %v", s, err)
406 return
407 }
408 if err == nil && !ok {
409 t.Errorf("unexpected parseDataSize('%s') success, got %d", s, val)
410 return
411 }
412 if val != expected {
413 t.Errorf("parseDataSize('%s') != %d", s, expected)
414 return
415 }
416 }
417
418 check("1M", true, 1024*1024)
419 check("1K", true, 1024)
420 check("1b", true, 1)
421 check("1M 5b", true, 1024*1024+5)
422 check("1M 5K 5b", true, 1024*1024+5*1024+5)
423 check("0", true, 0)
424 check("1", false, 0)
425 check("1d", false, 0)
426 check("d", false, 0)
427 check("unrelated", false, 0)
428 check("1M5b", false, 0)
429 check("", false, 0)
430 check("-5M", false, 0)
431}
432
433func TestMap_Callback(t *testing.T) {
434 called := map[string]int{}

Callers

nothing calls this directly

Calls 1

ParseDataSizeFunction · 0.85

Tested by

no test coverage detected