MCPcopy
hub / github.com/dreadl0ck/netcap / TestReassemblyObjectCaptureInfo

Function TestReassemblyObjectCaptureInfo

reassembly/tcpassembly_test.go:1899–1950  ·  view source on GitHub ↗

Make sure reassemblyObject.CaptureInfo conforms to ScatterGather interface.

(t *testing.T)

Source from the content-addressed store, hash-verified

1897
1898// Make sure reassemblyObject.CaptureInfo conforms to ScatterGather interface.
1899func TestReassemblyObjectCaptureInfo(t *testing.T) {
1900 // Add 20 bytes worth of data into a reassemblyObject.
1901 all := []byteContainer{
1902 &page{
1903 bytes: bytes.Repeat([]byte("1"), 10),
1904 ac: testCustomContext(1203),
1905 },
1906 &livePacket{
1907 bytes: bytes.Repeat([]byte("1"), 10),
1908 ac: testCustomContext(794598214),
1909 },
1910 }
1911 ro := &reassemblyObject{all: all}
1912
1913 testCases := []struct {
1914 offset int
1915 expected testCustomContext
1916 }{
1917 {
1918 offset: -1,
1919 },
1920 {
1921 offset: 0,
1922 expected: testCustomContext(1203),
1923 },
1924 {
1925 offset: 5,
1926 expected: testCustomContext(1203),
1927 },
1928 {
1929 offset: 10,
1930 expected: testCustomContext(794598214),
1931 },
1932 {
1933 offset: 19,
1934 expected: testCustomContext(794598214),
1935 },
1936 {
1937 offset: 20,
1938 },
1939 {
1940 offset: 1000000,
1941 },
1942 }
1943 for _, c := range testCases {
1944 expected := c.expected.GetCaptureInfo()
1945 ci := ro.CaptureInfo(c.offset)
1946 if !reflect.DeepEqual(expected, ci) {
1947 t.Errorf("test CaptureInfo(%d):\nwant: %v\n got: %v\n", c.offset, expected, ci)
1948 }
1949 }
1950}

Callers

nothing calls this directly

Calls 3

CaptureInfoMethod · 0.95
testCustomContextTypeAlias · 0.85
GetCaptureInfoMethod · 0.65

Tested by

no test coverage detected