From patchwork Sat Jul 30 13:20:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16876 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 98BA0C3275 for ; Sat, 30 Jul 2022 13:20:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 483E663315; Sat, 30 Jul 2022 15:20:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659187231; bh=d8H9oX+K/LFSVw26J1/OlLC7BPf3qKl0RcNRUGiml20=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=AP6kT6EPcKvAdHVAuxvO1Ce3jPN/ZeR+7ZaZnYL2ZPl55gLjXKba/84h84FWNw93q eg72KmUQF63s6BJwKppNflNEsWFvcwoblCXEiEaPDIrmbSVo6MQT3SO4hOXEX7Q+Vo y2rV/wV31nLkypVNu1I1ck2jW+KKBm9QXitCxnS4uMLLWllxETM/+YXbHkwkEDIlxS LlmZCBxNp20cjhft4ReB+LFTsmvhv+SpDt32Gd4Bk2iGkjOJtjmG9YwTjeTEbjCLuV x0/zZVhKIbULweBEZWRwmPBCad0Gm73xVgJT3S+ZH+Dmmak9/LkjlI/LRs4M0nBbrg lmkyI/FA/X3Zg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EA453603EB for ; Sat, 30 Jul 2022 15:20:29 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Ziy+e8+R"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 880BF480; Sat, 30 Jul 2022 15:20:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1659187229; bh=d8H9oX+K/LFSVw26J1/OlLC7BPf3qKl0RcNRUGiml20=; h=From:To:Cc:Subject:Date:From; b=Ziy+e8+R4ETwZTkqcVVrWayQstgglsY+jfJad/vqr7y1EbsNrZlEhb9NQd4x0mvfl 7ANbQ228ckr65fEy4zQYwHlopbMyH3VEXwVUsa5cueWYtuSOfet8QCTadwsyMkshyb +r9zknPlr5xaktphDq+hhIMCLMxmbDYn39dI0rpk= To: libcamera-devel@lists.libcamera.org Date: Sat, 30 Jul 2022 16:20:27 +0300 Message-Id: <20220730132027.20679-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] test: yaml-parser: Test YamlObject::get(const T &defaultValue) 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: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When the YamlObject::get() function override that returns a std::optional got introduced, all tests were moved to it, leaving no tests for the override that takes a default value. Reintroduce those tests. Reported-by: Florian Sylvestre Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- test/yaml-parser.cpp | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) base-commit: 69ae75b0cc211f82665b3e92fb3de64a9852b403 diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp index 9fd278664b3b..93ba88b8bcd5 100644 --- a/test/yaml-parser.cpp +++ b/test/yaml-parser.cpp @@ -160,7 +160,8 @@ protected: return TestFail; } - if (strObj.get().value_or("") != "libcamera") { + if (strObj.get().value_or("") != "libcamera" || + strObj.get("") != "libcamera") { cerr << "String object parse as wrong content" << std::endl; return TestFail; } @@ -198,17 +199,20 @@ protected: return TestFail; } - if (int32Obj.get().value_or(0) != -100) { + if (int32Obj.get().value_or(0) != -100 || + int32Obj.get(0) != -100) { cerr << "Integer object parse as wrong value" << std::endl; return TestFail; } - if (int32Obj.get().value_or("") != "-100") { + if (int32Obj.get().value_or("") != "-100" || + int32Obj.get("") != "-100") { cerr << "Integer object fail to parse as string" << std::endl; return TestFail; } - if (int32Obj.get().value_or(0.0) != -100.0) { + if (int32Obj.get().value_or(0.0) != -100.0 || + int32Obj.get(0.0) != -100.0) { cerr << "Integer object fail to parse as double" << std::endl; return TestFail; } @@ -236,22 +240,26 @@ protected: return TestFail; } - if (uint32Obj.get().value_or(0) != 100) { + if (uint32Obj.get().value_or(0) != 100 || + uint32Obj.get(0) != 100) { cerr << "Unsigned integer object fail to parse as integer" << std::endl; return TestFail; } - if (uint32Obj.get().value_or("") != "100") { + if (uint32Obj.get().value_or("") != "100" || + uint32Obj.get("") != "100") { cerr << "Unsigned integer object fail to parse as string" << std::endl; return TestFail; } - if (uint32Obj.get().value_or(0.0) != 100.0) { + if (uint32Obj.get().value_or(0.0) != 100.0 || + uint32Obj.get(0.0) != 100.0) { cerr << "Unsigned integer object fail to parse as double" << std::endl; return TestFail; } - if (uint32Obj.get().value_or(0) != 100) { + if (uint32Obj.get().value_or(0) != 100 || + uint32Obj.get(0) != 100) { cerr << "Unsigned integer object parsed as wrong value" << std::endl; return TestFail; } @@ -274,12 +282,14 @@ protected: return TestFail; } - if (doubleObj.get().value_or("") != "3.14159") { + if (doubleObj.get().value_or("") != "3.14159" || + doubleObj.get("") != "3.14159") { cerr << "Double object fail to parse as string" << std::endl; return TestFail; } - if (doubleObj.get().value_or(0.0) != 3.14159) { + if (doubleObj.get().value_or(0.0) != 3.14159 || + doubleObj.get(0.0) != 3.14159) { cerr << "Double object parse as wrong value" << std::endl; return TestFail; } @@ -332,7 +342,8 @@ protected: return TestFail; } - if (sizeObj.get().value_or(Size(0, 0)) != Size(1920, 1080)) { + if (sizeObj.get().value_or(Size(0, 0)) != Size(1920, 1080) || + sizeObj.get(Size(0, 0)) != Size(1920, 1080)) { cerr << "Size object parse as wrong value" << std::endl; return TestFail; }