MCPcopy Create free account
hub / github.com/apache/trafficserver / testParseRange

Function testParseRange

plugins/slice/slice_test.cc:85–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85std::string
86testParseRange()
87{
88 std::ostringstream oss;
89
90 std::vector<std::string> const teststrings = {
91 "bytes=0-1023",
92 "bytes=1-1024",
93 "bytes=11-11",
94 "bytes=1-" // 2nd byte to end
95 ,
96 "Range: bytes=-13" // final 13 bytes
97 ,
98 "bytes=3-17" // ,23-29" // open
99 ,
100 "bytes=3 -17 " //,18-29" // adjacent
101 ,
102 "bytes=3- 17" //, 11-29" // overlapping
103 ,
104 "bytes=3 - 11" //,13-17 , 23-29" // unsorted triplet
105 ,
106 "bytes=3-11 " //,13-17, 23-29" // unsorted triplet
107 ,
108 "bytes=0-0" //,-1" // first and last bytes
109 ,
110 "bytes=-20" // last 20 bytes of file
111
112 ,
113 "bytes=-60-50" // invalid fully negative
114 ,
115 "bytes=17-13" // degenerate
116 ,
117 "bytes 0-1023/146515" // this should be rejected (Content-range)
118 }; // invalid
119
120 std::vector<Range> const exps = {
121 Range{0, 1023 + 1 },
122 Range{1, 1024 + 1 },
123 Range{11, 11 + 1 },
124 Range{1, Range::maxval},
125 Range{-1, -1 },
126 Range{3, 17 + 1 },
127 Range{3, 17 + 1 },
128 Range{3, 17 + 1 },
129 Range{3, 11 + 1 },
130 Range{3, 11 + 1 },
131 Range{0, 1 },
132 Range{-20, 0 },
133 Range{-1, -1 },
134 Range{-1, -1 },
135 Range{-1, -1 }
136 };
137
138 std::vector<bool> const expsres = {true, true, true, true, false, true, true, true, true, true, true, true, false, false, false};
139
140 assert(exps.size() == teststrings.size());
141
142 std::vector<Range> gots;

Callers

nothing calls this directly

Calls 6

sizeMethod · 0.45
reserveMethod · 0.45
push_backMethod · 0.45
fromStringClosedMethod · 0.45
c_strMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected