Replace escaped strings with raw string literals (#71)

This commit is contained in:
Prashant Varanasi
2020-05-11 14:48:55 -07:00
committed by GitHub
parent fb0c2ade64
commit 1b900bfc8c
2 changed files with 8 additions and 8 deletions

View File

@@ -60,7 +60,7 @@ func TestInt32(t *testing.T) {
})
t.Run("JSON/Unmarshal/Error", func(t *testing.T) {
err := json.Unmarshal([]byte("\"40\""), &atom)
err := json.Unmarshal([]byte(`"40"`), &atom)
require.Error(t, err, "json.Unmarshal didn't error as expected.")
assertErrorJSONUnmarshalType(t, err,
"json.Unmarshal failed with unexpected error %v, want UnmarshalTypeError.", err)
@@ -98,7 +98,7 @@ func TestInt64(t *testing.T) {
})
t.Run("JSON/Unmarshal/Error", func(t *testing.T) {
err := json.Unmarshal([]byte("\"40\""), &atom)
err := json.Unmarshal([]byte(`"40"`), &atom)
require.Error(t, err, "json.Unmarshal didn't error as expected.")
assertErrorJSONUnmarshalType(t, err,
"json.Unmarshal failed with unexpected error %v, want UnmarshalTypeError.", err)
@@ -136,7 +136,7 @@ func TestUint32(t *testing.T) {
})
t.Run("JSON/Unmarshal/Error", func(t *testing.T) {
err := json.Unmarshal([]byte("\"40\""), &atom)
err := json.Unmarshal([]byte(`"40"`), &atom)
require.Error(t, err, "json.Unmarshal didn't error as expected.")
assertErrorJSONUnmarshalType(t, err,
"json.Unmarshal failed with unexpected error %v, want UnmarshalTypeError.", err)
@@ -174,7 +174,7 @@ func TestUint64(t *testing.T) {
})
t.Run("JSON/Unmarshal/Error", func(t *testing.T) {
err := json.Unmarshal([]byte("\"40\""), &atom)
err := json.Unmarshal([]byte(`"40"`), &atom)
require.Error(t, err, "json.Unmarshal didn't error as expected.")
assertErrorJSONUnmarshalType(t, err,
"json.Unmarshal failed with unexpected error %v, want UnmarshalTypeError.", err)
@@ -253,7 +253,7 @@ func TestFloat64(t *testing.T) {
})
t.Run("JSON/Unmarshal/Error", func(t *testing.T) {
err := json.Unmarshal([]byte("\"40.5\""), &atom)
err := json.Unmarshal([]byte(`"40.5"`), &atom)
require.Error(t, err, "json.Unmarshal didn't error as expected.")
assertErrorJSONUnmarshalType(t, err,
"json.Unmarshal failed with unexpected error %v, want UnmarshalTypeError.", err)
@@ -290,7 +290,7 @@ func TestDuration(t *testing.T) {
})
t.Run("JSON/Unmarshal/Error", func(t *testing.T) {
err := json.Unmarshal([]byte("\"1000000000\""), &atom)
err := json.Unmarshal([]byte(`"1000000000"`), &atom)
require.Error(t, err, "json.Unmarshal didn't error as expected.")
assertErrorJSONUnmarshalType(t, err,
"json.Unmarshal failed with unexpected error %v, want UnmarshalTypeError.", err)

View File

@@ -46,11 +46,11 @@ func TestString(t *testing.T) {
t.Run("JSON/Marshal", func(t *testing.T) {
bytes, err := json.Marshal(atom)
require.NoError(t, err, "json.Marshal errored unexpectedly.")
require.Equal(t, []byte("\"bcd\""), bytes, "json.Marshal encoded the wrong bytes.")
require.Equal(t, []byte(`"bcd"`), bytes, "json.Marshal encoded the wrong bytes.")
})
t.Run("JSON/Unmarshal", func(t *testing.T) {
err := json.Unmarshal([]byte("\"abc\""), &atom)
err := json.Unmarshal([]byte(`"abc"`), &atom)
require.NoError(t, err, "json.Unmarshal errored unexpectedly.")
require.Equal(t, "abc", atom.Load(), "json.Unmarshal didn't set the correct value.")
})