utils_test: add osmo_print_n_test()

A couple of times recently I've needed to copy out a substring to a buffer with
limited size. Use of strncpy() or osmo_strlcpy() are nontrivial here.
I wanted to have a dedicated function.

After I wrote that function with a test, I noticed that I had already
implemented the same thing a while ago, as osmo_print_n() :P
So here is just the test.

Change-Id: Ia716abdc1f58af6065b84f4f567388a32a7b39fc
diff --git a/tests/utils/utils_test.ok b/tests/utils/utils_test.ok
index b603647..d5cf491 100644
--- a/tests/utils/utils_test.ok
+++ b/tests/utils/utils_test.ok
@@ -377,3 +377,29 @@
       OSMO_NAME_C_IMPL(10, NULL) -> NULL  allocated 0
     OSMO_NAME_C_IMPL(0, "ERROR") -> "ERROR"  allocated 1  6 bytes, name 'foo_name_c_zero'
        OSMO_NAME_C_IMPL(0, NULL) -> NULL  allocated 0
+
+osmo_print_n_test()
+"foo=bar" token_len=3 buf_size=100 -> token="foo" rc=3
+"foo" token_len=10 buf_size=100 -> token="foo" rc=3
+"foo" token_len=3 buf_size=100 -> token="foo" rc=3
+NULL token_len=10 buf_size=100 -> token="" rc=0
+"" token_len=10 buf_size=100 -> token="" rc=0
+"foo=bar" token_len=0 buf_size=100 -> token="" rc=0
+"foo=bar" token_len=3 buf_size=2 -> token="f" rc=3
+"foo" token_len=10 buf_size=2 -> token="f" rc=3
+"foo" token_len=3 buf_size=2 -> token="f" rc=3
+NULL token_len=10 buf_size=2 -> token="" rc=0
+"" token_len=10 buf_size=2 -> token="" rc=0
+"foo=bar" token_len=0 buf_size=2 -> token="" rc=0
+"foo=bar" token_len=3 buf_size=1 -> token="" rc=3
+"foo" token_len=10 buf_size=1 -> token="" rc=3
+"foo" token_len=3 buf_size=1 -> token="" rc=3
+NULL token_len=10 buf_size=1 -> token="" rc=0
+"" token_len=10 buf_size=1 -> token="" rc=0
+"foo=bar" token_len=0 buf_size=1 -> token="" rc=0
+"foo=bar" token_len=3 buf_size=0 -> token="unchanged" rc=3
+"foo" token_len=10 buf_size=0 -> token="unchanged" rc=3
+"foo" token_len=3 buf_size=0 -> token="unchanged" rc=3
+NULL token_len=10 buf_size=0 -> token="unchanged" rc=0
+"" token_len=10 buf_size=0 -> token="unchanged" rc=0
+"foo=bar" token_len=0 buf_size=0 -> token="unchanged" rc=0