package buffers_test import ( "sourcecode.social/reiver/go-buffers" "testing" ) func TestLimitedBuffer_oneByteAtATime(t *testing.T) { tests := []struct{ Data string Expected string Limit int }{ { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "", Limit: 0, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "0", Limit: 1, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "01", Limit: 2, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "012", Limit: 3, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "0123", Limit: 4, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "01234", Limit: 5, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "012345", Limit: 6, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "0123456", Limit: 7, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "01234567", Limit: 8, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "012345678", Limit: 9, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "0123456789", Limit: 10, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "0123456789"+"A", Limit: 11, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "0123456789"+"AB", Limit: 12, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "0123456789"+"ABC", Limit: 13, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "0123456789"+"ABCD", Limit: 14, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "0123456789"+"ABCDE", Limit: 15, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXY", Limit: 35, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ", Limit: 36, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"a", Limit: 37, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"ab", Limit: 38, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abc", Limit: 39, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvw", Limit: 59, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwx", Limit: 60, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxy", Limit: 61, }, { Data: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Expected: "0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz", Limit: 62, }, } loop: for testNumber, test := range tests { { var buffer buffers.Buffer = buffers.LimitedBuffer(test.Limit) var i int for i=0; i