blob: df3cdc0f86528f626c0aa45ea2533b4d1cf69dc9 [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 Clow7fc6a552019-05-31 18:35:30 +000016#include "test_macros.h"
Marshall Clowe34f6f62013-11-26 20:58:02 +000017#include "min_allocator.h"
Howard Hinnanteec72182013-06-28 16:59:19 +000018
Howard Hinnant3e519522010-05-11 19:42:16 +000019template <class S>
20void
21test(const S& s)
22{
23 assert(s.length() == s.size());
24}
25
JF Bastien2df59c52019-02-04 20:31:13 +000026int main(int, char**)
Howard Hinnant3e519522010-05-11 19:42:16 +000027{
Howard Hinnanteec72182013-06-28 16:59:19 +000028 {
Howard Hinnant3e519522010-05-11 19:42:16 +000029 typedef std::string S;
30 test(S());
31 test(S("123"));
32 test(S("12345678901234567890123456789012345678901234567890"));
Howard Hinnanteec72182013-06-28 16:59:19 +000033 }
Eric Fiselierf2f2a632016-06-14 21:31:42 +000034#if TEST_STD_VER >= 11
Howard Hinnanteec72182013-06-28 16:59:19 +000035 {
36 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
37 test(S());
38 test(S("123"));
39 test(S("12345678901234567890123456789012345678901234567890"));
40 }
41#endif
JF Bastien2df59c52019-02-04 20:31:13 +000042
43 return 0;
Howard Hinnant3e519522010-05-11 19:42:16 +000044}