From 5d79a69bd8d8869e55caf6b722ba098559f3413c Mon Sep 17 00:00:00 2001 From: Ivan Matmati Date: Wed, 4 Dec 2024 15:32:30 +0100 Subject: [PATCH] TEST: add dashcase test --- misc/stringutil_test.go | 84 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/misc/stringutil_test.go b/misc/stringutil_test.go index 8ab0d1f9..d182d666 100644 --- a/misc/stringutil_test.go +++ b/misc/stringutil_test.go @@ -57,3 +57,87 @@ func TestSanitizeFilename(t *testing.T) { }) } } + +func TestDashCase(t *testing.T) { + tests := []struct { + fieldname string + dashcase string + }{ + {fieldname: "Abortonclose", dashcase: "abortonclose"}, + {fieldname: "AcceptInvalidHTTPRequest", dashcase: "accept-invalid-http-request"}, + {fieldname: "AcceptInvalidHTTPResponse", dashcase: "accept-invalid-http-response"}, + {fieldname: "Backlog", dashcase: "backlog"}, + {fieldname: "Check", dashcase: "check"}, + {fieldname: "Checkcache", dashcase: "checkcache"}, + {fieldname: "Client", dashcase: "client"}, + {fieldname: "ClientFin", dashcase: "client-fin"}, + {fieldname: "Clitcpka", dashcase: "clitcpka"}, + {fieldname: "ClitcpkaCnt", dashcase: "clitcpka-cnt"}, + {fieldname: "Connect", dashcase: "connect"}, + {fieldname: "Contstats", dashcase: "contstats"}, + {fieldname: "DisableH2Upgrade", dashcase: "disable-h2-upgrade"}, + {fieldname: "Disabled", dashcase: "disabled"}, + {fieldname: "DontlogNormal", dashcase: "dontlog-normal"}, + {fieldname: "Dontlognull", dashcase: "dontlognull"}, + {fieldname: "DynamicCookieKey", dashcase: "dynamic-cookie-key"}, + {fieldname: "Enabled", dashcase: "enabled"}, + {fieldname: "ErrorLogFormat", dashcase: "error-log-format"}, + {fieldname: "Fullconn", dashcase: "fullconn"}, + {fieldname: "H1CaseAdjustBogusClient", dashcase: "h1-case-adjust-bogus-client"}, + {fieldname: "H1CaseAdjustBogusServer", dashcase: "h1-case-adjust-bogus-server"}, + {fieldname: "HashBalanceFactor", dashcase: "hash-balance-factor"}, + {fieldname: "HTTPBufferRequest", dashcase: "http-buffer-request"}, + {fieldname: "HTTPIgnoreProbes", dashcase: "http-ignore-probes"}, + {fieldname: "HTTPKeepAlive", dashcase: "http-keep-alive"}, + {fieldname: "HTTPNoDelay", dashcase: "http-no-delay"}, + {fieldname: "HTTPPretendKeepalive", dashcase: "http-pretend-keepalive"}, + {fieldname: "HTTPRequest", dashcase: "http-request"}, + {fieldname: "HTTPUseHtx", dashcase: "http-use-htx"}, + {fieldname: "HTTPUseProxyHeader", dashcase: "http-use-proxy-header"}, + {fieldname: "HttpchkParams", dashcase: "httpchk-params"}, + {fieldname: "Httpslog", dashcase: "httpslog"}, + {fieldname: "IdleCloseOnResponse", dashcase: "idle-close-on-response"}, + {fieldname: "IndependentStreams", dashcase: "independent-streams"}, + {fieldname: "LogFormat", dashcase: "log-format"}, + {fieldname: "LogFormatSd", dashcase: "log-format-sd"}, + {fieldname: "LogHealthChecks", dashcase: "log-health-checks"}, + {fieldname: "LogSeparateErrors", dashcase: "log-separate-errors"}, + {fieldname: "LogTag", dashcase: "log-tag"}, + {fieldname: "MaxKeepAliveQueue", dashcase: "max-keep-alive-queue"}, + {fieldname: "Maxconn", dashcase: "maxconn"}, + {fieldname: "Mode", dashcase: "mode"}, + {fieldname: "MysqlCheckParams", dashcase: "mysql-check-params"}, + {fieldname: "Name", dashcase: "name"}, + {fieldname: "Nolinger", dashcase: "nolinger"}, + {fieldname: "Persist", dashcase: "persist"}, + {fieldname: "PgsqlCheckParams", dashcase: "pgsql-check-params"}, + {fieldname: "PreferLastServer", dashcase: "prefer-last-server"}, + {fieldname: "Queue", dashcase: "queue"}, + {fieldname: "Retries", dashcase: "retries"}, + {fieldname: "RetryOn", dashcase: "retry-on"}, + {fieldname: "Server", dashcase: "server"}, + {fieldname: "ServerFin", dashcase: "server-fin"}, + {fieldname: "SmtpchkParams", dashcase: "smtpchk-params"}, + {fieldname: "SocketStats", dashcase: "socket-stats"}, + {fieldname: "SpliceAuto", dashcase: "splice-auto"}, + {fieldname: "SpliceRequest", dashcase: "splice-request"}, + {fieldname: "SpliceResponse", dashcase: "splice-response"}, + {fieldname: "Srvtcpka", dashcase: "srvtcpka"}, + {fieldname: "SrvtcpkaCnt", dashcase: "srvtcpka-cnt"}, + {fieldname: "Tarpit", dashcase: "tarpit"}, + {fieldname: "TCPSmartAccept", dashcase: "tcp-smart-accept"}, + {fieldname: "TCPSmartConnect", dashcase: "tcp-smart-connect"}, + {fieldname: "Tcpka", dashcase: "tcpka"}, + {fieldname: "Tcplog", dashcase: "tcplog"}, + {fieldname: "Transparent", dashcase: "transparent"}, + {fieldname: "Tunnel", dashcase: "tunnel"}, + } + + for _, tt := range tests { + t.Run(tt.fieldname, func(t *testing.T) { + if got := DashCase(tt.fieldname); got != tt.dashcase { + t.Errorf("DashCase(%s) = %s, want %s", tt.fieldname, got, tt.dashcase) + } + }) + } +}