diff --git a/histogam.cpp b/histogam.cpp index e3fc6aa..25ee82b 100644 --- a/histogam.cpp +++ b/histogam.cpp @@ -2,9 +2,10 @@ #include <vector> #include <cmath> #include "histogam.h" +#include "histogam_internal.h" using namespace std; -static find_minmax(vector<double> numbers, double& min, double& max) { +void find_minmax(vector<double> numbers, double& min, double& max) { min = numbers[0]; for (auto i = 0; i < numbers.size(); i++) { if (numbers[i] < min) { diff --git a/histogam.h b/histogam.h index 994a9c4..af2d8ad 100644 --- a/histogam.h +++ b/histogam.h @@ -2,7 +2,6 @@ #define HISTOGAM_H_INCLUDED #include <vector> - std::vector<size_t> make_histogram(const std::vector<double>& numbers, size_t bin_count); diff --git a/histogam_internal.h b/histogam_internal.h new file mode 100644 index 0000000..58eecb6 --- /dev/null +++ b/histogam_internal.h @@ -0,0 +1,7 @@ +#ifndef HISTOGAM_INTERNAL_H_INCLUDED +#define HISTOGAM_INTERNAL_H_INCLUDED + +#include <vector> +void find_minmax(std::vector<double> numbers, double& min, double& max); + +#endif // HISTOGAM_INTERNAL_H_INCLUDED diff --git a/lab1.depend b/lab1.depend index fdaeffe..5f3bc1d 100644 --- a/lab1.depend +++ b/lab1.depend @@ -3,16 +3,17 @@ <iostream> <vector> -1682272330 source:c:\users\admin\onedrive\������� ����\lab1\main.cpp +1682273505 source:c:\users\admin\onedrive\������� ����\lab1\main.cpp <iostream> <vector> <cmath> "histogam.h" + "text.h" -1682271932 c:\users\admin\onedrive\������� ����\lab1\histogam.h +1682273839 c:\users\admin\onedrive\������� ����\lab1\histogam.h <vector> -1682272812 source:c:\users\admin\onedrive\������� ����\lab1\histogam.cpp +1682273664 source:c:\users\admin\onedrive\������� ����\lab1\histogam.cpp <iostream> <vector> <cmath> diff --git a/unittest.cbp b/unittest.cbp new file mode 100644 index 0000000..7f9621b --- /dev/null +++ b/unittest.cbp @@ -0,0 +1,38 @@ +<?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> + <Extensions> + <lib_finder disable_auto="1" /> + </Extensions> + </Project> +</CodeBlocks_project_file> diff --git a/unittest.cpp b/unittest.cpp new file mode 100644 index 0000000..87d0670 --- /dev/null +++ b/unittest.cpp @@ -0,0 +1,17 @@ +#define DOCTEST_CONFIG_NO_MULTITHREADING +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include "doctest.h" +#include "histogam_internal.h" +#include <vector> + +TEST_CASE("distinct positive numbers") { + double min = 0; + double max = 0; + std::vector<double>f{1,2}; + CHECK(f.size() != 0); + CHECK(f.size() != 1); + find_minmax(f, min, max); + CHECK(min == 1); + CHECK(max == 2); + CHECK(min != max); +} diff --git a/unittest.depend b/unittest.depend new file mode 100644 index 0000000..5760bab --- /dev/null +++ b/unittest.depend @@ -0,0 +1,64 @@ +# depslib dependency file v1.0 +1682273864 source:c:\users\admin\onedrive\������� ����\lab1\histogam.cpp + <iostream> + <vector> + <cmath> + "histogam.h" + "histogam_internal.h" + +1682273839 c:\users\admin\onedrive\������� ����\lab1\histogam.h + <vector> + +1682273796 c:\users\admin\onedrive\������� ����\lab1\histogam_internal.h + <vector> + +1682276727 source:c:\users\admin\onedrive\������� ����\lab1\unittest.cpp + "doctest.h" + "histogam_internal.h" + <vector> + +1682274769 c:\users\admin\onedrive\������� ����\lab1\doctest.h + <signal.h> + <ciso646> + <cstddef> + <ostream> + <istream> + <type_traits> + "doctest_fwd.h" + <ctime> + <cmath> + <climits> + <math.h> + <new> + <cstdio> + <cstdlib> + <cstring> + <limits> + <utility> + <fstream> + <sstream> + <iostream> + <algorithm> + <iomanip> + <vector> + <atomic> + <mutex> + <set> + <map> + <unordered_set> + <exception> + <stdexcept> + <csignal> + <cfloat> + <cctype> + <cstdint> + <string> + <sys/types.h> + <unistd.h> + <sys/sysctl.h> + <AfxWin.h> + <windows.h> + <io.h> + <sys/time.h> + <unistd.h> +