mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-26 04:10:08 +01:00
21 lines
369 B
Go
21 lines
369 B
Go
|
package stringsutil
|
|||
|
|
|||
|
import (
|
|||
|
"testing"
|
|||
|
)
|
|||
|
|
|||
|
func TestJSONString(t *testing.T) {
|
|||
|
f := func(s, resultExpected string) {
|
|||
|
t.Helper()
|
|||
|
|
|||
|
result := JSONString(s)
|
|||
|
if result != resultExpected {
|
|||
|
t.Fatalf("unexpected result\ngot\n%s\nwant\n%s", result, resultExpected)
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
f(``, `""`)
|
|||
|
f(`foo`, `"foo"`)
|
|||
|
f("\n\b\f\t\"acЫВА'\\", `"\n\b\f\t\"acЫВА\u0027\\"`)
|
|||
|
}
|