diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-03 05:27:36 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-03 05:27:36 +0000 |
commit | df721dd80f5e2c6b37ce8e89fc40f50a246a1903 (patch) | |
tree | 4f194bdb2e9edcc69ef2ab0dfb4aab15ca259267 /libgo/go/log/syslog/syslog_test.go | |
parent | 7bf8bc7dd3bb151e716c3ff34c0e1158d864023d (diff) | |
download | gcc-df721dd80f5e2c6b37ce8e89fc40f50a246a1903.tar.gz |
libgo: Update to Go 1.0.3.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@192025 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/log/syslog/syslog_test.go')
-rw-r--r-- | libgo/go/log/syslog/syslog_test.go | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/libgo/go/log/syslog/syslog_test.go b/libgo/go/log/syslog/syslog_test.go index 0fd6239059a..b7579c363d3 100644 --- a/libgo/go/log/syslog/syslog_test.go +++ b/libgo/go/log/syslog/syslog_test.go @@ -98,20 +98,32 @@ func TestUDPDial(t *testing.T) { } func TestWrite(t *testing.T) { - done := make(chan string) - startServer(done) - l, err := Dial("udp", serverAddr, LOG_ERR, "syslog_test") - if err != nil { - t.Fatalf("syslog.Dial() failed: %s", err) + tests := []struct { + pri Priority + pre string + msg string + exp string + }{ + {LOG_ERR, "syslog_test", "", "<3>syslog_test: \n"}, + {LOG_ERR, "syslog_test", "write test", "<3>syslog_test: write test\n"}, + // Write should not add \n if there already is one + {LOG_ERR, "syslog_test", "write test 2\n", "<3>syslog_test: write test 2\n"}, } - msg := "write test" - _, err = io.WriteString(l, msg) - if err != nil { - t.Fatalf("WriteString() failed: %s", err) - } - expected := "<3>syslog_test: write test\n" - rcvd := <-done - if rcvd != expected { - t.Fatalf("s.Info() = '%q', but wanted '%q'", rcvd, expected) + + for _, test := range tests { + done := make(chan string) + startServer(done) + l, err := Dial("udp", serverAddr, test.pri, test.pre) + if err != nil { + t.Fatalf("syslog.Dial() failed: %s", err) + } + _, err = io.WriteString(l, test.msg) + if err != nil { + t.Fatalf("WriteString() failed: %s", err) + } + rcvd := <-done + if rcvd != test.exp { + t.Fatalf("s.Info() = '%q', but wanted '%q'", rcvd, test.exp) + } } } |