From f4069ef5969302ff57e6d7d7946b086d363f9b57 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sun, 12 Feb 2023 11:23:17 -0800 Subject: [PATCH] expand testing of shared_array::convertTo --- test/testshared.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/test/testshared.cpp b/test/testshared.cpp index 5591863..b9ebbd3 100644 --- a/test/testshared.cpp +++ b/test/testshared.cpp @@ -11,6 +11,7 @@ #include #include +#include "utilpvt.h" #include #include @@ -364,14 +365,46 @@ void testConvertTrunc() (TO)FROM(0), (TO)FROM(1), (TO)FROM(-1), - std::numeric_limits::min(), - std::numeric_limits::max(), + (TO)std::numeric_limits::min(), + (TO)std::numeric_limits::max(), }); auto conv(inp.template convertTo()); testShow()<<"Input "< "< +void testToFromString() +{ + shared_array inp({ + T(0), + T(1), + T(-1), + std::numeric_limits::min(), + std::numeric_limits::max(), + }); + shared_array expect({ + (SB()<::op(T(0))).str(), + (SB()<::op(T(1))).str(), + (SB()<::op(T(-1))).str(), + (SB()<::op(std::numeric_limits::min())).str(), + (SB()<::op(std::numeric_limits::max())).str(), + }); + + testShow()<<"Input "<()); + testArrEq(conv, expect)<<" "<<__func__<<"("< str)"; + }catch(std::exception& e){ + testFail("%s(%s -> str) throws %s", __func__, typeid(T).name(), e.what()); + } + try{ + testArrEq(expect.template convertTo(), inp)<<" "<<__func__<<"("<(); testConvertTrunc(); + testToFromString(); + testToFromString(); + testToFromString(); + testToFromString(); + testToFromString(); + testToFromString(); + testToFromString(); + testToFromString(); + testTodoBegin("problems parsing +-DBL/FLT_MIN/MAX"); + testToFromString(); + testToFromString(); + testTodoEnd(); + + testArrEq(shared_array({true, false}).convertTo(), + shared_array({"true", "false"})); + testArrEq(shared_array({1u, 2u, 0xffffffffu}).convertTo(), shared_array({1u, 2u, 0xffffffffu})); @@ -465,7 +514,7 @@ void testConvert() MAIN(testshared) { - testPlan(247); + testPlan(268); testSetup(); testEmpty(); testEmpty();