Skip to content

Commit

Permalink
New namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaweees committed Nov 23, 2024
1 parent 98fca94 commit 3eda466
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 19 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# EditorConfig is awesome: https://EditorConfig.org

# https://github.com/jokeyrhyme/standard-editorconfig

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ _deps/
Makefile
obj/
CMakeFiles/
CPackSourceConfig.cmake
CPackSourceConfig.cmake
CMakeSettings.json
CTestTestfile.cmake
*_tests[1-9]*_include.cmake
*_include.cmake
*_tests.cmake

# Build files
.cache/
target/
build/
build/
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.14)
project(my_project VERSION 1.0.0 LANGUAGES CXX)
project(kiwicpp VERSION 1.0.0 LANGUAGES CXX)

# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
Expand Down
4 changes: 2 additions & 2 deletions examples/example1.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <iostream>

#include "my_project/library.hpp"
#include "kiwicpp/library.hpp"

int main() {
std::cout << "Sum: " << my_project::add(2, 3) << std::endl;
std::cout << "Sum: " << KiwiCPP::add(2, 3) << std::endl;
return 0;
}
5 changes: 5 additions & 0 deletions include/kiwicpp/library.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

namespace KiwiCPP {
int add(int a, int b);
} // namespace KiwiCPP
5 changes: 0 additions & 5 deletions include/my_project/library.hpp

This file was deleted.

6 changes: 3 additions & 3 deletions src/library.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "my_project/library.hpp"
#include "../include/kiwicpp/library.hpp"

namespace my_project {
namespace KiwiCPP {
int add(int a, int b) { return a + b; }
} // namespace my_project
} // namespace KiwiCPP
10 changes: 5 additions & 5 deletions tests/test_library.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <gtest/gtest.h>

#include "my_project/library.hpp"
#include "../include/kiwicpp/library.hpp"

TEST(LibraryTest, Add) {
// Consider adding more test cases
EXPECT_EQ(my_project::add(2, 3), 5);
EXPECT_EQ(my_project::add(-1, 1), 0);
EXPECT_EQ(my_project::add(0, 0), 0); // test zero case
EXPECT_EQ(my_project::add(-2, -3), -5); // test negative numbers
EXPECT_EQ(KiwiCPP::add(2, 3), 5);
EXPECT_EQ(KiwiCPP::add(-1, 1), 0);
EXPECT_EQ(KiwiCPP::add(0, 0), 0);
EXPECT_EQ(KiwiCPP::add(-2, -3), -5);
}

0 comments on commit 3eda466

Please sign in to comment.