MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / TestIntToRoman

Function TestIntToRoman

conversion/inttoroman_test.go:5–23  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3import "testing"
4
5func TestIntToRoman(t *testing.T) {
6 for expected, input := range romanTestCases {
7 out, err := IntToRoman(input)
8 if err != nil {
9 t.Errorf("IntToRoman(%d) returned an error %s", input, err.Error())
10 }
11 if out != expected {
12 t.Errorf("IntToRoman(%d) = %s; want %s", input, out, expected)
13 }
14 }
15 _, err := IntToRoman(100000)
16 if err == nil {
17 t.Errorf("IntToRoman(%d) expected an error", 100000)
18 }
19 _, err = IntToRoman(0)
20 if err == nil {
21 t.Errorf("IntToRoman(%d) expected an error", 0)
22 }
23}
24
25func BenchmarkIntToRoman(b *testing.B) {
26 b.ReportAllocs()

Callers

nothing calls this directly

Calls 1

IntToRomanFunction · 0.85

Tested by

no test coverage detected