Save App
This commit is contained in:
parent
6c5d3f4e79
commit
51d20067c6
3
App/.vscode/settings.json
vendored
3
App/.vscode/settings.json
vendored
@ -70,7 +70,8 @@
|
|||||||
"xlocbuf": "cpp",
|
"xlocbuf": "cpp",
|
||||||
"xlocmes": "cpp",
|
"xlocmes": "cpp",
|
||||||
"xlocmon": "cpp",
|
"xlocmon": "cpp",
|
||||||
"xloctime": "cpp"
|
"xloctime": "cpp",
|
||||||
|
"array": "cpp"
|
||||||
},
|
},
|
||||||
"cmake.configureOnOpen": true
|
"cmake.configureOnOpen": true
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ namespace App
|
|||||||
opengl_shader_compile_source(fs, fs_source);
|
opengl_shader_compile_source(fs, fs_source);
|
||||||
|
|
||||||
m_prog = glCreateProgram();
|
m_prog = glCreateProgram();
|
||||||
opengl_shader_link_program(m_prog, vs, fs);
|
// opengl_shader_link_program(m_prog, vs, fs);
|
||||||
|
|
||||||
GLint uniform_angle = glGetUniformLocation(m_prog, "angle");
|
GLint uniform_angle = glGetUniformLocation(m_prog, "angle");
|
||||||
|
|
||||||
|
|||||||
26
App/AppLib/include/AppLib/Algorithm.cpp
Normal file
26
App/AppLib/include/AppLib/Algorithm.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include "Algorithm.hh"
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
|
||||||
|
vector<int> Algorithm::selection_sort(vector<int> &arr)
|
||||||
|
{
|
||||||
|
vector<int> ret = vector<int>();
|
||||||
|
|
||||||
|
int sorted_index = 0;
|
||||||
|
|
||||||
|
if(arr.size() == 0 || arr.size() == 1)
|
||||||
|
{
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int elem : arr)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
16
App/AppLib/include/AppLib/Algorithm.hh
Normal file
16
App/AppLib/include/AppLib/Algorithm.hh
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// https://www.interviewcake.com/sorting-algorithm-cheat-sheet
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
|
||||||
|
class Algorithm
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static vector<int> selection_sort(vector<int> &arr);
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
} // namespace Core
|
||||||
17
App/Tests/AlgoTest.cpp
Normal file
17
App/Tests/AlgoTest.cpp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <gmock/gmock.h>
|
||||||
|
|
||||||
|
#include "Helpers.hh"
|
||||||
|
|
||||||
|
using namespace Core;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
|
TEST(Algo, selection_sort)
|
||||||
|
{
|
||||||
|
EXPECT_CALL(turtle, PenDown()) // #3
|
||||||
|
.Times(AtLeast(1));
|
||||||
|
vector<int> vec1 = vector<int>{3,2,1,35,24};
|
||||||
|
vector<int> vec2 = Algorithm::selection_sort(vec1);
|
||||||
|
ASSERT_TRUE(Helpers::is_sorted(vec2) == true);
|
||||||
|
|
||||||
|
}
|
||||||
7
App/Tests/AllTests.cpp
Normal file
7
App/Tests/AllTests.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
testing::InitGoogleTest(&argc, argv);
|
||||||
|
return RUN_ALL_TESTS();
|
||||||
|
}
|
||||||
@ -4,9 +4,14 @@ enable_testing()
|
|||||||
|
|
||||||
add_executable(
|
add_executable(
|
||||||
AppTest
|
AppTest
|
||||||
|
AllTests.cpp
|
||||||
MathTest.cpp
|
MathTest.cpp
|
||||||
|
AlgoTest.cpp
|
||||||
|
Helpers.hh
|
||||||
|
MockAlgorithm.hh
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
target_include_directories(App PUBLIC "${CMAKE_SOURCE_DIR}/AppLib/include/AppLib")
|
target_include_directories(App PUBLIC "${CMAKE_SOURCE_DIR}/AppLib/include/AppLib")
|
||||||
|
|
||||||
find_package(GTest CONFIG REQUIRED)
|
find_package(GTest CONFIG REQUIRED)
|
||||||
@ -25,4 +30,5 @@ endif()
|
|||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
gtest_discover_tests(AppTest)
|
gtest_discover_tests(AppTest)
|
||||||
|
|
||||||
add_test(MathTest AppTest)
|
add_test(AppTest AppTest)
|
||||||
|
# add_test(MathTest AppTest)
|
||||||
21
App/Tests/Helpers.hh
Normal file
21
App/Tests/Helpers.hh
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
|
class Helpers {
|
||||||
|
public:
|
||||||
|
static bool is_sorted(std::vector<int> &arr)
|
||||||
|
{
|
||||||
|
int index = 0;
|
||||||
|
for (auto e : arr)
|
||||||
|
{
|
||||||
|
if(index == 0)
|
||||||
|
index++;
|
||||||
|
continue;
|
||||||
|
if(e < arr[index-1])
|
||||||
|
return false;
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -21,9 +21,4 @@ TEST(Math, Vector2_Add)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO (Eero): Add tests for Vector2
|
//TODO (Eero): Add tests for Vector2
|
||||||
//TODO (Eero): Add tests for Vector3
|
//TODO (Eero): Add tests for Vector3
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
|
||||||
return RUN_ALL_TESTS();
|
|
||||||
}
|
|
||||||
14
App/Tests/MockAlgorithm.hh
Normal file
14
App/Tests/MockAlgorithm.hh
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include <vector>
|
||||||
|
#include <gmock/gmock.h>
|
||||||
|
#include "Algorithm.hh"
|
||||||
|
|
||||||
|
using std:: vector;
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
class MockAlgorithm : Algorithm
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MOCK_METHOD(vector<int>, selection_sort, (vector<int> arr&), ());
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user