jsonstr.Compile() -> jsonstr.CompileStrings()
parent
160f1f1769
commit
cca9187c97
|
@ -23,7 +23,7 @@ type Strings struct {
|
|||
value string
|
||||
}
|
||||
|
||||
func Compile(a ...string) Strings {
|
||||
func CompileStrings(a ...string) Strings {
|
||||
if len(a) <= 0 {
|
||||
return Strings{
|
||||
value:"[]",
|
||||
|
|
|
@ -22,34 +22,34 @@ func TestString_MarshalJSON(t *testing.T) {
|
|||
|
||||
|
||||
{
|
||||
Strings: jsonstr.Compile("apple"),
|
||||
Strings: jsonstr.CompileStrings("apple"),
|
||||
Expected: `["apple"]`,
|
||||
},
|
||||
{
|
||||
Strings: jsonstr.Compile("apple", "banana"),
|
||||
Strings: jsonstr.CompileStrings("apple", "banana"),
|
||||
Expected: `["apple","banana"]`,
|
||||
},
|
||||
{
|
||||
Strings: jsonstr.Compile("apple", "banana", "cherry"),
|
||||
Strings: jsonstr.CompileStrings("apple", "banana", "cherry"),
|
||||
Expected: `["apple","banana","cherry"]`,
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Strings: jsonstr.Compile("😈"),
|
||||
Strings: jsonstr.CompileStrings("😈"),
|
||||
Expected: `["😈"]`,
|
||||
},
|
||||
{
|
||||
Strings: jsonstr.Compile("😈", "🙂🙁"),
|
||||
Strings: jsonstr.CompileStrings("😈", "🙂🙁"),
|
||||
Expected: `["😈","🙂🙁"]`,
|
||||
},
|
||||
{
|
||||
Strings: jsonstr.Compile("😈", "🙂🙁", ""),
|
||||
Strings: jsonstr.CompileStrings("😈", "🙂🙁", ""),
|
||||
Expected: `["😈","🙂🙁",""]`,
|
||||
},
|
||||
{
|
||||
Strings: jsonstr.Compile("😈", "🙂🙁", "", "٠١٢٣۴۵۶٧٨٩"),
|
||||
Strings: jsonstr.CompileStrings("😈", "🙂🙁", "", "٠١٢٣۴۵۶٧٨٩"),
|
||||
Expected: `["😈","🙂🙁","","٠١٢٣۴۵۶٧٨٩"]`,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -30,42 +30,42 @@ func TestString_UnmarshalJSON(t *testing.T) {
|
|||
|
||||
|
||||
{
|
||||
JSON: `["apple"]`,
|
||||
Expected: jsonstr.Compile("apple"),
|
||||
JSON: `["apple"]`,
|
||||
Expected: jsonstr.CompileStrings("apple"),
|
||||
},
|
||||
{
|
||||
JSON: `["apple","banana"]`,
|
||||
Expected: jsonstr.Compile("apple","banana"),
|
||||
JSON: `["apple","banana"]`,
|
||||
Expected: jsonstr.CompileStrings("apple","banana"),
|
||||
},
|
||||
{
|
||||
JSON: `["apple","banana","cherry"]`,
|
||||
Expected: jsonstr.Compile("apple","banana","cherry"),
|
||||
JSON: `["apple","banana","cherry"]`,
|
||||
Expected: jsonstr.CompileStrings("apple","banana","cherry"),
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
JSON: `["😈"]`,
|
||||
Expected: jsonstr.Compile("😈"),
|
||||
JSON: `["😈"]`,
|
||||
Expected: jsonstr.CompileStrings("😈"),
|
||||
},
|
||||
{
|
||||
JSON: `["😈","🙂🙁"]`,
|
||||
Expected: jsonstr.Compile("😈","🙂🙁"),
|
||||
JSON: `["😈","🙂🙁"]`,
|
||||
Expected: jsonstr.CompileStrings("😈","🙂🙁"),
|
||||
},
|
||||
{
|
||||
JSON: `["😈","🙂🙁",""]`,
|
||||
Expected: jsonstr.Compile("😈","🙂🙁",""),
|
||||
JSON: `["😈","🙂🙁",""]`,
|
||||
Expected: jsonstr.CompileStrings("😈","🙂🙁",""),
|
||||
},
|
||||
{
|
||||
JSON: `["😈","🙂🙁","","٠١٢٣۴۵۶٧٨٩"]`,
|
||||
Expected: jsonstr.Compile("😈","🙂🙁","","٠١٢٣۴۵۶٧٨٩"),
|
||||
JSON: `["😈","🙂🙁","","٠١٢٣۴۵۶٧٨٩"]`,
|
||||
Expected: jsonstr.CompileStrings("😈","🙂🙁","","٠١٢٣۴۵۶٧٨٩"),
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
JSON: `["1","two", "THREE", "iv", "۵"]`,
|
||||
Expected: jsonstr.Compile("1","two", "THREE", "iv", "۵"),
|
||||
JSON: `["1","two", "THREE", "iv", "۵"]`,
|
||||
Expected: jsonstr.CompileStrings("1","two", "THREE", "iv", "۵"),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue