diff --git a/.gitignore b/.gitignore index ea02661..3524323 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ /NULL /ProvProg.sh /prog -/prov.txt \ No newline at end of file +/prov.txt +/unittest/.DS_Store \ No newline at end of file diff --git a/lab_3.xcodeproj/project.xcworkspace/xcuserdata/lesaminov.xcuserdatad/UserInterfaceState.xcuserstate b/lab_3.xcodeproj/project.xcworkspace/xcuserdata/lesaminov.xcuserdatad/UserInterfaceState.xcuserstate index 91dde2c..b346b5e 100644 Binary files a/lab_3.xcodeproj/project.xcworkspace/xcuserdata/lesaminov.xcuserdatad/UserInterfaceState.xcuserstate and b/lab_3.xcodeproj/project.xcworkspace/xcuserdata/lesaminov.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/unittest/histogram_internal.hpp b/unittest/histogram_internal.hpp new file mode 100644 index 0000000..caf2ee2 --- /dev/null +++ b/unittest/histogram_internal.hpp @@ -0,0 +1,14 @@ +#include +#include + +void find_minmax(std::vector &numbers, double& min, double& max) +{ + min = numbers[0]; max = numbers[0]; + for (double x : numbers) + { + if (max < x) + max = x; + if (min > x) + min = x; + } +} diff --git a/unittest/unittest.cpp b/unittest/unittest.cpp index 8f06592..f5fdc74 100644 --- a/unittest/unittest.cpp +++ b/unittest/unittest.cpp @@ -1,31 +1,30 @@ -#define DOCTEST_CONFIG_NO_MULTITHREADING #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN -#include "doctest.h" -#include "histogram_internal.h" +#include "doctest.hpp" +#include "histogram_internal.hpp" +#include TEST_CASE("distinct positive numbers") { double min = 0; double max = 0; - find_minmax({1, 2}, min, max); - CHECK(min == 1); - CHECK(max == 2); + std::vector numbers3 = {-5, -3, -4, -1, -2}; + find_minmax(numbers3, min, max); + CHECK(min == -5); + CHECK(max == -1); } TEST_CASE("vector with same elements") { double min = 0; double max = 0; - find_minmax({2,2,2}, min, max); + std::vector numbers3 = {2,2,2}; + find_minmax(numbers3, min, max); CHECK(min == 2); CHECK(max == 2); } TEST_CASE("distinct positive numbers 2") { double min = 0; double max = 0; - std::vectorv{2,1}; - CHECK(v.size() != 0); - CHECK(v.size() != 1); - find_minmax({1, 2}, min, max); - CHECK(min == 1); - CHECK(max == 2); - CHECK(min != max); + std::vector numbers3 = {-4}; + find_minmax(numbers3, min, max); + CHECK(min == -4); + CHECK(max == -4); } diff --git a/unittest/unittest.xcodeproj/project.pbxproj b/unittest/unittest.xcodeproj/project.pbxproj index a9dc519..18a9746 100644 --- a/unittest/unittest.xcodeproj/project.pbxproj +++ b/unittest/unittest.xcodeproj/project.pbxproj @@ -6,34 +6,93 @@ objectVersion = 56; objects = { +/* Begin PBXBuildFile section */ + 358EC98D2A300FF200A7EB98 /* unittest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 358EC98A2A300FF200A7EB98 /* unittest.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 358EC97E2A300FA700A7EB98 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ - 35EA3AD42A2D65C200ED69F1 /* histogram_internal.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = histogram_internal.hpp; path = ../histogram_internal.hpp; sourceTree = ""; }; - 35EA3AD52A2D65C200ED69F1 /* histogram.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = histogram.cpp; path = ../histogram.cpp; sourceTree = ""; }; - 35EA3AD62A2D65F200ED69F1 /* unittest.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = unittest.cpp; sourceTree = ""; }; - 35EA3AD72A2D65F200ED69F1 /* doctest.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = doctest.hpp; sourceTree = ""; }; + 358EC9802A300FA700A7EB98 /* unittest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = unittest; sourceTree = BUILT_PRODUCTS_DIR; }; + 358EC98A2A300FF200A7EB98 /* unittest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = unittest.cpp; sourceTree = ""; }; + 358EC98B2A300FF200A7EB98 /* doctest.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = doctest.hpp; sourceTree = ""; }; + 358EC98C2A300FF200A7EB98 /* histogram_internal.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = histogram_internal.hpp; sourceTree = ""; }; /* End PBXFileReference section */ +/* Begin PBXFrameworksBuildPhase section */ + 358EC97D2A300FA700A7EB98 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + /* Begin PBXGroup section */ - 35EA3ACD2A2D657900ED69F1 = { + 358EC9772A300FA700A7EB98 = { + isa = PBXGroup; + children = ( + 358EC98A2A300FF200A7EB98 /* unittest.cpp */, + 358EC98C2A300FF200A7EB98 /* histogram_internal.hpp */, + 358EC98B2A300FF200A7EB98 /* doctest.hpp */, + 358EC9812A300FA700A7EB98 /* Products */, + ); + sourceTree = ""; + }; + 358EC9812A300FA700A7EB98 /* Products */ = { isa = PBXGroup; children = ( - 35EA3AD62A2D65F200ED69F1 /* unittest.cpp */, - 35EA3AD42A2D65C200ED69F1 /* histogram_internal.hpp */, - 35EA3AD52A2D65C200ED69F1 /* histogram.cpp */, - 35EA3AD72A2D65F200ED69F1 /* doctest.hpp */, + 358EC9802A300FA700A7EB98 /* unittest */, ); + name = Products; sourceTree = ""; }; /* End PBXGroup section */ +/* Begin PBXNativeTarget section */ + 358EC97F2A300FA700A7EB98 /* unittest */ = { + isa = PBXNativeTarget; + buildConfigurationList = 358EC9872A300FA700A7EB98 /* Build configuration list for PBXNativeTarget "unittest" */; + buildPhases = ( + 358EC97C2A300FA700A7EB98 /* Sources */, + 358EC97D2A300FA700A7EB98 /* Frameworks */, + 358EC97E2A300FA700A7EB98 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = unittest; + productName = sd; + productReference = 358EC9802A300FA700A7EB98 /* unittest */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + /* Begin PBXProject section */ - 35EA3ACE2A2D657900ED69F1 /* Project object */ = { + 358EC9782A300FA700A7EB98 /* Project object */ = { isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = 1; LastUpgradeCheck = 1430; + TargetAttributes = { + 358EC97F2A300FA700A7EB98 = { + CreatedOnToolsVersion = 14.3.1; + }; + }; }; - buildConfigurationList = 35EA3AD12A2D657900ED69F1 /* Build configuration list for PBXProject "unittest" */; + buildConfigurationList = 358EC97B2A300FA700A7EB98 /* Build configuration list for PBXProject "unittest" */; compatibilityVersion = "Xcode 14.0"; developmentRegion = en; hasScannedForEncodings = 0; @@ -41,40 +100,175 @@ en, Base, ); - mainGroup = 35EA3ACD2A2D657900ED69F1; + mainGroup = 358EC9772A300FA700A7EB98; + productRefGroup = 358EC9812A300FA700A7EB98 /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( + 358EC97F2A300FA700A7EB98 /* unittest */, ); }; /* End PBXProject section */ +/* Begin PBXSourcesBuildPhase section */ + 358EC97C2A300FA700A7EB98 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 358EC98D2A300FF200A7EB98 /* unittest.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + /* Begin XCBuildConfiguration section */ - 35EA3AD22A2D657900ED69F1 /* Debug */ = { + 358EC9852A300FA700A7EB98 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 13.3; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 358EC9862A300FA700A7EB98 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 13.3; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + }; + name = Release; + }; + 358EC9882A300FA700A7EB98 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; }; - 35EA3AD32A2D657900ED69F1 /* Release */ = { + 358EC9892A300FA700A7EB98 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 35EA3AD12A2D657900ED69F1 /* Build configuration list for PBXProject "unittest" */ = { + 358EC97B2A300FA700A7EB98 /* Build configuration list for PBXProject "unittest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 358EC9852A300FA700A7EB98 /* Debug */, + 358EC9862A300FA700A7EB98 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 358EC9872A300FA700A7EB98 /* Build configuration list for PBXNativeTarget "unittest" */ = { isa = XCConfigurationList; buildConfigurations = ( - 35EA3AD22A2D657900ED69F1 /* Debug */, - 35EA3AD32A2D657900ED69F1 /* Release */, + 358EC9882A300FA700A7EB98 /* Debug */, + 358EC9892A300FA700A7EB98 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; - rootObject = 35EA3ACE2A2D657900ED69F1 /* Project object */; + rootObject = 358EC9782A300FA700A7EB98 /* Project object */; } diff --git a/unittest/unittest.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/unittest/unittest.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 919434a..fb0f231 100644 --- a/unittest/unittest.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/unittest/unittest.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:/Users/lesaminov/Desktop/Sem2/lab_3/sd/unittest.xcodeproj"> diff --git a/unittest/unittest.xcodeproj/project.xcworkspace/xcuserdata/lesaminov.xcuserdatad/UserInterfaceState.xcuserstate b/unittest/unittest.xcodeproj/project.xcworkspace/xcuserdata/lesaminov.xcuserdatad/UserInterfaceState.xcuserstate index 11cf15a..3298840 100644 Binary files a/unittest/unittest.xcodeproj/project.xcworkspace/xcuserdata/lesaminov.xcuserdatad/UserInterfaceState.xcuserstate and b/unittest/unittest.xcodeproj/project.xcworkspace/xcuserdata/lesaminov.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/unittest/unittest.xcodeproj/xcuserdata/lesaminov.xcuserdatad/xcschemes/xcschememanagement.plist b/unittest/unittest.xcodeproj/xcuserdata/lesaminov.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..2a989de --- /dev/null +++ b/unittest/unittest.xcodeproj/xcuserdata/lesaminov.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,19 @@ + + + + + SchemeUserState + + sd.xcscheme_^#shared#^_ + + orderHint + 0 + + unittest.xcscheme_^#shared#^_ + + orderHint + 0 + + + +