From 3e3e24a882782ef988453d6bb6f2efb45a700dd8 Mon Sep 17 00:00:00 2001 From: TekotovaVA Date: Sun, 14 May 2023 20:43:37 +0300 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BD=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- unittest/unittest.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 unittest/unittest.cpp diff --git a/unittest/unittest.cpp b/unittest/unittest.cpp new file mode 100644 index 0000000..be25bcc --- /dev/null +++ b/unittest/unittest.cpp @@ -0,0 +1,49 @@ +#define DOCTEST_CONFIG_NO_MULTITHREADING +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include "doctest.h" +#include "C:\Users\User\Desktop\cs-lab03\histogram_internal.h" +#include "C:\Users\User\Desktop\cs-lab03\svg.h" + +TEST_CASE("distinct positive numbers") { + double min = 0; + double max = 0; + find_minmax({ }, min, max); + CHECK(min == 0); + CHECK(max == 0); +} + +TEST_CASE("distinct identical numbers") { + double min = 10000; + double max = 0; + find_minmax({ 5, 5 }, min, max); + CHECK(min == 5); + CHECK(max == 5); +} + +TEST_CASE("distinct one number") { + double min = 10000; + double max = 0; + find_minmax({ 3 }, min, max); + CHECK(min == 3); + CHECK(max == 3); +} + +TEST_CASE("distinct negative numbers") { + double min = 1000; + double max = -1000; + find_minmax({ -3, -1 }, min, max); + CHECK(min == -3); + CHECK(max == -1); +} + +TEST_CASE("take percent") { + int x = 0; + pers(1, 20, x); + CHECK(x < 10); +} + +TEST_CASE("take percent") { + int x = 0; + pers(5, 10, x); + CHECK(x == 50); +}