Skip to content

Commit

Permalink
Merge pull request #3 from sir-gon/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sir-gon authored Sep 10, 2024
2 parents de7d288 + e9ed754 commit 89d37db
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 23 deletions.
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ lint/yaml:
lint: lint/markdown lint/yaml test/styling test/static

test/static:
cppcheck --enable=all \
--inconclusive \
--library=posix \
cppcheck \
--enable=all \
--std=c++17 \
--library=posix \
--inconclusive \
--inline-suppr \
--error-exitcode=13 \
--suppress=missingIncludeSystem \
--showtime=summary \
src/

test/styling:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include <iostream>
#include <vector>

#pragma once

namespace hackerrank::warmup {
int simpleArraySum(std::vector<int> ar);
int simpleArraySum(const std::vector<int>& ar);
}
20 changes: 4 additions & 16 deletions src/lib/exercises/src/hackerrank/warmup/simple_array_sum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,14 @@
* @link Problem definition [[docs/hackerrank/warmup/simple_array_sum.md]]
*/

#include <iostream>
#include <cmath>
#include <numeric>
#include <vector>

using namespace std;

string ltrim(const string &);
string rtrim(const string &);
vector<string> split(const string &);


namespace hackerrank::warmup {

int simpleArraySum(std::vector<int> ar) {
int accum = 0;

for(const int i : ar) {
accum += i;
}
return accum;
int simpleArraySum(const std::vector<int>& ar) {
const int INIT_VALUE = 0;
return std::accumulate(ar.begin(), ar.end(), INIT_VALUE);
}

}
1 change: 1 addition & 0 deletions src/tests/unit/lib/foo.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <exercises/foo.hpp>

// cppcheck-suppress unusedFunction
TEST_CASE("adding numbers work", "[foo]")
{
CHECK(foo::add(0, 0) == 0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#include <catch2/catch_test_macros.hpp>

#include <exercises/hackerrank/warmup/simple_array_sum.hpp>
#include <iostream>
#include <vector>

#include <filesystem>
#include <fstream>
#include <nlohmann/json.hpp>

using json = nlohmann::json;

TEST_CASE("simpleArraySum", "[warmup]")
Expand Down

0 comments on commit 89d37db

Please sign in to comment.