MCPcopy Create free account
hub / github.com/boostorg/beast / testSwap

Method testSwap

test/beast/core/static_string.cpp:1246–1301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1244 }
1245
1246 void
1247 testSwap()
1248 {
1249 {
1250 static_string<3> s1("123");
1251 static_string<3> s2("XYZ");
1252 swap(s1, s2);
1253 BEAST_EXPECT(s1 == "XYZ");
1254 BEAST_EXPECT(*s1.end() == 0);
1255 BEAST_EXPECT(s2 == "123");
1256 BEAST_EXPECT(*s2.end() == 0);
1257 static_string<3> s3("UV");
1258 swap(s2, s3);
1259 BEAST_EXPECT(s2 == "UV");
1260 BEAST_EXPECT(*s2.end() == 0);
1261 BEAST_EXPECT(s3 == "123");
1262 BEAST_EXPECT(*s3.end() == 0);
1263 }
1264 {
1265 static_string<5> s1("123");
1266 static_string<7> s2("XYZ");
1267 swap(s1, s2);
1268 BEAST_EXPECT(s1 == "XYZ");
1269 BEAST_EXPECT(*s1.end() == 0);
1270 BEAST_EXPECT(s2 == "123");
1271 BEAST_EXPECT(*s2.end() == 0);
1272 static_string<3> s3("UV");
1273 swap(s2, s3);
1274 BEAST_EXPECT(s2 == "UV");
1275 BEAST_EXPECT(*s2.end() == 0);
1276 BEAST_EXPECT(s3 == "123");
1277 BEAST_EXPECT(*s3.end() == 0);
1278 try
1279 {
1280 static_string<5> s4("12345");
1281 static_string<3> s5("XYZ");
1282 swap(s4, s5);
1283 fail("", __FILE__, __LINE__);
1284 }
1285 catch(std::length_error const&)
1286 {
1287 pass();
1288 }
1289 try
1290 {
1291 static_string<3> s4("XYZ");
1292 static_string<5> s5("12345");
1293 swap(s4, s5);
1294 fail("", __FILE__, __LINE__);
1295 }
1296 catch(std::length_error const&)
1297 {
1298 pass();
1299 }
1300 }
1301 }
1302
1303 void

Callers

nothing calls this directly

Calls 3

swapFunction · 0.50
failFunction · 0.50
endMethod · 0.45

Tested by

no test coverage detected