Simplify TS alloc: move slot check into functions

Move timeslot applicability check outside of nested for loop into
separate functions and document them. Add corresponding tests.

This allows us to clarify types used in TS-related computations.

Change-Id: Ic39e848da47dc11357782362fdf6206d2c1457c2
Related: OS#2282
diff --git a/tests/alloc/MslotTest.cpp b/tests/alloc/MslotTest.cpp
index 1fa28bf..92f92fa 100644
--- a/tests/alloc/MslotTest.cpp
+++ b/tests/alloc/MslotTest.cpp
@@ -27,6 +27,7 @@
 #include <errno.h>
 
 extern "C" {
+	#include "mslot_class.h"
 #include <osmocom/core/application.h>
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/talloc.h>
@@ -137,6 +138,13 @@
 	test_all_classes(trx, seq);
 }
 
+static inline void test_window_wrapper()
+{
+	uint16_t i;
+	for (i = 0; i < 256 * 2 + 1; i++)
+		printf("W[%03u] -> %3u %s\n",
+		       i, mslot_wrap_window(i), mslot_wrap_window(i) < 256 ? "OK" : "FAIL");
+}
 
 int main(int argc, char **argv)
 {
@@ -163,6 +171,8 @@
 	test_multislot_ends(true);
 	test_multislot_ends(false);
 
+	test_window_wrapper();
+
 	return EXIT_SUCCESS;
 }