This is an automated email from the ASF dual-hosted git repository.

alexstocks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/develop by this push:
     new ff690b5e9 test(auth): improve IsEmpty test coverage (#2956)
ff690b5e9 is described below

commit ff690b5e9a7b8e0e67e996f963c392f34f32b652
Author: CAICAII <[email protected]>
AuthorDate: Tue Jul 29 19:43:54 2025 +0800

    test(auth): improve IsEmpty test coverage (#2956)
    
    Add more comprehensive test cases for IsEmpty function, covering 
whitespace, empty, normal, tab, mixed, leading/trailing/both-end whitespace 
scenarios.
---
 filter/auth/sign_util_test.go | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/filter/auth/sign_util_test.go b/filter/auth/sign_util_test.go
index 15ba719e6..02e36853e 100644
--- a/filter/auth/sign_util_test.go
+++ b/filter/auth/sign_util_test.go
@@ -36,11 +36,24 @@ func TestIsEmpty(t *testing.T) {
                want bool
        }{
                // TODO: Add test cases.
-               {"test1", args{s: "   ", allowSpace: false}, true},
-               {"test2", args{s: "   ", allowSpace: true}, false},
-               {"test3", args{s: "hello,dubbo", allowSpace: false}, false},
-               {"test4", args{s: "hello,dubbo", allowSpace: true}, false},
-               {"test5", args{s: "", allowSpace: true}, true},
+               {"whitespace_false", args{s: "   ", allowSpace: false}, true},
+               {"whitespace_true", args{s: "   ", allowSpace: true}, false},
+               {"normal_false", args{s: "hello,dubbo", allowSpace: false}, 
false},
+               {"normal_true", args{s: "hello,dubbo", allowSpace: true}, 
false},
+               {"empty_true", args{s: "", allowSpace: true}, true},
+               {"empty_false", args{s: "", allowSpace: false}, true},
+               {"single_space_false", args{s: " ", allowSpace: false}, true},
+               {"single_space_true", args{s: " ", allowSpace: true}, false},
+               {"single_tab_false", args{s: "\t", allowSpace: false}, true},
+               {"single_tab_true", args{s: "\t", allowSpace: true}, false},
+               {"mixed_whitespace_false", args{s: " \t\n\r ", allowSpace: 
false}, true},
+               {"mixed_whitespace_true", args{s: " \t\n\r ", allowSpace: 
true}, false},
+               {"leading_space_false", args{s: "  hello", allowSpace: false}, 
false},
+               {"leading_space_true", args{s: "  hello", allowSpace: true}, 
false},
+               {"trailing_space_false", args{s: "hello  ", allowSpace: false}, 
false},
+               {"trailing_space_true", args{s: "hello  ", allowSpace: true}, 
false},
+               {"both_ends_false", args{s: "  hello  ", allowSpace: false}, 
false},
+               {"both_ends_true", args{s: "  hello  ", allowSpace: true}, 
false},
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {

Reply via email to