blob: b61ec488e27e3ceeaa31ead8e57487f0f5c396fc [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Chandler Carruth57b08b02019-01-19 10:56:40 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Howard Hinnant3e519522010-05-11 19:42:16 +00006//
7//===----------------------------------------------------------------------===//
8
9// <string>
10
11// size_type length() const;
12
13#include <string>
14#include <cassert>
15
Marshall Clowe34f6f62013-11-26 20:58:02 +000016#include "min_allocator.h"
Howard Hinnanteec72182013-06-28 16:59:19 +000017
Howard Hinnant3e519522010-05-11 19:42:16 +000018template <class S>
19void
20test(const S& s)
21{
22 assert(s.length() == s.size());
23}
24
JF Bastien2df59c52019-02-04 20:31:13 +000025int main(int, char**)
Howard Hinnant3e519522010-05-11 19:42:16 +000026{
Howard Hinnanteec72182013-06-28 16:59:19 +000027 {
Howard Hinnant3e519522010-05-11 19:42:16 +000028 typedef std::string S;
29 test(S());
30 test(S("123"));
31 test(S("12345678901234567890123456789012345678901234567890"));
Howard Hinnanteec72182013-06-28 16:59:19 +000032 }
Eric Fiselierf2f2a632016-06-14 21:31:42 +000033#if TEST_STD_VER >= 11
Howard Hinnanteec72182013-06-28 16:59:19 +000034 {
35 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
36 test(S());
37 test(S("123"));
38 test(S("12345678901234567890123456789012345678901234567890"));
39 }
40#endif
JF Bastien2df59c52019-02-04 20:31:13 +000041
42 return 0;
Howard Hinnant3e519522010-05-11 19:42:16 +000043}