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