Skip to content

Commit

Permalink
add test files
Browse files Browse the repository at this point in the history
  • Loading branch information
hotstreams authored and hotstreams committed Jun 17, 2023
1 parent 3efb7a0 commit ab54c57
Show file tree
Hide file tree
Showing 19 changed files with 20,872 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/cmake/
/cmake-build-debug/
/cmake-build-release/
/tests
/cmake-build-release/
44 changes: 44 additions & 0 deletions test/buffer_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <gtest/gtest.h>

#include <limitless/core/context.hpp>
#include <limitless/core/state_buffer.hpp>
#include <limitless/core/state_query.hpp>

TEST(BufferTest, StateBufferFunctions) {
using namespace Limitless;

Context context {"test context", {1, 1}, {{WindowHint::Visible, false}}};

// bind, bindAs, bindBase, bindBaseAs works as expected
// * state is right when its used
// * state is right when move constructor is invoked
// * state is right when buffer was resized
// * state is right when buffer was cloned
// * state is right when buffer was deleted
// * and map method returned success

// test every above scenario with complicated state (binding points in particular)
{
const auto BUFFER_SIZE = 1024;
StateBuffer buffer {Buffer::Type::Array, BUFFER_SIZE, nullptr, Buffer::Usage::StaticDraw, Buffer::MutableAccess::None};
StateQuery query;

buffer.bind();

ASSERT_EQ(buffer.getId(), context.getBufferTargets().at(Buffer::Type::Array));
ASSERT_EQ(context.getBufferTargets().at(Buffer::Type::Array), query.geti(QueryState::ArrayBufferBinding));
}

{
const auto BUFFER_SIZE = 1024;
StateBuffer buffer {Buffer::Type::Array, BUFFER_SIZE, nullptr, Buffer::Storage::Static, Buffer::ImmutableAccess::None};
StateQuery query;

buffer.bind();
buffer.resize(2048);
buffer.bind();

ASSERT_EQ(buffer.getId(), context.getBufferTargets().at(Buffer::Type::Array));
ASSERT_EQ(context.getBufferTargets().at(Buffer::Type::Array), query.geti(QueryState::ArrayBufferBinding));
}
}
5 changes: 5 additions & 0 deletions test/limitless/assets/shader1.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#version 330

void main() {

}
5 changes: 5 additions & 0 deletions test/limitless/assets/shader2.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Limitless::GLSL_VERSION

void main() {

}
7 changes: 7 additions & 0 deletions test/limitless/assets/shader3.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Limitless::GLSL_VERSION

Limitless::Extensions

void main() {

}
9 changes: 9 additions & 0 deletions test/limitless/assets/shader4.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Limitless::GLSL_VERSION

Limitless::Extensions

#include "./test_include.glsl"

void main() {

}
9 changes: 9 additions & 0 deletions test/limitless/assets/shader5.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Limitless::GLSL_VERSION

Limitless::Extensions

#include "./test_dir/test_include.glsl"

void main() {

}
9 changes: 9 additions & 0 deletions test/limitless/assets/shader6.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Limitless::GLSL_VERSION

Limitless::Extensions

#include "./test_dir/test_include.glsl"

void main() {
SOME_STATEMENT
}
9 changes: 9 additions & 0 deletions test/limitless/assets/shader7.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Limitless::GLSL_VERSION

Limitless::Extensions

#include "./test_dir/not_found.glsl"

void main() {

}
7 changes: 7 additions & 0 deletions test/limitless/assets/shader8.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Limitless::GLSL_VERSION

Limitless::Extensions

void main() {
kek shrek
}
5 changes: 5 additions & 0 deletions test/limitless/assets/test_dir/test_include.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "../test_include.glsl"

int test_function1() {
return 42;
}
3 changes: 3 additions & 0 deletions test/limitless/assets/test_include.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int test_function() {
return 42;
}
Loading

0 comments on commit ab54c57

Please sign in to comment.