File: map_test.go

package info (click to toggle)
golang-github-komkom-toml 0.0~git20211215.3c8ee9d-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 3,072 kB
  • sloc: makefile: 2
file content (38 lines) | stat: -rw-r--r-- 550 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package toml

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestMap(t *testing.T) {

	m := Map{m: make(map[string]Map)}

	key := []string{`1`, `2`, `3`}

	ok := m.Set(key, BasicVar)
	assert.True(t, ok)

	r, ok := m.Get(key)
	assert.True(t, ok)

	assert.Equal(t, BasicVar, r.Var)
	assert.Nil(t, r.m)

	ok = m.Set(key[:2], BasicVar)
	assert.False(t, ok)

	ok = m.Clear(key[:2])
	assert.True(t, ok)

	_, ok = m.Get(key)
	assert.False(t, ok)

	ok = m.Set(key, BasicVar)
	assert.True(t, ok)

	_, ok = m.Get(key)
	assert.True(t, ok)
}