ctx_value_test.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package ctx_value
  2. import (
  3. "testing"
  4. . "gitp78su.ipnodns.ru/svi/kern/v4/lev0/kalias"
  5. . "gitp78su.ipnodns.ru/svi/kern/v4/lev0/ktypes"
  6. )
  7. type tester struct {
  8. t *testing.T
  9. val ICtxValue
  10. create ATime
  11. }
  12. func TestCtxValue(t *testing.T) {
  13. sf := &tester{
  14. t: t,
  15. }
  16. sf.new()
  17. }
  18. // Создаёт значение локального контекста.
  19. func (sf *tester) new() {
  20. sf.t.Log("new")
  21. sf.val = NewCtxValue("test_key", 5, "test_value").Hassert("new()")
  22. if sf.val == nil {
  23. sf.t.Fatalf("new(): val==nil")
  24. }
  25. if val := sf.val.Val().(int); val != 5 {
  26. sf.t.Fatalf("new(): val(%v)!=5", val)
  27. }
  28. create := sf.val.CreateAt()
  29. if create == "" {
  30. sf.t.Fatalf("new(): create is empty")
  31. }
  32. sf.create = create
  33. if comment := sf.val.Comment(); comment != "test_value" {
  34. sf.t.Fatalf("new(): comment(%v)!='test_value'", comment)
  35. }
  36. if key := sf.val.Key(); key != "test_key" {
  37. sf.t.Fatalf("new(): key(%v)!='test_key'", key)
  38. }
  39. if update := sf.val.UpdateAt(); update != "" {
  40. sf.t.Fatalf("new(): update not empty")
  41. }
  42. }