+static int str_test_upper(struct unit_test_state *uts)
+{
+ char out[TEST_STR_SIZE];
+
+ /* Make sure it adds a terminator */
+ out[strlen(str1)] = 'a';
+ str_to_upper(str1, out, SIZE_MAX);
+ ut_asserteq_str("I'M SORRY I'M LATE.", out);
+
+ /* In-place operation */
+ strcpy(out, str2);
+ str_to_upper(out, out, SIZE_MAX);
+ ut_asserteq_str("1099ABNO, DON'T BOTHER APOLOGISING.", out);
+
+ /* Limited length */
+ str_to_upper(str1, out, 7);
+ ut_asserteq_str("I'M SORO, DON'T BOTHER APOLOGISING.", out);
+
+ /* In-place with limited length */
+ strcpy(out, str2);
+ str_to_upper(out, out, 7);
+ ut_asserteq_str("1099ABNo, don't bother apologising.", out);
+
+ /* Copy an empty string to a buffer with space*/
+ out[1] = 0x7f;
+ str_to_upper("", out, SIZE_MAX);
+ ut_asserteq('\0', *out);
+ ut_asserteq(0x7f, out[1]);
+
+ /* Copy an empty string to a buffer with no space*/
+ out[0] = 0x7f;
+ str_to_upper("", out, 0);
+ ut_asserteq(0x7f, out[0]);
+
+ return 0;
+}
+STR_TEST(str_test_upper, 0);
+