jsonstr.Compile() -> jsonstr.CompileStrings()

master
Charles Iliya Krempeaux 2023-09-27 12:28:37 +09:00
parent 160f1f1769
commit cca9187c97
3 changed files with 24 additions and 24 deletions

View File

@ -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:"[]",

View File

@ -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: `["😈","🙂🙁","","٠١٢٣۴۵۶٧٨٩"]`,
},
}

View File

@ -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", "۵"),
},
}