ROOTPLOIT
Server: LiteSpeed
System: Linux in-mum-web1878.main-hosting.eu 5.14.0-570.21.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 11 07:22:35 EDT 2025 x86_64
User: u435929562 (435929562)
PHP: 7.4.33
Disabled: system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/go/pkg/mod/github.com/mailru/[email protected]/gen/generator_test.go
package gen

import (
	"testing"
)

func TestCamelToSnake(t *testing.T) {
	for i, test := range []struct {
		In, Out string
	}{
		{"", ""},
		{"A", "a"},
		{"SimpleExample", "simple_example"},
		{"internalField", "internal_field"},

		{"SomeHTTPStuff", "some_http_stuff"},
		{"WriteJSON", "write_json"},
		{"HTTP2Server", "http2_server"},
		{"Some_Mixed_Case", "some_mixed_case"},
		{"do_nothing", "do_nothing"},

		{"JSONHTTPRPCServer", "jsonhttprpc_server"}, // nothing can be done here without a dictionary
	} {
		got := camelToSnake(test.In)
		if got != test.Out {
			t.Errorf("[%d] camelToSnake(%s) = %s; want %s", i, test.In, got, test.Out)
		}
	}
}

func TestCamelToLowerCamel(t *testing.T) {
	for i, test := range []struct {
		In, Out string
	}{
		{"", ""},
		{"A", "a"},
		{"SimpleExample", "simpleExample"},
		{"internalField", "internalField"},

		{"SomeHTTPStuff", "someHTTPStuff"},
		{"WriteJSON", "writeJSON"},
		{"HTTP2Server", "http2Server"},

		{"JSONHTTPRPCServer", "jsonhttprpcServer"}, // nothing can be done here without a dictionary
	} {
		got := lowerFirst(test.In)
		if got != test.Out {
			t.Errorf("[%d] lowerFirst(%s) = %s; want %s", i, test.In, got, test.Out)
		}
	}
}

func TestJoinFunctionNameParts(t *testing.T) {
	for i, test := range []struct {
		keepFirst bool
		parts     []string
		out       string
	}{
		{false, []string{}, ""},
		{false, []string{"a"}, "A"},
		{false, []string{"simple", "example"}, "SimpleExample"},
		{true, []string{"first", "example"}, "firstExample"},
		{false, []string{"some", "UPPER", "case"}, "SomeUPPERCase"},
		{false, []string{"number", "123"}, "Number123"},
	} {
		got := joinFunctionNameParts(test.keepFirst, test.parts...)
		if got != test.out {
			t.Errorf("[%d] joinFunctionNameParts(%v) = %s; want %s", i, test.parts, got, test.out)
		}
	}
}

func TestFixVendorPath(t *testing.T) {
	for i, test := range []struct {
		In, Out string
	}{
		{"", ""},
		{"time", "time"},
		{"project/vendor/subpackage", "subpackage"},
	} {
		got := fixPkgPathVendoring(test.In)
		if got != test.Out {
			t.Errorf("[%d] fixPkgPathVendoring(%s) = %s; want %s", i, test.In, got, test.Out)
		}
	}

}