Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision 055a68ab1371c586f29857ab43fca766da6c947b)
+++ uspace/lib/c/Makefile	(revision a18a8b98aaf4c1d3de4b05b95565daf1aa01a1c8)
@@ -171,5 +171,6 @@
 TEST_SOURCES = \
 	test/main.c \
-	test/sprintf.c
+	test/sprintf.c \
+	test/str.c
 
 include $(USPACE_PREFIX)/Makefile.common
Index: uspace/lib/c/generic/str.c
===================================================================
--- uspace/lib/c/generic/str.c	(revision 055a68ab1371c586f29857ab43fca766da6c947b)
+++ uspace/lib/c/generic/str.c	(revision a18a8b98aaf4c1d3de4b05b95565daf1aa01a1c8)
@@ -534,5 +534,5 @@
 
 		if (c1 == 0 || c2 == 0)
-			break;		
+			break;
 	}
 
@@ -588,5 +588,5 @@
 			break;
 
-		++len;	
+		++len;
 	}
 
@@ -1058,5 +1058,5 @@
 		memmove(str, &str[pos], str_sz - pos);
 		pos = str_sz - pos;
-		str[str_sz - pos] = '\0';
+		str[pos] = '\0';
 	}
 }
@@ -1151,5 +1151,5 @@
 }
 
-/** Convert string to a number. 
+/** Convert string to a number.
  * Core of strtol and strtoul functions.
  *
@@ -1197,5 +1197,5 @@
 				str += 2;
 			}
-		} 
+		}
 	}
 	
@@ -1236,5 +1236,5 @@
 		*endptr = (char *) str;
 
-	if (nptr == str) { 
+	if (nptr == str) {
 		/*FIXME: errno = EINVAL*/
 		return 0;
@@ -1267,8 +1267,8 @@
 		if ((sgn) && (number == (unsigned long) (LONG_MAX) + 1)) {
 			/* FIXME: set 0 to errno */
-			return number;		
+			return number;
 		}
 		/* FIXME: set ERANGE to errno */
-		return (sgn ? LONG_MIN : LONG_MAX);	
+		return (sgn ? LONG_MIN : LONG_MAX);
 	}
 	
Index: uspace/lib/c/test/main.c
===================================================================
--- uspace/lib/c/test/main.c	(revision 055a68ab1371c586f29857ab43fca766da6c947b)
+++ uspace/lib/c/test/main.c	(revision a18a8b98aaf4c1d3de4b05b95565daf1aa01a1c8)
@@ -33,4 +33,5 @@
 
 PCUT_IMPORT(sprintf);
+PCUT_IMPORT(str);
 
 PCUT_MAIN()
Index: uspace/lib/c/test/str.c
===================================================================
--- uspace/lib/c/test/str.c	(revision a18a8b98aaf4c1d3de4b05b95565daf1aa01a1c8)
+++ uspace/lib/c/test/str.c	(revision a18a8b98aaf4c1d3de4b05b95565daf1aa01a1c8)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2015 Michal Koutny
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <str.h>
+#include <pcut/pcut.h>
+
+#define BUFFER_SIZE 256
+
+#define SET_BUFFER(str) snprintf(buffer, BUFFER_SIZE, "%s", str)
+#define EQ(expected, value) PCUT_ASSERT_STR_EQUALS(expected, value)
+
+
+
+PCUT_INIT
+
+PCUT_TEST_SUITE(str);
+
+static char buffer[BUFFER_SIZE];
+
+PCUT_TEST_BEFORE {
+	memset(buffer, 0, BUFFER_SIZE);
+}
+
+
+PCUT_TEST(rtrim) {
+	SET_BUFFER("foobar");
+	str_rtrim(buffer, ' ');
+	EQ("foobar", buffer);
+
+	SET_BUFFER("  foobar  ");
+	str_rtrim(buffer, ' ');
+	EQ("  foobar", buffer);
+
+	SET_BUFFER("  ššš  ");
+	str_rtrim(buffer, ' ');
+	EQ("  ššš", buffer);
+
+	SET_BUFFER("ššAAAšš");
+	str_rtrim(buffer, L'š');
+	EQ("ššAAA", buffer);
+}
+
+PCUT_TEST(ltrim) {
+	SET_BUFFER("foobar");
+	str_ltrim(buffer, ' ');
+	EQ("foobar", buffer);
+
+	SET_BUFFER("  foobar  ");
+	str_ltrim(buffer, ' ');
+	EQ("foobar  ", buffer);
+
+	SET_BUFFER("  ššš  ");
+	str_ltrim(buffer, ' ');
+	EQ("ššš  ", buffer);
+
+	SET_BUFFER("ššAAAšš");
+	str_ltrim(buffer, L'š');
+	EQ("AAAšš", buffer);
+}
+
+
+PCUT_EXPORT(str);
