-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniel Marjamäki
committed
Aug 28, 2008
1 parent
0f036f6
commit 778410c
Showing
6 changed files
with
139 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
|
||
|
||
|
||
#include "tokenize.h" | ||
#include "CommonCheck.h" | ||
#include "CheckOther.h" | ||
#include "MiniCppUnit.h" | ||
|
||
#include <sstream> | ||
|
||
extern std::ostringstream errout; | ||
extern bool ShowAll; | ||
|
||
class TestCharVar : public TestFixture<TestCharVar> | ||
{ | ||
private: | ||
void check( const char code[] ) | ||
{ | ||
// Tokenize.. | ||
tokens = tokens_back = NULL; | ||
std::istringstream istr(code); | ||
TokenizeCode( istr ); | ||
|
||
// Fill function list | ||
FillFunctionList(0); | ||
|
||
// Clear the error buffer.. | ||
errout.str(""); | ||
|
||
// Check for memory leaks.. | ||
ShowAll = true; | ||
CheckCharVariable(); | ||
} | ||
|
||
public: | ||
TEST_FIXTURE( TestCharVar ) | ||
{ | ||
TEST_CASE( array_index ); | ||
} | ||
|
||
|
||
void array_index() | ||
{ | ||
check( "void foo()\n" | ||
"{\n" | ||
" unsigned char ch = 0x80;\n" | ||
" buf[ch] = 0;\n" | ||
"}\n" ); | ||
ASSERT_EQUALS( std::string(""), errout.str() ); | ||
|
||
check( "void foo()\n" | ||
"{\n" | ||
" char ch = 0x80;\n" | ||
" buf[ch] = 0;\n" | ||
"}\n" ); | ||
ASSERT_EQUALS( std::string("[test.cpp:4]: Warning - using char variable as array index\n"), errout.str() ); | ||
} | ||
|
||
}; | ||
|
||
REGISTER_FIXTURE( TestCharVar ) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters