| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package ctx_value
- import (
- "testing"
- . "gitp78su.ipnodns.ru/svi/kern/v4/lev0/core_spec"
- "gitp78su.ipnodns.ru/svi/kern/v4/lev0/defs"
- )
- type tester struct {
- t *testing.T
- val ICtxValue
- createdAt ITime
- }
- func TestCtxValue(t *testing.T) {
- sf := &tester{
- t: t,
- }
- sf.new()
- }
- // Создаёт значение локального контекста.
- func (sf *tester) new() {
- sf.t.Log("new")
- sf.val = NewCtxValue(defs.Txt("test_key"), 5, "test_value")
- if sf.val == nil {
- sf.t.Fatalf("new(): val==nil")
- }
- if val := sf.val.Val().(int); val != 5 {
- sf.t.Fatalf("new(): val(%v)!=5", val)
- }
- create := sf.val.CreateAt()
- if create.Time().Get() == "" {
- sf.t.Fatalf("new(): create is empty")
- }
- sf.createdAt = create
- if comment := sf.val.Comment(); comment.Get() != "test_value" {
- sf.t.Fatalf("new(): comment(%v)!='test_value'", comment)
- }
- if key := sf.val.Key(); key.Get() != "test_key" {
- sf.t.Fatalf("new(): key(%v)!='test_key'", key)
- }
- if update := sf.val.UpdateAt(); update.Time().Get() != "" {
- sf.t.Fatalf("new(): update not empty")
- }
- }
|