TestValueFlow::valueFlowArrayElement: Refactoring tests

This commit is contained in:
Daniel Marjamäki 2015-07-27 16:25:14 +02:00
parent f449e91d43
commit b50f554b28
1 changed files with 10 additions and 6 deletions

View File

@ -204,18 +204,22 @@ private:
const char *code; const char *code;
code = "void f() {\n" code = "void f() {\n"
" const int a[] = {43,23,12};\n" " const int x[] = {43,23,12};\n"
" int x = a[0];\n"
" return x;\n" " return x;\n"
"}"; "}";
ASSERT_EQUALS(true, testValueOfX(code, 4U, 43)); ASSERT_EQUALS(true, testValueOfX(code, 3U, "{ 43 , 23 , 12 }"));
code = "void f() {\n" code = "void f() {\n"
" const char abcd[] = \"abcd\";\n" " const char x[] = \"abcd\";\n"
" int x = abcd[2];\n"
" return x;\n" " return x;\n"
"}"; "}";
ASSERT_EQUALS(true, testValueOfX(code, 4U, 'c')); ASSERT_EQUALS(true, testValueOfX(code, 3U, "\"abcd\""));
code = "void f() {\n"
" char x[32] = \"abcd\";\n"
" return x;\n"
"}";
TODO_ASSERT_EQUALS(true, false, testValueOfX(code, 3U, "\"abcd\""));
} }
void valueFlowCalculations() { void valueFlowCalculations() {