From 70408b5c7dad73654fcc855745f09298892f0b9f Mon Sep 17 00:00:00 2001
From: MachulinaDV <MachulinaDV>
Date: Tue, 25 Apr 2023 01:04:19 +0300
Subject: [PATCH] code: tests

---
 histogram_internal.h |  7 ++++++
 unittest.cbp         | 40 +++++++++++++++++++++++++++++++
 unittest.cpp         | 56 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 103 insertions(+)
 create mode 100644 histogram_internal.h
 create mode 100644 unittest.cbp
 create mode 100644 unittest.cpp

diff --git a/histogram_internal.h b/histogram_internal.h
new file mode 100644
index 0000000..6e1e667
--- /dev/null
+++ b/histogram_internal.h
@@ -0,0 +1,7 @@
+#ifndef HISTOGRAM_INTERNAL_H_INCLUDED
+#define HISTOGRAM_INTERNAL_H_INCLUDED
+
+#include <vector>
+
+bool find_minmax(const std::vector<double>& A, double& min, double& max);
+#endif // HISTOGRAM_INTERNAL_H_INCLUDED
diff --git a/unittest.cbp b/unittest.cbp
new file mode 100644
index 0000000..379d0a2
--- /dev/null
+++ b/unittest.cbp
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<CodeBlocks_project_file>
+	<FileVersion major="1" minor="6" />
+	<Project>
+		<Option title="unittest" />
+		<Option pch_mode="2" />
+		<Option compiler="gcc" />
+		<Build>
+			<Target title="Debug">
+				<Option output="bin/Debug/unittest" prefix_auto="1" extension_auto="1" />
+				<Option object_output="obj/Debug/" />
+				<Option type="1" />
+				<Option compiler="gcc" />
+				<Compiler>
+					<Add option="-g" />
+				</Compiler>
+			</Target>
+			<Target title="Release">
+				<Option output="bin/Release/unittest" prefix_auto="1" extension_auto="1" />
+				<Option object_output="obj/Release/" />
+				<Option type="1" />
+				<Option compiler="gcc" />
+				<Compiler>
+					<Add option="-O2" />
+				</Compiler>
+				<Linker>
+					<Add option="-s" />
+				</Linker>
+			</Target>
+		</Build>
+		<Compiler>
+			<Add option="-Wall" />
+		</Compiler>
+		<Unit filename="doctest.h" />
+		<Unit filename="histogram.cpp" />
+		<Unit filename="histogram_internal.h" />
+		<Unit filename="unittest.cpp" />
+		<Extensions />
+	</Project>
+</CodeBlocks_project_file>
diff --git a/unittest.cpp b/unittest.cpp
new file mode 100644
index 0000000..c8f4db1
--- /dev/null
+++ b/unittest.cpp
@@ -0,0 +1,56 @@
+#define DOCTEST_CONFIG_NO_MULTITHREADING
+#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
+#include "doctest.h"
+#include "histogram_internal.h"
+
+TEST_CASE("emptyA") {
+    std::vector<double>A{1,2,3,4};
+    double min = 0;
+    double max = 0;
+    find_minmax(A, min, max);
+    CHECK(A.size() !=0 );
+}
+
+TEST_CASE("min")
+{
+    std::vector<double>A{1,2,3,4};
+    double min = 0;
+    double max = 0;
+    find_minmax(A, min, max);
+    CHECK(min == 1);
+}
+
+TEST_CASE("max")
+{
+    std::vector<double>A{1,2,3,4};
+    double min = 0;
+    double max = 0;
+    find_minmax(A, min, max);
+    CHECK(max == 4);
+}
+
+
+TEST_CASE("1A") {
+    std::vector<double>A{1,2,3,4};
+    double min = 0;
+    double max = 0;
+    find_minmax(A, min, max);
+    CHECK(A.size() !=1 );
+}
+
+
+TEST_CASE("same"){
+    std::vector<double>A{1,1,1,1};
+    std::vector<double>B{1,1,1,1};
+    double min = 0;
+    double max = 0;
+    find_minmax(A, min, max);
+    CHECK(A == B);
+}
+
+TEST_CASE("emt"){
+        std::vector<double>A{};
+        double min = 0;
+        double max = 0;
+        CHECK(find_minmax(A,min,max)==false);
+}