Skip to content

Commit

Permalink
glm_perlin_vec2 test
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinKonowalczyk committed Jan 17, 2025
1 parent 1377a94 commit 9085ed0
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/src/test_noise.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,43 @@ TEST_IMPL(GLM_PREFIX, perlin_vec3) {

TEST_SUCCESS
}


TEST_IMPL(GLM_PREFIX, perlin_vec2) {
vec2 p1[] = {
{0.1f, 0.2f},
{0.2f, 0.3f},
{0.3f, 0.4f},
{0.4f, 0.5f},
{0.5f, 0.6f},
{0.6f, 0.7f},
{0.7f, 0.8f},
{0.8f, 0.9f},
{0.9f, 1.0f},
{1.0f, 1.1f},
};

// expected values calculated by glm::perlin
float e[] = {
0.2841092348098755f,
0.2328013032674789f,
-0.0017980185803026f,
-0.3300299644470215f,
-0.5998955368995667f,
-0.6914522647857666f,
-0.5896517634391785f,
-0.3778679668903351f,
-0.1557840555906296f,
0.0453133136034012f
};

for (int i = 0; i < 10; i++) {
ASSERT(test_eq(GLM(perlin_vec2)(p1[i]), e[i]));
}

TEST_SUCCESS
}




4 changes: 4 additions & 0 deletions test/tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ TEST_DECLARE(glm_perlin_vec4)
TEST_DECLARE(glmc_perlin_vec4)
TEST_DECLARE(glm_perlin_vec3)
TEST_DECLARE(glmc_perlin_vec3)
TEST_DECLARE(glm_perlin_vec2)
TEST_DECLARE(glmc_perlin_vec2)

/* utils */
TEST_DECLARE(clamp)
Expand Down Expand Up @@ -1545,6 +1547,8 @@ TEST_LIST {
TEST_ENTRY(glmc_perlin_vec4)
TEST_ENTRY(glm_perlin_vec3)
TEST_ENTRY(glmc_perlin_vec3)
TEST_ENTRY(glm_perlin_vec2)
TEST_ENTRY(glmc_perlin_vec2)

/* utils */
TEST_ENTRY(clamp)
Expand Down

0 comments on commit 9085ed0

Please sign in to comment.