File: convsui_test.go

package info (click to toggle)
termshark 2.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 1,800 kB
  • sloc: sh: 98; makefile: 9
file content (56 lines) | stat: -rw-r--r-- 1,181 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2019-2021 Graham Clark. All rights reserved.  Use of this source
// code is governed by the MIT license that can be found in the LICENSE
// file.

// Package ui contains user-interface functions and helpers for termshark.
package ui

import (
	"fmt"
	"strings"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestScan1(t *testing.T) {
	line := `127.0.0.1:47416            <-> 127.0.0.1:9191                   0         0   43549   9951808   43549   9951808     4.160565000         9.4522`

	var (
		addra      string
		addrb      string
		framesto   int
		bytesto    int
		framesfrom int
		bytesfrom  int
		frames     int
		bytes      int
		start      string
		durn       string
	)

	r := strings.NewReader(line)
	n, err := fmt.Fscanf(r, "%s <-> %s %d %d %d %d %d %d %s %s",
		&addra,
		&addrb,
		&framesto,
		&bytesto,
		&framesfrom,
		&bytesfrom,
		&frames,
		&bytes,
		&start,
		&durn,
	)

	assert.NoError(t, err)
	assert.Equal(t, 10, n)
	assert.Equal(t, "4.160565000", start)
	assert.Equal(t, "127.0.0.1:9191", addrb)
}

//======================================================================
// Local Variables:
// mode: Go
// fill-column: 110
// End: