-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.cpp
More file actions
37 lines (31 loc) · 740 Bytes
/
Copy pathtests.cpp
File metadata and controls
37 lines (31 loc) · 740 Bytes
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
//
#include <iostream>
// Created by kerne on 2/13/2019.
//
#include "catch.hpp"
#include <string>
#include <sstream>
using std::cin;
using std::string;
using std::stoi;
int stringCalc(string c) {
int result;
if (c == "") return 0;
else if (c.length() < 3) return std::stoi(c);
else {
string o(1,c[0]);
string t(1,c[2]);
int x = stoi(o);
int y = stoi(t);
result = x + y;
}
return result;
}
TEST_CASE( "Strings are computed", "[stringCalc]" ) {
REQUIRE( stringCalc("") == 0 );
REQUIRE( stringCalc("1") == 1);
REQUIRE( stringCalc("16") == 16);
REQUIRE( stringCalc("23") == 23);
REQUIRE( stringCalc("1,2") == 3);
REQUIRE( stringCalc("1\n5") == 6);
}