(t *testing.T)
| 40 | } |
| 41 | |
| 42 | func TestMemoryBackend(t *testing.T) { |
| 43 | backend := NewMemoryBackend(8) |
| 44 | SetBackend(backend) |
| 45 | |
| 46 | log := MustGetLogger("test") |
| 47 | |
| 48 | if nil != MemoryRecordN(backend, 0) || 0 != backend.size { |
| 49 | t.Errorf("memory level: %d", backend.size) |
| 50 | } |
| 51 | |
| 52 | // Run 13 times, the resulting vector should be [5..12] |
| 53 | for i := 0; i < 13; i++ { |
| 54 | log.Infof("%d", i) |
| 55 | } |
| 56 | |
| 57 | if 8 != backend.size { |
| 58 | t.Errorf("record length: %d", backend.size) |
| 59 | } |
| 60 | record := MemoryRecordN(backend, 0) |
| 61 | if "5" != record.Formatted(0) { |
| 62 | t.Errorf("unexpected start: %s", record.Formatted(0)) |
| 63 | } |
| 64 | for i := 0; i < 8; i++ { |
| 65 | record = MemoryRecordN(backend, i) |
| 66 | if strconv.Itoa(i+5) != record.Formatted(0) { |
| 67 | t.Errorf("unexpected record: %v", record.Formatted(0)) |
| 68 | } |
| 69 | } |
| 70 | record = MemoryRecordN(backend, 7) |
| 71 | if "12" != record.Formatted(0) { |
| 72 | t.Errorf("unexpected end: %s", record.Formatted(0)) |
| 73 | } |
| 74 | record = MemoryRecordN(backend, 8) |
| 75 | if nil != record { |
| 76 | t.Errorf("unexpected eof: %s", record.Formatted(0)) |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | func TestChannelMemoryBackend(t *testing.T) { |
| 81 | backend := NewChannelMemoryBackend(8) |
nothing calls this directly
no test coverage detected