github.com/alimy/mir/v4@v4.1.0/internal/utils/utils_test.go (about)

     1  // Copyright 2022 Michael Li <alimy@gility.net>. All rights reserved.
     2  // Use of this source code is governed by Apache License 2.0 that
     3  // can be found in the LICENSE file.
     4  
     5  package utils
     6  
     7  import "testing"
     8  
     9  func TestUpperFirst(t *testing.T) {
    10  	for input, expect := range map[string]string{
    11  		"Options": "Options",
    12  		"get":     "Get",
    13  		"post":    "Post",
    14  		"head":    "Head",
    15  	} {
    16  		if res := UpperFirst(input); res != expect {
    17  			t.Errorf("expect %s but got %s", expect, res)
    18  		}
    19  	}
    20  }
    21  
    22  func TestQuoteJoin(t *testing.T) {
    23  	for _, data := range []struct {
    24  		input  []string
    25  		expect string
    26  	}{
    27  		{
    28  			input:  []string{"GET", "POST", "HEAD"},
    29  			expect: `"GET","POST","HEAD"`,
    30  		},
    31  		{
    32  			input:  []string{"Options", "Trace", "Post"},
    33  			expect: `"Options","Trace","Post"`,
    34  		},
    35  	} {
    36  		if res := QuoteJoin(data.input, ","); res != data.expect {
    37  			t.Errorf("expect (%s) but got (%s)", data.expect, res)
    38  		}
    39  	}
    40  }