| 1 | package netasciiscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/ |
| 2 | |
| 3 | import ( |
| 4 | "bytesscip-go gomod github.com/golang/go/src go1.13 bytes/" |
| 5 | "io/ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/" |
| 6 | "stringsscip-go gomod github.com/golang/go/src go1.13 strings/" |
| 7 | "testingscip-go gomod github.com/golang/go/src go1.13 testing/" |
| 8 | "testing/iotestscip-go gomod github.com/golang/go/src go1.13 `testing/iotest`/" |
| 9 | ) |
| 10 | |
| 11 | var basicscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/basic. = map[string]string{ |
| 12 | "\r": "\r\x00", |
| 13 | "\n": "\r\n", |
| 14 | "la\nbu": "la\r\nbu", |
| 15 | "la\rbu": "la\r\x00bu", |
| 16 | "\r\r\r": "\r\x00\r\x00\r\x00", |
| 17 | "\n\n\n": "\r\n\r\n\r\n", |
| 18 | } |
| 19 | |
| 20 | func TestToscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/TestTo().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 21 | for text, netascii := range basicscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/basic. { |
| 22 | to := ToReaderscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/ToReader().(stringsscip-go gomod github.com/golang/go/src go1.13 strings/.NewReaderscip-go gomod github.com/golang/go/src go1.13 strings/NewReader().(text)) |
| 23 | n, _ := ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.ReadAllscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/ReadAll().(to) |
| 24 | if !bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Equalscip-go gomod github.com/golang/go/src go1.13 bytes/Equal().(n, []byte(netascii)) { |
| 25 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("%q to netascii: %q != %q", text, n, netascii) |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | func TestFromscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/TestFrom().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 31 | for text, netascii := range basicscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/basic. { |
| 32 | r := bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.NewReaderscip-go gomod github.com/golang/go/src go1.13 bytes/NewReader().([]byte(netascii)) |
| 33 | b := &bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#{} |
| 34 | from := FromWriterscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/FromWriter().(b) |
| 35 | r.WriteToscip-go gomod github.com/golang/go/src go1.13 bytes/Reader#WriteTo().(from) |
| 36 | n, _ := ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.ReadAllscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/ReadAll().(b) |
| 37 | if string(n) != text { |
| 38 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("%q from netascii: %q != %q", netascii, n, text) |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | const textscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/text. = ` |
| 44 | Therefore, the sequence "CR LF" must be treated as a single "new |
| 45 | line" character and used whenever their combined action is |
| 46 | intended; the sequence "CR NUL" must be used where a carriage |
| 47 | return alone is actually desired; and the CR character must be |
| 48 | avoided in other contexts. This rule gives assurance to systems |
| 49 | which must decide whether to perform a "new line" function or a |
| 50 | multiple-backspace that the TELNET stream contains a character |
| 51 | following a CR that will allow a rational decision. |
| 52 | (in the default ASCII mode), to preserve the symmetry of the |
| 53 | NVT model. Even though it may be known in some situations |
| 54 | (e.g., with remote echo and suppress go ahead options in |
| 55 | effect) that characters are not being sent to an actual |
| 56 | printer, nonetheless, for the sake of consistency, the protocol |
| 57 | requires that a NUL be inserted following a CR not followed by |
| 58 | a LF in the data stream. The converse of this is that a NUL |
| 59 | received in the data stream after a CR (in the absence of |
| 60 | options negotiations which explicitly specify otherwise) should |
| 61 | be stripped out prior to applying the NVT to local character |
| 62 | set mapping. |
| 63 | ` |
| 64 | |
| 65 | func TestWriteReadscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/TestWriteRead().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 66 | var one bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer# |
| 67 | to := ToReaderscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/ToReader().(stringsscip-go gomod github.com/golang/go/src go1.13 strings/.NewReaderscip-go gomod github.com/golang/go/src go1.13 strings/NewReader().(textscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/text.)) |
| 68 | one.ReadFromscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#ReadFrom().(to) |
| 69 | two := &bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#{} |
| 70 | from := FromWriterscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/FromWriter().(two) |
| 71 | one.WriteToscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#WriteTo().(from) |
| 72 | text2, _ := ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.ReadAllscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/ReadAll().(two) |
| 73 | if textscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/text. != string(text2) { |
| 74 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("text mismatch \n%x \n%x", textscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/text., text2) |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | func TestOneBytescip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/TestOneByte().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 79 | var one bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer# |
| 80 | to := iotestscip-go gomod github.com/golang/go/src go1.13 `testing/iotest`/.OneByteReaderscip-go gomod github.com/golang/go/src go1.13 `testing/iotest`/OneByteReader().(ToReaderscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/ToReader().(stringsscip-go gomod github.com/golang/go/src go1.13 strings/.NewReaderscip-go gomod github.com/golang/go/src go1.13 strings/NewReader().(textscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/text.))) |
| 81 | one.ReadFromscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#ReadFrom().(to) |
| 82 | two := &bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#{} |
| 83 | from := FromWriterscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/FromWriter().(two) |
| 84 | one.WriteToscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer#WriteTo().(from) |
| 85 | text2, _ := ioutilscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/.ReadAllscip-go gomod github.com/golang/go/src go1.13 `io/ioutil`/ReadAll().(two) |
| 86 | if textscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/text. != string(text2) { |
| 87 | t.Errorfscip-go gomod github.com/golang/go/src go1.13 testing/common#Errorf().("text mismatch \n%x \n%x", textscip-go gomod github.com/pin/tftp/v3 . `github.com/pin/tftp/v3/netascii`/text., text2) |
| 88 | } |
| 89 | } |