mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-12-15 19:31:45 +03:00
812b43a4b3
Merge in DNS/adguard-home from 2238-fix-static-analisys-warnings to master Squashed commit of the following: commit 721ca6fa1cbfdfe9d414e6ed52fec4a64653fb52 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Oct 30 15:48:10 2020 +0300 * all: fix all staticcheck SA warnings Closes #2238.
35 lines
728 B
Go
35 lines
728 B
Go
package querylog
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestJSON(t *testing.T) {
|
|
s := `
|
|
{"keystr":"val","obj":{"keybool":true,"keyint":123456}}
|
|
`
|
|
k, v, jtype := readJSON(&s)
|
|
assert.Equal(t, jtype, int32(jsonTStr))
|
|
assert.Equal(t, "keystr", k)
|
|
assert.Equal(t, "val", v)
|
|
|
|
k, _, jtype = readJSON(&s)
|
|
assert.Equal(t, jtype, int32(jsonTObj))
|
|
assert.Equal(t, "obj", k)
|
|
|
|
k, v, jtype = readJSON(&s)
|
|
assert.Equal(t, jtype, int32(jsonTBool))
|
|
assert.Equal(t, "keybool", k)
|
|
assert.Equal(t, "true", v)
|
|
|
|
k, v, jtype = readJSON(&s)
|
|
assert.Equal(t, jtype, int32(jsonTNum))
|
|
assert.Equal(t, "keyint", k)
|
|
assert.Equal(t, "123456", v)
|
|
|
|
_, _, jtype = readJSON(&s)
|
|
assert.True(t, jtype == jsonTErr)
|
|
}
|