From patchwork Tue Apr 13 00:27:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 11894 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 4F7DEBD1F6 for ; Tue, 13 Apr 2021 00:28:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4456F68801; Tue, 13 Apr 2021 02:28:27 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="N2yg3PJw"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0591A605AE for ; Tue, 13 Apr 2021 02:28:25 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9AC0E89A for ; Tue, 13 Apr 2021 02:28:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1618273704; bh=qu3oIzQMbwzG76RUg2C67O0n2Jy4ndzX3o2fefY6PAQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=N2yg3PJwuLyHbMbFy7P6Tn82zl2nkPWbW/ogXA28g+t/IL5aSPSMgIIOU+iXgtVCN vqVHq9BuTuFSvOzQPL6Gui1bqiyt62Vuau3DSmRMqTHuE5eeeZVi7pCiaU3GiojH0s rjD2o+OZVbVj4PsKm22rNR+uW6AkbzKXOXtWhhcE= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 13 Apr 2021 03:27:30 +0300 Message-Id: <20210413002731.25653-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.28.1 In-Reply-To: <20210413002731.25653-1-laurent.pinchart@ideasonboard.com> References: <20210413002731.25653-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] test: span: Add tests for begin() and rend() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Verify that the begin() and rend() iterators (and their const version) reference the correct values. The end() and rbegin() iterators can't be tested the same way as they're not dereferenceable. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- test/span.cpp | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/test/span.cpp b/test/span.cpp index d60b769c9877..ca037c8f02fa 100644 --- a/test/span.cpp +++ b/test/span.cpp @@ -72,12 +72,24 @@ protected: staticSpan = Span{ v }; - staticSpan.begin(); - staticSpan.cbegin(); + if (*staticSpan.begin() != 1) { + std::cout << "Span::begin() failed" << std::endl; + return TestFail; + } + if (*staticSpan.cbegin() != 1) { + std::cout << "Span::cbegin() failed" << std::endl; + return TestFail; + } staticSpan.end(); staticSpan.cend(); - staticSpan.rbegin(); - staticSpan.crbegin(); + if (*staticSpan.rbegin() != 4) { + std::cout << "Span::rbegin() failed" << std::endl; + return TestFail; + } + if (*staticSpan.crbegin() != 4) { + std::cout << "Span::crbegin() failed" << std::endl; + return TestFail; + } staticSpan.rend(); staticSpan.crend(); @@ -141,12 +153,24 @@ protected: dynamicSpan = Span{ a }; - dynamicSpan.begin(); - dynamicSpan.cbegin(); + if (*dynamicSpan.begin() != 1) { + std::cout << "Span::begin() failed" << std::endl; + return TestFail; + } + if (*dynamicSpan.cbegin() != 1) { + std::cout << "Span::cbegin() failed" << std::endl; + return TestFail; + } dynamicSpan.end(); dynamicSpan.cend(); - dynamicSpan.rbegin(); - dynamicSpan.crbegin(); + if (*dynamicSpan.rbegin() != 4) { + std::cout << "Span::rbegin() failed" << std::endl; + return TestFail; + } + if (*dynamicSpan.crbegin() != 4) { + std::cout << "Span::crbegin() failed" << std::endl; + return TestFail; + } dynamicSpan.rend(); dynamicSpan.crend();