github.com/sereiner/library@v0.0.0-20200518095232-1fa3e640cc5f/net/value_test.go (about) 1 package net 2 3 import "testing" 4 import "github.com/sereiner/library/ut" 5 6 func TestSign(t *testing.T) { 7 values := NewValues() 8 values.Set("b1", "v3") 9 values.Set("a1", "v1") 10 values.Set("a2", "v2") 11 a := values.Join("=", "&") 12 ut.Expect(t, a, "b1=v3&a1=v1&a2=v2") 13 values.Sort() 14 a = values.Join("=", "&") 15 ut.Expect(t, a, "a1=v1&a2=v2&b1=v3") 16 e := values.Encode() 17 ut.Expect(t, len(e), 17) 18 19 f := values.Join("=", "&", "key", "123123") 20 ut.Expect(t, f, "a1=v1&a2=v2&b1=v3&key=123123") 21 22 g := values.Join("=", "&", "123123") 23 ut.Expect(t, g, "a1=v1&a2=v2&b1=v3&123123") 24 25 h := values.Join("", "", "123123") 26 ut.Expect(t, h, "a1v1a2v2b1v3123123") 27 28 }