improved tests by validating that buffer gets not modified before or
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Tue, 25 Oct 2005 16:23:45 +0000 (16:23 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Tue, 25 Oct 2005 16:23:45 +0000 (16:23 +0000)
after the indented space

git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2185 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/lib/testsuite/fmt.c

index 356067a..c2b2f81 100644 (file)
 #define TEST(VAL, EXP) {                       \
     char       buf[512];                       \
     size_t     l;                              \
-    memset(buf, '\23', sizeof buf);            \
+    memset(buf+1, '\23', sizeof(buf)-2);       \
+    buf[0] = buf[sizeof(EXP)] = '\42';         \
     l = FUNC(buf+1, VAL);                      \
     assert(l==sizeof(EXP)-1);                  \
     assert(memcmp(buf+1, EXP, l)==0);          \
-    assert(buf[l+1]=='\23');                   \
+    assert(buf[0]  =='\42');                   \
+    assert(buf[l+1]=='\42');                   \
+    assert(buf[l+2]=='\23');                   \
   }
 
 int main()