From a8424bcb54c827e871950b221bd480ac6de6869b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 4 Mar 2017 08:56:37 +0100 Subject: [PATCH] Test get/getline/read/readsome configuration in std.cfg --- test/cfg/std.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 4494d81e0..6eb7bb8e2 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -3221,3 +3221,25 @@ void stdalgorithm(const std::list &ints1, const std::list &ints2) std::for_each(ints1.begin(), ints2.end(), [](int i) {}); } + + +void getline() { + // #837 + std::ifstream in("test1.txt"); + + char cBuf[10]; + // cppcheck-suppress bufferAccessOutOfBounds + in.getline(cBuf, 100); + // cppcheck-suppress bufferAccessOutOfBounds + in.read(cBuf, 100); + // cppcheck-suppress bufferAccessOutOfBounds + in.readsome(cBuf, 100); + // cppcheck-suppress bufferAccessOutOfBounds + in.get(cBuf, 100); + // cppcheck-suppress bufferAccessOutOfBounds + in.get(cBuf, 100, 'a'); + // cppcheck-suppress bufferAccessOutOfBounds + in.getline(cBuf, 100, 'a'); + + in.close(); +}