MCPcopy
hub / github.com/mum4k/termdash / TestSetCell

Function TestSetCell

private/canvas/buffer/buffer_test.go:313–487  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

311}
312
313func TestSetCell(t *testing.T) {
314 size := image.Point{3, 3}
315 tests := []struct {
316 desc string
317 buffer Buffer
318 point image.Point
319 r rune
320 opts []cell.Option
321 wantCells int
322 want Buffer
323 wantErr bool
324 }{
325 {
326 desc: "point falls before the buffer",
327 buffer: mustNew(size),
328 point: image.Point{-1, -1},
329 r: 'A',
330 wantErr: true,
331 },
332 {
333 desc: "point falls after the buffer",
334 buffer: mustNew(size),
335 point: image.Point{3, 3},
336 r: 'A',
337 wantErr: true,
338 },
339 {
340 desc: "point falls on cell with partial rune",
341 buffer: func() Buffer {
342 b := mustNew(size)
343 b[0][0].Rune = '世'
344 return b
345 }(),
346 point: image.Point{1, 0},
347 r: 'A',
348 wantErr: true,
349 },
350 {
351 desc: "point falls on cell with full-width rune and overwrites with half-width rune",
352 buffer: func() Buffer {
353 b := mustNew(size)
354 b[0][0].Rune = '世'
355 return b
356 }(),
357 point: image.Point{0, 0},
358 r: 'A',
359 wantCells: 1,
360 want: func() Buffer {
361 b := mustNew(size)
362 b[0][0].Rune = 'A'
363 return b
364 }(),
365 },
366 {
367 desc: "point falls on cell with full-width rune and overwrites with full-width rune",
368 buffer: func() Buffer {
369 b := mustNew(size)
370 b[0][0].Rune = '世'

Callers

nothing calls this directly

Calls 6

FgColorFunction · 0.92
BgColorFunction · 0.92
NewOptionsFunction · 0.92
RunMethod · 0.80
mustNewFunction · 0.70
SetCellMethod · 0.65

Tested by

no test coverage detected