-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnitTest1.cpp
55 lines (51 loc) · 975 Bytes
/
UnitTest1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "pch.h"
#include "CppUnitTest.h"
#include "../Project1/head.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTest1
{
TEST_CLASS(UnitTest1)
{
public:
TEST_METHOD(TestMethod1) //n<0
{
int arr[] = { 1,2,3,4,5 };
int n = -5;
int k;
k = getmax(arr, n);
Assert::AreEqual(k, 0);
}
TEST_METHOD(TestMethod2) // sum<arr[i]
{
int arr[] = { -2,11,-4,13,-5,-2 };
int n = 6;
int k;
k = getmax(arr, n);
Assert::AreEqual(k, 20);
}
TEST_METHOD(TestMethod3) //sum>arr[i]
{
int arr[] = { 2,11,-4,13,-5,-2 };
int n = 6;
int k;
k = getmax(arr, n);
Assert::AreEqual(k, 22);
}
TEST_METHOD(TestMethod4)
{
int arr[] = { 1,2,3,4,5 };
int n = 5;
int k;
k = getmax(arr, n);
Assert::AreEqual(k, 15);
}
TEST_METHOD(TestMethod5)
{
int arr[] = { -1,-2,-3,-4,-5 };
int n = 5;
int k;
k = getmax(arr, n);
Assert::AreEqual(k, 0);
}
};
}