From 5932556e7051690e262a5ee39263b7905bf1ba20 Mon Sep 17 00:00:00 2001 From: xengineering Date: Tue, 4 Jul 2023 12:30:02 +0200 Subject: Remove element_buffer The new RX concept will not need such an element buffer and uses the xml.Decoder.DecodeElement() function instead. --- xmpp/element_buffer_test.go | 55 --------------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 xmpp/element_buffer_test.go (limited to 'xmpp/element_buffer_test.go') diff --git a/xmpp/element_buffer_test.go b/xmpp/element_buffer_test.go deleted file mode 100644 index af3d5c2..0000000 --- a/xmpp/element_buffer_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package xmpp - -import ( - "encoding/xml" - "strings" - "testing" -) - -// bufTest is a struct containing a test point for the -// xengineering.eu/limox/xmpp.elementBuffer. It contains a test XML string -// which has to be exactly one XML element and an array of indentation levels -// which have to be checked after each token which is parsed. -type bufTest struct { - xml string - levels []int -} - -func TestElementBuffer(t *testing.T) { - tests := []bufTest{ - bufTest{``, []int{1, 0}}, - bufTest{``, []int{1, 0}}, - bufTest{`testing`, []int{1, 2, 2, 1, 0}}, - bufTest{`testing`, []int{1, 1, 2, 2, 1, 0}}, - bufTest{`testing`, []int{0, 1, 2, 2, 1, 0}}, - } - - for _, v := range tests { - r := strings.NewReader(v.xml) - d := xml.NewDecoder(r) - b := newElementBuffer() - - i := 0 - - for { - token, err := d.Token() - if err != nil { - if i != len(v.levels) { - t.Fatalf("Stopped parsing at unexpected index due to error `%v`!\n", err) - } - break - } - - err = b.add(token) - if err != nil { - t.Fatalf("add(token) failed with error `%v`!\n", err) - } - - if b.level != v.levels[i] { - t.Fatalf("Indent level of xmpp.elementBuffer %d does not match value given by test data %d!\n", b.level, v.levels[i]) - } - - i += 1 - } - } -} -- cgit v1.2.3-70-g09d2