
test/std/depr/depr.c.headers/inttypes_h.pass.cpp test/std/input.output/file.streams/c.files/cinttypes.pass.cpp test/std/input.output/iostream.forward/iosfwd.pass.cpp Add test() to avoid a bunch of void-casts, although we still need a few. test/std/input.output/iostream.format/quoted.manip/quoted.pass.cpp skippingws was unused (it's unclear to me whether this was mistakenly copy-pasted from round_trip() below). test/std/localization/locale.categories/category.collate/locale.collate/types.pass.cpp test/std/localization/locale.categories/category.ctype/facet.ctype.special/types.pass.cpp test/std/localization/locale.categories/category.ctype/locale.codecvt/types_char.pass.cpp test/std/localization/locale.categories/category.ctype/locale.codecvt/types_wchar_t.pass.cpp test/std/localization/locale.categories/category.ctype/locale.ctype/types.pass.cpp test/std/localization/locale.categories/facet.numpunct/locale.numpunct/types.pass.cpp test/std/localization/locales/locale.global.templates/use_facet.pass.cpp When retrieving facets, the references are unused. test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long.pass.cpp test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long.pass.cpp "std::ios_base::iostate err = ios.goodbit;" was completely unused here. test/std/localization/locale.categories/category.time/locale.time.get/time_base.pass.cpp test/std/numerics/c.math/ctgmath.pass.cpp test/std/numerics/rand/rand.device/entropy.pass.cpp test/std/numerics/rand/rand.device/eval.pass.cpp test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp test/std/thread/futures/futures.promise/dtor.pass.cpp test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp test/std/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp These variables are verifying types but are otherwise unused. test/std/strings/basic.string/string.capacity/reserve.pass.cpp old_cap was unused (it's unclear to me whether it was intended to be used). test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp These tests contained unused characters. llvm-svn: 286847
129 lines
2.2 KiB
C++
129 lines
2.2 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
// Source Licenses. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// <string>
|
|
|
|
// void reserve(size_type res_arg=0);
|
|
|
|
#include <string>
|
|
#include <stdexcept>
|
|
#include <cassert>
|
|
|
|
#include "test_macros.h"
|
|
#include "min_allocator.h"
|
|
|
|
template <class S>
|
|
void
|
|
test(S s)
|
|
{
|
|
typename S::size_type old_cap = s.capacity();
|
|
S s0 = s;
|
|
s.reserve();
|
|
LIBCPP_ASSERT(s.__invariants());
|
|
assert(s == s0);
|
|
assert(s.capacity() <= old_cap);
|
|
assert(s.capacity() >= s.size());
|
|
}
|
|
|
|
template <class S>
|
|
void
|
|
test(S s, typename S::size_type res_arg)
|
|
{
|
|
typename S::size_type old_cap = s.capacity();
|
|
((void)old_cap); // Prevent unused warning
|
|
S s0 = s;
|
|
if (res_arg <= s.max_size())
|
|
{
|
|
s.reserve(res_arg);
|
|
assert(s == s0);
|
|
assert(s.capacity() >= res_arg);
|
|
assert(s.capacity() >= s.size());
|
|
}
|
|
#ifndef TEST_HAS_NO_EXCEPTIONS
|
|
else
|
|
{
|
|
try
|
|
{
|
|
s.reserve(res_arg);
|
|
assert(false);
|
|
}
|
|
catch (std::length_error&)
|
|
{
|
|
assert(res_arg > s.max_size());
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
int main()
|
|
{
|
|
{
|
|
typedef std::string S;
|
|
{
|
|
S s;
|
|
test(s);
|
|
|
|
s.assign(10, 'a');
|
|
s.erase(5);
|
|
test(s);
|
|
|
|
s.assign(100, 'a');
|
|
s.erase(50);
|
|
test(s);
|
|
}
|
|
{
|
|
S s;
|
|
test(s, 5);
|
|
test(s, 10);
|
|
test(s, 50);
|
|
}
|
|
{
|
|
S s(100, 'a');
|
|
s.erase(50);
|
|
test(s, 5);
|
|
test(s, 10);
|
|
test(s, 50);
|
|
test(s, 100);
|
|
test(s, S::npos);
|
|
}
|
|
}
|
|
#if TEST_STD_VER >= 11
|
|
{
|
|
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
|
{
|
|
S s;
|
|
test(s);
|
|
|
|
s.assign(10, 'a');
|
|
s.erase(5);
|
|
test(s);
|
|
|
|
s.assign(100, 'a');
|
|
s.erase(50);
|
|
test(s);
|
|
}
|
|
{
|
|
S s;
|
|
test(s, 5);
|
|
test(s, 10);
|
|
test(s, 50);
|
|
}
|
|
{
|
|
S s(100, 'a');
|
|
s.erase(50);
|
|
test(s, 5);
|
|
test(s, 10);
|
|
test(s, 50);
|
|
test(s, 100);
|
|
test(s, S::npos);
|
|
}
|
|
}
|
|
#endif
|
|
}
|