From 8a77eb32cd8ea4a4f52adddab507dab1f6d6a930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Mon, 23 Oct 2017 08:27:23 -0700 Subject: [PATCH] Added easing test file. --- tests/easing_test.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 tests/easing_test.cpp diff --git a/tests/easing_test.cpp b/tests/easing_test.cpp new file mode 100644 index 0000000..a15587b --- /dev/null +++ b/tests/easing_test.cpp @@ -0,0 +1,61 @@ +/* + * Copyright 2010-2017 Branimir Karadzic. All rights reserved. + * License: https://github.com/bkaradzic/bx#license-bsd-2-clause + */ + +#include "test.h" + +#include +#include + +TEST_CASE("easing", "") +{ + if (BX_ENABLED(false) ) + { + bx::WriterI* writer = bx::getStdOut(); + + for (uint32_t ee = 0; ee < bx::Easing::Count; ++ee) + { + bx::writePrintf(writer, "\n\n%d\n", ee); + + const bx::EaseFn easing = bx::getEaseFunc(bx::Easing::Enum(ee) ); + + const int32_t nx = 64; + const int32_t ny = 10; + + bx::writePrintf(writer, "\t/// ^\n"); + + for (int32_t yy = ny+4; yy >= -5; --yy) + { + const float ys = float(yy )/float(ny); + const float ye = float(yy+1.0)/float(ny); + + bx::writePrintf(writer, "\t/// %c", yy != 0 ? '|' : '+'); + + for (int32_t xx = 0; xx < nx; ++xx) + { + int32_t jj = 0; + for (; jj < 10; ++jj) + { + const float tt = float(xx*10+jj)/10.0f/float(nx); + const float vv = easing(tt); + + if (vv >= ys + && vv < ye) + { + bx::writePrintf(writer, "*"); + break; + } + } + + if (jj == 10) + { + bx::writePrintf(writer, "%c", yy != 0 ? ' ' : '-'); + } + } + + bx::writePrintf(writer, "%s\n", yy != 0 ? "" : ">"); + } + } + } +}