1
0
forked from 0ad/0ad

# fixes to string_s selftest

snd_mgr: fix cppdoc comments (got shredded by IDE autofmt)
string_s: disable WARN_IF_PTR_LEN (too many false positives)
test_string_s: add missing debug_skip_next_err (fixes complaints on
VC2003)

refs #130

This was SVN commit r4066.
This commit is contained in:
janwas 2006-07-06 15:52:59 +00:00
parent a95c72d0c1
commit dd6679b0b8
3 changed files with 535 additions and 510 deletions

File diff suppressed because it is too large Load Diff

View File

@ -70,10 +70,14 @@
// raise a debug warning if <len> is the size of a pointer.
// catches bugs such as: tchar* s = ..; tcpy_s(s, sizeof(s), T(".."));
// if warnings get annoying, replace with debug_printf. usable as a statement.
#define WARN_IF_PTR_LEN(len) STMT( \
//
// currently disabled due to high risk of false positives.
#define WARN_IF_PTR_LEN(len)\
/*
STMT( \
if(len == sizeof(char*)) \
debug_warn("make sure string buffer size is correct");\
)
)*/
// skip our implementation if already available, but not the

View File

@ -119,31 +119,53 @@ public:
debug_skip_next_err(ERR_INVALID_PARAM);
TEST_CPY(d1,0,s1, ERANGE,""); // max_dst_chars = 0
debug_skip_next_err(ERR_BUF_SIZE);
TEST_CPY2(d1,1, s1, ERANGE,"");
debug_skip_next_err(ERR_BUF_SIZE);
TEST_CPY2(d1,1, s5, ERANGE,"");
debug_skip_next_err(ERR_BUF_SIZE);
TEST_CPY2(d5,5, s5, ERANGE,"");
debug_skip_next_err(ERR_BUF_SIZE);
TEST_NCPY(d1,1 ,s1,1, ERANGE,"");
debug_skip_next_err(ERR_BUF_SIZE);
TEST_NCPY(d1,1 ,s5,1, ERANGE,"");
debug_skip_next_err(ERR_BUF_SIZE);
TEST_NCPY(d5,5 ,s5,5, ERANGE,"");
debug_skip_next_err(ERR_INVALID_PARAM);
TEST_CAT(0 ,0,0 , EINVAL,""); // all invalid
debug_skip_next_err(ERR_INVALID_PARAM);
TEST_CAT(0 ,0,s1, EINVAL,""); // dst = 0, max = 0
debug_skip_next_err(ERR_INVALID_PARAM);
TEST_CAT(0 ,1,s1, EINVAL,""); // dst = 0, max > 0
debug_skip_next_err(ERR_INVALID_PARAM);
TEST_CAT(d1,1,0 , EINVAL,""); // src = 0
debug_skip_next_err(ERR_INVALID_PARAM);
TEST_CAT(d1,0,s1, ERANGE,""); // max_dst_chars = 0
debug_skip_next_err(ERR_STRING_NOT_TERMINATED);
TEST_CAT(no_null,5,s1, ERANGE,""); // dst not terminated
debug_skip_next_err(ERR_BUF_SIZE);
TEST_CAT2(d1,1, s1, "",ERANGE,"");
debug_skip_next_err(ERR_BUF_SIZE);
TEST_CAT2(d1,1, s5, "",ERANGE,"");
debug_skip_next_err(ERR_BUF_SIZE);
TEST_CAT2(d10,10, s10, "",ERANGE,""); // empty, total overflow
debug_skip_next_err(ERR_BUF_SIZE);
TEST_CAT2(d10,10, s5, "12345",ERANGE,""); // not empty, overflow
debug_skip_next_err(ERR_BUF_SIZE);
TEST_CAT2(d10,10, s10, "12345",ERANGE,""); // not empty, total overflow
debug_skip_next_err(ERR_BUF_SIZE);
TEST_NCAT(d1,1, s1,1, "",ERANGE,"");
debug_skip_next_err(ERR_BUF_SIZE);
TEST_NCAT(d1,1, s5,5, "",ERANGE,"");
debug_skip_next_err(ERR_BUF_SIZE);
TEST_NCAT(d10,10, s10,10, "",ERANGE,""); // empty, total overflow
debug_skip_next_err(ERR_BUF_SIZE);
TEST_NCAT(d10,10, s5,5, "12345",ERANGE,""); // not empty, overflow
debug_skip_next_err(ERR_BUF_SIZE);
TEST_NCAT(d10,10, s10,10, "12345",ERANGE,""); // not empty, total overflow
#endif
}
@ -179,7 +201,6 @@ public:
strcpy(d5, "----");
TEST_NCPY(d5,5, s5,0 , 0,""); // specified behavior! see 3.6.2.1.1 #4
TEST_NCPY(d5,5, s5,1 , 0,"a");
TEST_NCPY(d5,5, s5,4 , 0,"abcd");
TEST_NCPY(d6,6, s5,5 , 0,"abcde");
TEST_NCPY(d6,6, s5,10, 0,"abcde");
}