ctx_value_test.go 998 B

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